Class: Ruflet::Event
- Inherits:
-
Object
- Object
- Ruflet::Event
- Defined in:
- lib/ruflet_ui/ruflet/event.rb
Instance Attribute Summary collapse
-
#control ⇒ Object
readonly
Returns the value of attribute control.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#typed_data ⇒ Object
readonly
Returns the value of attribute typed_data.
Instance Method Summary collapse
-
#initialize(name:, target:, raw_data:, page:, control:) ⇒ Event
constructor
A new instance of Event.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
-
#value ⇒ Object
A stable convenience accessor shared by built-in and extension events.
Constructor Details
#initialize(name:, target:, raw_data:, page:, control:) ⇒ Event
Returns a new instance of Event.
10 11 12 13 14 15 16 17 18 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 10 def initialize(name:, target:, raw_data:, page:, control:) @name = name @target = target @raw_data = raw_data @data = parse_data(raw_data) @typed_data = Events::GestureEventFactory.build(name, @data) @page = page @control = control end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
41 42 43 44 45 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 41 def method_missing(name, *args, &block) return typed_data.public_send(name, *args, &block) if typed_data && typed_data.respond_to?(name) super end |
Instance Attribute Details
#control ⇒ Object (readonly)
Returns the value of attribute control.
8 9 10 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 8 def control @control end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 8 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 8 def name @name end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
8 9 10 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 8 def page @page end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
8 9 10 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 8 def raw_data @raw_data end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
8 9 10 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 8 def target @target end |
#typed_data ⇒ Object (readonly)
Returns the value of attribute typed_data.
8 9 10 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 8 def typed_data @typed_data end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
47 48 49 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 47 def respond_to_missing?(name, include_private = false) (typed_data && typed_data.respond_to?(name, include_private)) || super end |
#value ⇒ Object
A stable convenience accessor shared by built-in and extension events. Extension event names are intentionally not part of the core typed-event registry, so fall back to the same value extraction used by GenericEvent.
23 24 25 26 27 |
# File 'lib/ruflet_ui/ruflet/event.rb', line 23 def value return typed_data.value if typed_data&.respond_to?(:value) Events::GenericEvent.from_data(data).value end |