Class: Nimo::InputListener::KeyAction
- Defined in:
- lib/nimo/listeners/input_listener.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
Instance Method Summary collapse
-
#initialize(action, options) ⇒ KeyAction
constructor
A new instance of KeyAction.
- #should_execute?(is_button_down) ⇒ Boolean
Constructor Details
#initialize(action, options) ⇒ KeyAction
Returns a new instance of KeyAction.
51 52 53 54 55 |
# File 'lib/nimo/listeners/input_listener.rb', line 51 def initialize(action, ) @action = action @options = {:repeatable => true}.merge() @pressed_since = nil end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
49 50 51 |
# File 'lib/nimo/listeners/input_listener.rb', line 49 def action @action end |
Instance Method Details
#should_execute?(is_button_down) ⇒ Boolean
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/nimo/listeners/input_listener.rb', line 57 def should_execute?() should_execute = false if should_execute = @pressed_since.nil? || @options[:repeatable] @pressed_since = Time.now if @pressed_since.nil? else @pressed_since = nil end return should_execute end |