Class: Ruflet::Events::ReorderEvent
- Inherits:
-
GenericEvent
- Object
- BasePayload
- GenericEvent
- Ruflet::Events::ReorderEvent
- Defined in:
- lib/ruflet_ui/ruflet/events/gesture_events.rb
Instance Attribute Summary collapse
-
#new_index ⇒ Object
readonly
Returns the value of attribute new_index.
-
#old_index ⇒ Object
readonly
Returns the value of attribute old_index.
Attributes inherited from GenericEvent
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(raw:, old_index:, new_index:) ⇒ ReorderEvent
constructor
A new instance of ReorderEvent.
Methods inherited from BasePayload
duration, offset, offset_pair, pick, stringify_keys
Constructor Details
#initialize(raw:, old_index:, new_index:) ⇒ ReorderEvent
Returns a new instance of ReorderEvent.
104 105 106 107 108 |
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 104 def initialize(raw:, old_index:, new_index:) super(raw: raw, value: [old_index, new_index]) @old_index = old_index @new_index = new_index end |
Instance Attribute Details
#new_index ⇒ Object (readonly)
Returns the value of attribute new_index.
102 103 104 |
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 102 def new_index @new_index end |
#old_index ⇒ Object (readonly)
Returns the value of attribute old_index.
102 103 104 |
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 102 def old_index @old_index end |
Class Method Details
.from_data(data) ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 110 def self.from_data(data) raw = data.is_a?(Hash) ? stringify_keys(data) : {} new( raw: raw, old_index: raw["old_index"] || raw["old"], new_index: raw["new_index"] || raw["new"] ) end |