Class: Motion::Event
- Inherits:
-
Object
- Object
- Motion::Event
- Defined in:
- lib/motion/event.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #details ⇒ Object
- #element ⇒ Object
- #extra_data ⇒ Object
- #form_data ⇒ Object
-
#initialize(raw) ⇒ Event
constructor
A new instance of Event.
- #target ⇒ Object
- #type ⇒ Object (also: #name)
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
#raw ⇒ Object (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
#details ⇒ Object
23 24 25 |
# File 'lib/motion/event.rb', line 23 def details raw.fetch("details", {}) end |
#element ⇒ Object
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_data ⇒ Object
27 28 29 |
# File 'lib/motion/event.rb', line 27 def extra_data raw["extraData"] end |
#form_data ⇒ Object
43 44 45 |
# File 'lib/motion/event.rb', line 43 def form_data element&.form_data end |
#target ⇒ Object
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 |
#type ⇒ Object Also known as: name
17 18 19 |
# File 'lib/motion/event.rb', line 17 def type raw["type"] end |