Class: Ruflet::Events::DismissibleUpdateEvent

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:, direction:, progress:, reached:) ⇒ DismissibleUpdateEvent

Returns a new instance of DismissibleUpdateEvent.



122
123
124
125
126
127
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 122

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

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



120
121
122
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 120

def direction
  @direction
end

#progressObject (readonly)

Returns the value of attribute progress.



120
121
122
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 120

def progress
  @progress
end

#reachedObject (readonly)

Returns the value of attribute reached.



120
121
122
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 120

def reached
  @reached
end

Class Method Details

.from_data(data) ⇒ Object



129
130
131
132
133
134
135
136
137
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 129

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