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.
24 25 26 |
# File 'lib/dill/checkpoint.rb', line 24 def initialize(duration) @duration = duration end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
28 29 30 |
# File 'lib/dill/checkpoint.rb', line 28 def duration @duration end |
Instance Method Details
#elapsed ⇒ Object
34 35 36 |
# File 'lib/dill/checkpoint.rb', line 34 def elapsed now - start_time end |
#expired? ⇒ Boolean
30 31 32 |
# File 'lib/dill/checkpoint.rb', line 30 def expired? duration < elapsed end |
#start ⇒ Object
38 39 40 |
# File 'lib/dill/checkpoint.rb', line 38 def start @start_time = now end |
#tick ⇒ Object
42 43 44 45 46 |
# File 'lib/dill/checkpoint.rb', line 42 def tick sleep tick_duration raise Frozen, 'time appears to be frozen' if frozen? end |