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.



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

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.



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

def direction
  @direction
end

#progressObject (readonly)

Returns the value of attribute progress.



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

def progress
  @progress
end

#reachedObject (readonly)

Returns the value of attribute reached.



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

def reached
  @reached
end

Class Method Details

.from_data(data) ⇒ Object



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

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