Class: Dilation::Timers::Timer Abstract
- Inherits:
-
Object
- Object
- Dilation::Timers::Timer
- Defined in:
- lib/dilation/timers/timer.rb
Overview
Instance Method Summary collapse
-
#initialize(target) ⇒ Timer
constructor
A new instance of Timer.
-
#running? ⇒ Boolean
True if this timer is running.
-
#start ⇒ Object
Start this timer.
-
#stop ⇒ Object
Stop this timer.
-
#tick ⇒ Object
This method should be called by subclasses on each tick.
Constructor Details
#initialize(target) ⇒ Timer
Returns a new instance of Timer.
8 9 10 |
# File 'lib/dilation/timers/timer.rb', line 8 def initialize(target) @target = target end |
Instance Method Details
#running? ⇒ Boolean
Returns true if this timer is running.
18 19 20 |
# File 'lib/dilation/timers/timer.rb', line 18 def running? defined?(@started) && @started end |
#start ⇒ Object
Start this timer
28 29 30 |
# File 'lib/dilation/timers/timer.rb', line 28 def start @started = true end |
#stop ⇒ Object
Stop this timer
23 24 25 |
# File 'lib/dilation/timers/timer.rb', line 23 def stop @started = false end |
#tick ⇒ Object
This method should be called by subclasses on each tick
13 14 15 |
# File 'lib/dilation/timers/timer.rb', line 13 def tick @target.tick end |