Class: Zyps::Clock
- Inherits:
-
Object
- Object
- Zyps::Clock
- Defined in:
- lib/zyps.rb
Overview
A clock to use for timing actions.
Instance Method Summary collapse
-
#copy ⇒ Object
Make a deep copy.
-
#elapsed_time ⇒ Object
Returns the time in (fractional) seconds since this method was last called (or on the first call, time since the Clock was created).
-
#initialize ⇒ Clock
constructor
A new instance of Clock.
- #reset_elapsed_time ⇒ Object
Constructor Details
#initialize ⇒ Clock
Returns a new instance of Clock.
474 475 476 |
# File 'lib/zyps.rb', line 474 def initialize reset_elapsed_time end |
Instance Method Details
#copy ⇒ Object
Make a deep copy.
479 |
# File 'lib/zyps.rb', line 479 def copy; self.clone; end |
#elapsed_time ⇒ Object
Returns the time in (fractional) seconds since this method was last called (or on the first call, time since the Clock was created).
482 483 484 485 486 487 |
# File 'lib/zyps.rb', line 482 def elapsed_time time = Time.new.to_f elapsed_time = time - @last_check_time @last_check_time = time elapsed_time end |
#reset_elapsed_time ⇒ Object
489 490 491 |
# File 'lib/zyps.rb', line 489 def reset_elapsed_time @last_check_time = Time.new.to_f end |