Class: Ruflet::Events::AutoCompleteSelectEvent

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:, value: nil, selection: nil) ⇒ AutoCompleteSelectEvent

Returns a new instance of AutoCompleteSelectEvent.



88
89
90
91
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 88

def initialize(raw:, value: nil, selection: nil)
  super(raw: raw, value: value)
  @selection = selection
end

Instance Attribute Details

#selectionObject (readonly)

Returns the value of attribute selection.



86
87
88
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 86

def selection
  @selection
end

Class Method Details

.from_data(data) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/ruflet_ui/ruflet/events/gesture_events.rb', line 93

def self.from_data(data)
  raw = data.is_a?(Hash) ? stringify_keys(data) : {}
  selection = raw["selection"]
  selection = stringify_keys(selection) if selection.is_a?(Hash)
  value = raw["value"] || raw["v"] || (selection.is_a?(Hash) ? selection["value"] : nil)
  new(raw: raw, value: value, selection: selection)
end