Class: Ruflet::Events::ReorderEvent

Inherits:
GenericEvent show all
Defined in:
lib/ruflet_ui/ruflet/events/gesture_events.rb

Instance Attribute Summary collapse

Attributes inherited from GenericEvent

#raw, #value

Class Method Summary collapse

Instance Method Summary collapse

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_indexObject (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_indexObject (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