Class: Necropsy::Clock
- Inherits:
-
Object
- Object
- Necropsy::Clock
- Defined in:
- lib/necropsy/clock.rb
Constant Summary collapse
- SOURCE_DATE_EPOCH =
'SOURCE_DATE_EPOCH'
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #date ⇒ Object
-
#initialize(as_of: nil, environment: ENV, now: nil) ⇒ Clock
constructor
A new instance of Clock.
Constructor Details
#initialize(as_of: nil, environment: ENV, now: nil) ⇒ Clock
Returns a new instance of Clock.
11 12 13 14 15 |
# File 'lib/necropsy/clock.rb', line 11 def initialize(as_of: nil, environment: ENV, now: nil) @time = resolve_time(as_of, environment, now).utc.freeze rescue ArgumentError, TypeError, RangeError raise Error, 'as-of time and SOURCE_DATE_EPOCH must identify a valid date' end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
9 10 11 |
# File 'lib/necropsy/clock.rb', line 9 def time @time end |
Instance Method Details
#date ⇒ Object
17 18 19 |
# File 'lib/necropsy/clock.rb', line 17 def date time.to_date end |