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, pick, stringify_keys

Constructor Details

#initialize(raw:, value: nil, state: nil) ⇒ StateChangeEvent

Returns a new instance of StateChangeEvent.



65
66
67
68
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 65

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.



63
64
65
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 63

def state
  @state
end

Class Method Details

.from_data(data) ⇒ Object



70
71
72
73
74
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 70

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