Class: Ruflet::Events::DismissEvent

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, direction: nil) ⇒ DismissEvent

Returns a new instance of DismissEvent.



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

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

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



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

def direction
  @direction
end

Class Method Details

.from_data(data) ⇒ Object



74
75
76
77
78
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 74

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