Class: R4r::FrozenClock
Overview
A frozen clock for testing
Instance Method Summary collapse
-
#advance(seconds:) ⇒ Object
Increase clock time by given seconds.
- #call ⇒ Object
-
#initialize(parent: nil) ⇒ FrozenClock
constructor
Creates a new instance of frozen clock.
Constructor Details
#initialize(parent: nil) ⇒ FrozenClock
Creates a new instance of frozen clock.
17 18 19 |
# File 'lib/r4r/clock.rb', line 17 def initialize(parent: nil) @time = (parent || R4r.clock).call end |
Instance Method Details
#advance(seconds:) ⇒ Object
Increase clock time by given seconds.
29 30 31 |
# File 'lib/r4r/clock.rb', line 29 def advance(seconds:) @time += (seconds.to_i * 1_000) end |
#call ⇒ Object
22 23 24 |
# File 'lib/r4r/clock.rb', line 22 def call @time end |