Class: Ruflet::Events::TapEvent

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(kind:, local_position:, global_position:) ⇒ TapEvent

Returns a new instance of TapEvent.



179
180
181
182
183
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 179

def initialize(kind:, local_position:, global_position:)
  @kind = kind
  @local_position = local_position
  @global_position = global_position
end

Instance Attribute Details

#global_positionObject (readonly)

Returns the value of attribute global_position.



177
178
179
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 177

def global_position
  @global_position
end

#kindObject (readonly)

Returns the value of attribute kind.



177
178
179
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 177

def kind
  @kind
end

#local_positionObject (readonly)

Returns the value of attribute local_position.



177
178
179
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 177

def local_position
  @local_position
end

Class Method Details

.from_data(data) ⇒ Object



185
186
187
188
189
190
191
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 185

def self.from_data(data)
  new(
    kind: pick(data, "k", "kind"),
    local_position: offset(data, "l", "local_position") || offset_pair(data, "lx", "ly"),
    global_position: offset(data, "g", "global_position") || offset_pair(data, "gx", "gy")
  )
end