Class: TomatoPaste::Timer
- Inherits:
-
Object
- Object
- TomatoPaste::Timer
- Defined in:
- lib/tomato_paste/timer.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#interval_duration ⇒ Object
writeonly
exposed for testing purposes.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #done? ⇒ Boolean
-
#initialize(duration) ⇒ Timer
constructor
A new instance of Timer.
- #start ⇒ Object
Constructor Details
#initialize(duration) ⇒ Timer
Returns a new instance of Timer.
8 9 10 11 12 13 |
# File 'lib/tomato_paste/timer.rb', line 8 def initialize(duration) @duration = duration @current = 0 @state = :idle @interval_duration = 1 end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
5 6 7 |
# File 'lib/tomato_paste/timer.rb', line 5 def current @current end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
5 6 7 |
# File 'lib/tomato_paste/timer.rb', line 5 def duration @duration end |
#interval_duration=(value) ⇒ Object (writeonly)
exposed for testing purposes
6 7 8 |
# File 'lib/tomato_paste/timer.rb', line 6 def interval_duration=(value) @interval_duration = value end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'lib/tomato_paste/timer.rb', line 5 def state @state end |
Instance Method Details
#done? ⇒ Boolean
20 21 22 |
# File 'lib/tomato_paste/timer.rb', line 20 def done? @state == :done end |
#start ⇒ Object
15 16 17 18 |
# File 'lib/tomato_paste/timer.rb', line 15 def start @state = :running time_becomes_a_loop end |