Class: Lita::Timer
- Inherits:
-
Object
- Object
- Lita::Timer
- Defined in:
- lib/lita/timer.rb
Overview
A timer that executes a block after a certain number of seconds, either once or repeatedly.
Instance Method Summary collapse
-
#initialize(interval: 0, recurring: false) {|timer| ... } ⇒ Timer
constructor
A new instance of Timer.
-
#start ⇒ Object
Starts running the timer.
-
#stop ⇒ Object
Stops the timer, preventing any further invocations of the block until started again.
Constructor Details
#initialize(interval: 0, recurring: false) {|timer| ... } ⇒ Timer
Returns a new instance of Timer.
8 9 10 11 12 13 |
# File 'lib/lita/timer.rb', line 8 def initialize(interval: 0, recurring: false, &block) @interval = interval @recurring = recurring @running = false @block = block end |
Instance Method Details
#start ⇒ Object
Starts running the timer.
16 17 18 19 |
# File 'lib/lita/timer.rb', line 16 def start @running = true run end |
#stop ⇒ Object
Stops the timer, preventing any further invocations of the block until started again.
22 23 24 |
# File 'lib/lita/timer.rb', line 22 def stop @running = false end |