Class: Horologium::Scales::Base Abstract
- Inherits:
-
Object
- Object
- Horologium::Scales::Base
- Defined in:
- lib/horologium/scales/base.rb,
sig/horologium/scales/base.rbs
Overview
Implement Base.from_reference and Base.to_reference in a subclass.
The two methods a time scale implements. One reads a TAI Julian Date in the scale, the other reads a Julian Date in the scale back in TAI. Every scale converts to and from TAI, so a scale does not need to know about the other scales.
The values are Julian Dates in days. They come at the precision of the
instant, a Numeric::TwoPartFloat at :standard and a
Numeric::Exact at :exact. A scale keeps that precision, and builds
what it adds at the precision it is given.
Class Method Summary collapse
-
.from_reference(_value, _precision) ⇒ Horologium::Numeric::TwoPartFloat, Horologium::Numeric::Exact
A TAI Julian Date, read in this scale.
-
.provenance(_value) ⇒ Symbol
A continuous scale is
:measuredeverywhere, its conversions resting on constants and models rather than revised data. -
.seconds_in_day(_day_number) ⇒ Integer
The seconds the clock counts in a day of this scale, on the day at
day_number. -
.si_seconds_in_day(day_number) ⇒ Integer, Rational
The SI seconds a day of this scale spans, on the day at
day_number. -
.to_reference(_value, _precision) ⇒ Horologium::Numeric::TwoPartFloat, Horologium::Numeric::Exact
A Julian Date in this scale, read back in TAI.
-
.zone_designator ⇒ String
The ISO 8601 zone designator this scale writes.
Class Method Details
.from_reference(_value, _precision) ⇒ Horologium::Numeric::TwoPartFloat, Horologium::Numeric::Exact
A TAI Julian Date, read in this scale.
50 51 52 |
# File 'lib/horologium/scales/base.rb', line 50 def from_reference(_value, _precision) raise NotImplementedError, "#{self} must implement .from_reference" end |
.provenance(_value) ⇒ Symbol
A continuous scale is :measured everywhere, its conversions
resting on constants and models rather than revised data. UTC is the
exception; see UTC.provenance.
112 113 114 |
# File 'lib/horologium/scales/base.rb', line 112 def provenance(_value) :measured end |
.seconds_in_day(_day_number) ⇒ Integer
The seconds the clock counts in a day of this scale, on the day at
day_number. A day is 86,400 seconds in every scale the library
reads by continuous time. UTC is the exception: a day that holds a
leap second is 86,401 seconds long, so UTC overrides this. A
representation asks the scale this to map a fraction of a day to a
time of day, and to know whether a 61-second final minute is legal.
77 78 79 |
# File 'lib/horologium/scales/base.rb', line 77 def seconds_in_day(_day_number) Duration::SECONDS_PER_DAY end |
.si_seconds_in_day(day_number) ⇒ Integer, Rational
The SI seconds a day of this scale spans, on the day at day_number.
It matches seconds_in_day everywhere the day counts whole seconds:
86,400 in a continuous scale, 86,401 on a UTC leap second day. The
one place they part is UTC's pre-1972 drift, where the clock still
counts 86,400 seconds but each is fractionally longer, so the day
spans a little more SI time. A numeric ISO 8601 offset counts against
this, so it shifts by SI seconds on every day.
91 92 93 |
# File 'lib/horologium/scales/base.rb', line 91 def si_seconds_in_day(day_number) seconds_in_day(day_number) end |
.to_reference(_value, _precision) ⇒ Horologium::Numeric::TwoPartFloat, Horologium::Numeric::Exact
A Julian Date in this scale, read back in TAI. It undoes from_reference. Calling one after the other returns the value given.
64 65 66 |
# File 'lib/horologium/scales/base.rb', line 64 def to_reference(_value, _precision) raise NotImplementedError, "#{self} must implement .to_reference" end |
.zone_designator ⇒ String
The ISO 8601 zone designator this scale writes. Empty for a
continuous scale, where the string carries no scale of its own and a
bare time is a coordinate in the scale it was read in. UTC writes
"Z", where a zero offset is a real thing.
101 102 103 |
# File 'lib/horologium/scales/base.rb', line 101 def zone_designator "" end |