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.



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

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.



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

def state
  @state
end

Class Method Details

.from_data(data) ⇒ Object



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

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