Class: Ruflet::Events::DragStartEvent

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

Constructor Details

#initialize(kind:, local_position:, global_position:, timestamp:) ⇒ DragStartEvent

Returns a new instance of DragStartEvent.



218
219
220
221
222
223
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 218

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

Instance Attribute Details

#global_positionObject (readonly)

Returns the value of attribute global_position.



216
217
218
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 216

def global_position
  @global_position
end

#kindObject (readonly)

Returns the value of attribute kind.



216
217
218
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 216

def kind
  @kind
end

#local_positionObject (readonly)

Returns the value of attribute local_position.



216
217
218
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 216

def local_position
  @local_position
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



216
217
218
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 216

def timestamp
  @timestamp
end

Class Method Details

.from_data(data) ⇒ Object



225
226
227
228
229
230
231
232
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 225

def self.from_data(data)
  new(
    kind: pick(data, "k", "kind"),
    local_position: offset(data, "l", "local_position"),
    global_position: offset(data, "g", "global_position"),
    timestamp: duration(data, "ts", "timestamp")
  )
end