Class: Motion::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/motion/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Event

Returns a new instance of Event.



13
14
15
# File 'lib/motion/event.rb', line 13

def initialize(raw)
  @raw = raw.freeze
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



11
12
13
# File 'lib/motion/event.rb', line 11

def raw
  @raw
end

Class Method Details

.from_raw(raw) ⇒ Object



7
8
9
# File 'lib/motion/event.rb', line 7

def self.from_raw(raw)
  new(raw) if raw
end

Instance Method Details

#detailsObject



23
24
25
# File 'lib/motion/event.rb', line 23

def details
  raw.fetch("details", {})
end

#elementObject



37
38
39
40
41
# File 'lib/motion/event.rb', line 37

def element
  return @element if defined?(@element)

  @element = Motion::Element.from_raw(raw["element"])
end

#extra_dataObject



27
28
29
# File 'lib/motion/event.rb', line 27

def extra_data
  raw["extraData"]
end

#form_dataObject



43
44
45
# File 'lib/motion/event.rb', line 43

def form_data
  element&.form_data
end

#targetObject



31
32
33
34
35
# File 'lib/motion/event.rb', line 31

def target
  return @target if defined?(@target)

  @target = Motion::Element.from_raw(raw["target"])
end

#typeObject Also known as: name



17
18
19
# File 'lib/motion/event.rb', line 17

def type
  raw["type"]
end