Class: Ruflet::Events::DragTargetEvent

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:, src_id:, accept: nil, x: nil, y: nil) ⇒ DragTargetEvent

Returns a new instance of DragTargetEvent.



142
143
144
145
146
147
148
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 142

def initialize(raw:, src_id:, accept: nil, x: nil, y: nil)
  super(raw: raw, value: src_id)
  @src_id = src_id
  @accept = accept
  @x = x
  @y = y
end

Instance Attribute Details

#acceptObject (readonly)

Returns the value of attribute accept.



140
141
142
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 140

def accept
  @accept
end

#src_idObject (readonly)

Returns the value of attribute src_id.



140
141
142
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 140

def src_id
  @src_id
end

#xObject (readonly)

Returns the value of attribute x.



140
141
142
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 140

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



140
141
142
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 140

def y
  @y
end

Class Method Details

.from_data(data) ⇒ Object



150
151
152
153
154
155
156
157
158
159
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 150

def self.from_data(data)
  raw = data.is_a?(Hash) ? stringify_keys(data) : {}
  new(
    raw: raw,
    src_id: raw["src_id"] || raw["src"] || raw["value"] || raw["v"],
    accept: raw["accept"] || raw["a"],
    x: raw["x"],
    y: raw["y"]
  )
end