Class: Moon::Input::Observer

Inherits:
Object
  • Object
show all
Includes:
Eventable
Defined in:
lib/moon/packages/std/input/observer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Eventable

#allow_event?, #clear_events, #each_listener, #each_typed_listener, filter_from_options, #has_events?, #initialize_eventable, #off, #on, #ppd_ev, #typing

Constructor Details

#initializeObserver

Returns a new instance of Observer.


8
9
10
# File 'lib/moon/packages/std/input/observer.rb', line 8

def initialize
  initialize_eventable
end

Instance Attribute Details

#on_exceptionObject

Returns the value of attribute on_exception


4
5
6
# File 'lib/moon/packages/std/input/observer.rb', line 4

def on_exception
  @on_exception
end

Instance Method Details

#clearObject


12
13
14
# File 'lib/moon/packages/std/input/observer.rb', line 12

def clear
  clear_events
end

#trigger(event) ⇒ Object


24
25
26
27
28
29
30
31
32
33
# File 'lib/moon/packages/std/input/observer.rb', line 24

def trigger(event)
  super# Input events may be triggered, outside of a State#step, since
# input events are not polled, this can sometimes bypass State
# breakpads and end up bubbling back to the engine level.
# Use an on_exception callback to hook the error and handle
# it elsewhere instead of bubbling back up.

rescue => exc
  handle_exception(exc, exc.backtrace.dup)
end