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

Constructor Details

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

Returns a new instance of GenericEvent.



42
43
44
45
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 42

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

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



40
41
42
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 40

def raw
  @raw
end

#valueObject (readonly)

Returns the value of attribute value.



40
41
42
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 40

def value
  @value
end

Class Method Details

.from_data(data) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 47

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"] || raw["route"]
    else
      raw
    end

  new(raw: raw, value: value)
end