Class: Timer
Instance Attribute Summary collapse
-
#max ⇒ Object
Returns the value of attribute max.
-
#start ⇒ Object
Returns the value of attribute start.
Attributes inherited from Text
#color, #font, #horizontal, #vertical, #window
Instance Method Summary collapse
-
#initialize(window, max, font) ⇒ Timer
constructor
A new instance of Timer.
- #reset ⇒ Object
- #value ⇒ Object
Methods inherited from Text
Constructor Details
#initialize(window, max, font) ⇒ Timer
Returns a new instance of Timer.
3 4 5 6 7 |
# File 'lib/timer.rb', line 3 def initialize window, max, font super window, max, font, :top, :right self.max = max self.reset end |
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max.
2 3 4 |
# File 'lib/timer.rb', line 2 def max @max end |
#start ⇒ Object
Returns the value of attribute start.
2 3 4 |
# File 'lib/timer.rb', line 2 def start @start end |
Instance Method Details
#reset ⇒ Object
13 14 15 |
# File 'lib/timer.rb', line 13 def reset self.start = Time.now end |
#value ⇒ Object
9 10 11 |
# File 'lib/timer.rb', line 9 def value max - (Time.now - self.start).to_i end |