Class: Hemi::Event::EventLoop
- Inherits:
-
Object
- Object
- Hemi::Event::EventLoop
- Includes:
- KeyHandler
- Defined in:
- lib/hemi/event/event_loop.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#logic ⇒ Object
readonly
Returns the value of attribute logic.
Instance Method Summary collapse
- #handle(event) ⇒ Object
-
#initialize(logic, events) ⇒ EventLoop
constructor
A new instance of EventLoop.
- #process ⇒ Object
Constructor Details
#initialize(logic, events) ⇒ EventLoop
Returns a new instance of EventLoop.
5 6 7 8 |
# File 'lib/hemi/event/event_loop.rb', line 5 def initialize(logic, events) @logic = logic register_events!(events) end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
10 11 12 |
# File 'lib/hemi/event/event_loop.rb', line 10 def event @event end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
10 11 12 |
# File 'lib/hemi/event/event_loop.rb', line 10 def events @events end |
#logic ⇒ Object (readonly)
Returns the value of attribute logic.
10 11 12 |
# File 'lib/hemi/event/event_loop.rb', line 10 def logic @logic end |
Instance Method Details
#handle(event) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/hemi/event/event_loop.rb', line 12 def handle(event) @event = event case event when SDL2::Event::KeyDown handle_key end end |
#process ⇒ Object
21 22 23 |
# File 'lib/hemi/event/event_loop.rb', line 21 def process logic.call end |