Class: ZMachine::Timer
- Inherits:
-
Object
- Object
- ZMachine::Timer
- Defined in:
- lib/zmachine/timers.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
Instance Method Summary collapse
- #cancel ⇒ Object
- #fire ⇒ Object
-
#initialize(interval, callback = nil, &block) ⇒ Timer
constructor
A new instance of Timer.
- #schedule ⇒ Object
Constructor Details
#initialize(interval, callback = nil, &block) ⇒ Timer
Returns a new instance of Timer.
6 7 8 9 10 |
# File 'lib/zmachine/timers.rb', line 6 def initialize(interval, callback=nil, &block) @interval = interval @callback = callback || block schedule end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
4 5 6 |
# File 'lib/zmachine/timers.rb', line 4 def interval @interval end |
Instance Method Details
#cancel ⇒ Object
20 21 22 |
# File 'lib/zmachine/timers.rb', line 20 def cancel @timer.cancel end |
#fire ⇒ Object
16 17 18 |
# File 'lib/zmachine/timers.rb', line 16 def fire @callback.call end |