Class: Lich::Common::GUI::CallbackParams

Inherits:
Object
  • Object
show all
Defined in:
documented/common/gui/parameter_objects.rb

Overview

Represents the callback parameters for various UI actions.

Examples:

Creating callback parameters

callbacks = CallbackParams.new(on_play: -> { puts "Playing" })

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ CallbackParams

Initializes a new instance of CallbackParams.

Parameters:

  • params (Hash) (defaults to: {})

    A hash of callback parameters.

Options Hash (params):

  • :on_play (Proc)

    Callback for play action.

  • :on_remove (Proc)

    Callback for remove action.

  • :on_save (Proc)

    Callback for save action.

  • :on_error (Proc)

    Callback for error action.

  • :on_theme_change (Proc)

    Callback for theme change.

  • :on_layout_change (Proc)

    Callback for layout change.

  • :on_sort_change (Proc)

    Callback for sort change.

  • :on_add_character (Proc)

    Callback for adding a character.

  • :on_favorites_change (Proc)

    Callback for favorites change.

  • :on_favorites_reorder (Proc)

    Callback for reordering favorites.



105
106
107
108
109
110
111
112
113
114
115
116
# File 'documented/common/gui/parameter_objects.rb', line 105

def initialize(params = {})
  @on_play = params[:on_play]
  @on_remove = params[:on_remove]
  @on_save = params[:on_save]
  @on_error = params[:on_error]
  @on_theme_change = params[:on_theme_change]
  @on_layout_change = params[:on_layout_change]
  @on_sort_change = params[:on_sort_change]
  @on_add_character = params[:on_add_character]
  @on_favorites_change = params[:on_favorites_change]
  @on_favorites_reorder = params[:on_favorites_reorder]
end

Instance Attribute Details

#on_add_characterObject

Returns the value of attribute on_add_character.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_add_character
  @on_add_character
end

#on_errorObject

Returns the value of attribute on_error.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_error
  @on_error
end

#on_favorites_changeObject

Returns the value of attribute on_favorites_change.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_favorites_change
  @on_favorites_change
end

#on_favorites_reorderObject

Returns the value of attribute on_favorites_reorder.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_favorites_reorder
  @on_favorites_reorder
end

#on_layout_changeObject

Returns the value of attribute on_layout_change.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_layout_change
  @on_layout_change
end

#on_playObject

Returns the value of attribute on_play.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_play
  @on_play
end

#on_removeObject

Returns the value of attribute on_remove.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_remove
  @on_remove
end

#on_saveObject

Returns the value of attribute on_save.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_save
  @on_save
end

#on_sort_changeObject

Returns the value of attribute on_sort_change.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_sort_change
  @on_sort_change
end

#on_theme_changeObject

Returns the value of attribute on_theme_change.



88
89
90
# File 'documented/common/gui/parameter_objects.rb', line 88

def on_theme_change
  @on_theme_change
end

Instance Method Details

#to_hHash

Converts the CallbackParams instance to a hash.

Examples:

Converting to hash

callbacks.to_h #=> { on_play: -> { puts "Playing" }, on_remove: -> { puts "Removing" } }

Returns:

  • (Hash)

    A hash representation of the callback parameters.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'documented/common/gui/parameter_objects.rb', line 122

def to_h
  {
    on_play: @on_play,
    on_remove: @on_remove,
    on_save: @on_save,
    on_error: @on_error,
    on_theme_change: @on_theme_change,
    on_layout_change: @on_layout_change,
    on_sort_change: @on_sort_change,
    on_add_character: @on_add_character,
    on_favorites_change: @on_favorites_change,
    on_favorites_reorder: @on_favorites_reorder
  }
end