Module: Fixtures::Time

Extended by:
Time, T::Sig
Includes:
Fixtures
Included in:
Time
Defined in:
lib/data_model/fixtures/time.rb

Instance Method Summary collapse

Instance Method Details

#earliestObject



44
45
46
# File 'lib/data_model/fixtures/time.rb', line 44

def earliest
  Example.new([:time, { earliest: earliest_time }], variants:)
end

#earliest_timeObject



10
11
12
# File 'lib/data_model/fixtures/time.rb', line 10

def earliest_time
  return ::Time.now - 1
end

#latestObject



49
50
51
# File 'lib/data_model/fixtures/time.rb', line 49

def latest
  Example.new([:time, { latest: latest_time }], variants:)
end

#latest_timeObject



15
16
17
# File 'lib/data_model/fixtures/time.rb', line 15

def latest_time
  return ::Time.now + 1
end

#optionalObject



39
40
41
# File 'lib/data_model/fixtures/time.rb', line 39

def optional
  Example.new([:time, { optional: true }], variants:)
end

#simpleObject



34
35
36
# File 'lib/data_model/fixtures/time.rb', line 34

def simple
  Example.new([:time], variants:)
end

#variantsObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/data_model/fixtures/time.rb', line 20

def variants
  now = ::Time.now

  {
    time: now,
    string: [now.strftime("%H:%M:%S.%6N"), now],
    invalid: "invalid",
    early: earliest_time - 1,
    late: latest_time + 1,
    missing: nil
  }
end