Class: R4r::FrozenClock

Inherits:
Clock
  • Object
show all
Defined in:
lib/r4r/clock.rb

Overview

A frozen clock for testing

Instance Method Summary collapse

Constructor Details

#initialize(parent: nil) ⇒ FrozenClock

Creates a new instance of frozen clock.

Parameters:

  • parent (R4r::Clock) (defaults to: nil)

    an initial time 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.

Parameters:

  • seconds (Fixnum)

    a number of seconds to increase time



29
30
31
# File 'lib/r4r/clock.rb', line 29

def advance(seconds:)
  @time += (seconds.to_i * 1_000)
end

#callObject

See Also:



22
23
24
# File 'lib/r4r/clock.rb', line 22

def call
  @time
end