Class: RBGL::GUI::Event
- Inherits:
-
Object
show all
- Defined in:
- lib/rbgl/gui/event.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(type, **data) ⇒ Event
Returns a new instance of Event.
8
9
10
11
|
# File 'lib/rbgl/gui/event.rb', line 8
def initialize(type, **data)
@type = type
@data = data
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
17
18
19
|
# File 'lib/rbgl/gui/event.rb', line 17
def method_missing(name, *args)
@data.key?(name) ? @data[name] : super
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
6
7
8
|
# File 'lib/rbgl/gui/event.rb', line 6
def data
@data
end
|
#type ⇒ Object
Returns the value of attribute type.
6
7
8
|
# File 'lib/rbgl/gui/event.rb', line 6
def type
@type
end
|
Instance Method Details
#[](key) ⇒ Object
13
14
15
|
# File 'lib/rbgl/gui/event.rb', line 13
def [](key)
@data[key]
end
|
#inspect ⇒ Object
29
30
31
|
# File 'lib/rbgl/gui/event.rb', line 29
def inspect
"Event[#{@type}, #{@data.map { |k, v| "#{k}: #{v}" }.join(', ')}]"
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
21
22
23
|
# File 'lib/rbgl/gui/event.rb', line 21
def respond_to_missing?(name, include_private = false)
@data.key?(name) || super
end
|
#to_h ⇒ Object
25
26
27
|
# File 'lib/rbgl/gui/event.rb', line 25
def to_h
{ type: @type }.merge(@data)
end
|