Class: Ruflet::Events::StateChangeEvent

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:, value: nil, state: nil) ⇒ StateChangeEvent

Returns a new instance of StateChangeEvent.



164
165
166
167
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 164

def initialize(raw:, value: nil, state: nil)
  super(raw: raw, value: value)
  @state = state
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



162
163
164
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 162

def state
  @state
end

Class Method Details

.from_data(data) ⇒ Object



169
170
171
172
173
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 169

def self.from_data(data)
  raw = data.is_a?(Hash) ? stringify_keys(data) : {}
  state = raw["state"] || raw["value"] || raw["v"] || data
  new(raw: raw, value: state, state: state)
end