Module: Clock::Controls::Time::Offset::Raw

Defined in:
lib/clock/controls/time/offset.rb

Class Method Summary collapse

Class Method Details

.example(amount = nil, precision: nil, time: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/clock/controls/time/offset.rb', line 12

def self.example(amount=nil, precision: nil, time: nil)
  amount ||= 1
  time ||= Time::Raw.example

  scale = scale(precision: precision)

  offset = amount * scale

  time + offset
end

.scale(precision: nil) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/clock/controls/time/offset.rb', line 23

def self.scale(precision: nil)
  precision ||= Clock::ISO8601::Defaults.precision

  scale = 10 ** precision

  Rational(1, scale)
end