Class: Maze::Timer
- Inherits:
-
Object
- Object
- Maze::Timer
- Defined in:
- lib/maze/timers.rb
Overview
A simple run/stop timer
Instance Attribute Summary collapse
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize ⇒ Timer
constructor
A new instance of Timer.
- #reset ⇒ Object
- #time(&block) ⇒ Object
Constructor Details
#initialize ⇒ Timer
Returns a new instance of Timer.
7 8 9 |
# File 'lib/maze/timers.rb', line 7 def initialize @total = 0 end |
Instance Attribute Details
#total ⇒ Object
Returns the value of attribute total.
5 6 7 |
# File 'lib/maze/timers.rb', line 5 def total @total end |
Instance Method Details
#reset ⇒ Object
19 20 21 |
# File 'lib/maze/timers.rb', line 19 def reset @total = 0 end |
#time(&block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/maze/timers.rb', line 11 def time(&block) start = Time.now block.call ensure @total += Time.now - start end |