Class: Dill::Checkpoint::Timer
- Inherits:
-
Object
- Object
- Dill::Checkpoint::Timer
- Defined in:
- lib/dill/checkpoint.rb
Defined Under Namespace
Classes: Frozen
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
Instance Method Summary collapse
- #elapsed ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(duration) ⇒ Timer
constructor
A new instance of Timer.
- #start ⇒ Object
- #tick ⇒ Object
Constructor Details
#initialize(duration) ⇒ Timer
Returns a new instance of Timer.
13 14 15 |
# File 'lib/dill/checkpoint.rb', line 13 def initialize(duration) @duration = duration end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
17 18 19 |
# File 'lib/dill/checkpoint.rb', line 17 def duration @duration end |
Instance Method Details
#elapsed ⇒ Object
23 24 25 |
# File 'lib/dill/checkpoint.rb', line 23 def elapsed now - start_time end |
#expired? ⇒ Boolean
19 20 21 |
# File 'lib/dill/checkpoint.rb', line 19 def expired? duration < elapsed end |
#start ⇒ Object
27 28 29 |
# File 'lib/dill/checkpoint.rb', line 27 def start @start_time = now end |
#tick ⇒ Object
31 32 33 34 35 |
# File 'lib/dill/checkpoint.rb', line 31 def tick sleep tick_duration raise Frozen, 'time appears to be frozen' if frozen? end |