Class: Arcp::FakeClock

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(now: Time.utc(2026, 1, 1)) ⇒ FakeClock

Returns a new instance of FakeClock.



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

def initialize(now: Time.utc(2026, 1, 1))
  @now_value = now.utc
  @monotonic_value = 0.0
end

Instance Attribute Details

#monotonic_valueObject

Returns the value of attribute monotonic_value.



19
20
21
# File 'lib/arcp/clock.rb', line 19

def monotonic_value
  @monotonic_value
end

#now_valueObject

Returns the value of attribute now_value.



19
20
21
# File 'lib/arcp/clock.rb', line 19

def now_value
  @now_value
end

Instance Method Details

#advance(seconds) ⇒ Object



29
30
31
32
33
# File 'lib/arcp/clock.rb', line 29

def advance(seconds)
  @now_value += seconds
  @monotonic_value += seconds
  self
end

#monotonicObject



27
# File 'lib/arcp/clock.rb', line 27

def monotonic = @monotonic_value

#nowObject



26
# File 'lib/arcp/clock.rb', line 26

def now = @now_value