Class: Ruflet::Events::GenericEvent

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasePayload

duration, offset, pick, stringify_keys

Constructor Details

#initialize(raw:, value: nil) ⇒ GenericEvent

Returns a new instance of GenericEvent.



32
33
34
35
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 32

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

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



30
31
32
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 30

def raw
  @raw
end

#valueObject (readonly)

Returns the value of attribute value.



30
31
32
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 30

def value
  @value
end

Class Method Details

.from_data(data) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 37

def self.from_data(data)
  raw = data.is_a?(Hash) ? stringify_keys(data) : data
  value =
    if raw.is_a?(Hash)
      raw["value"] || raw["v"] || raw["data"] || raw["state"]
    else
      raw
    end

  new(raw: raw, value: value)
end