Quartz::TimePoint
Inherits Comparable / Reference / Object
The TimePoint data type represents points in simulated time, and is
intended to be used internally.
Its main purpose is to describe event times as offsets from a common
reference point. It may be perturbed by a Duration value.
It is implemented as an arbitrary-precision integer, and provides only relevant methods.
The modeller should only manipulate Duration values.
TODO:
- handle sign.
- one zero representation.
- make immutable
- transform mod operations by bit masking (e.g. (n & (BASE-1)))
Constructors
Creates a new TimePoint value, initialized at the given precision from
the given integer n, which may or not be zero.
Creates a new TimePoint, whose value depends on the given *magnitude,
initialized at the given precision.
The magnitude must be ordered and organized from the least-significant number to the least-signifiant number.
Instance methods
Returns a new TimePoint to which the given Duration is added.
Doesn't truncate result to the duration precision.
Returns a new TimePoint to which the given Duration is subtracted.
Doesn't truncate result to the duration precision.
Measure the difference between self and another instance of self.
The difference is expressed by a Duration value.
If the exact difference between the time points cannot be represented, an
infinite Duration is returned.
See also #gap.
Returns the integer corresponding to the indicated precision, or zero if not in bounds.
Returns the integer at the corresponding index following the little-endian representation (0 is the least significant).
Raises if the given index is not in bounds.
Returns the integer corresponding to the indicated precision, or nil.
Returns the integer at the corresponding index following the little-endian representation (0 is the least significant).
Returns nil if given index is not in bounds.
Multiscale advancement - Adds the given Duration to self.
If the advancement duration is zero, returns self. Advances according to
the duration value otherwise.
If the truncate parameter is set to true, the time point is truncated
at the precision level of the duration (e.g. all digits less significant are
discarded). Otherwise, yields exact results.
See also #+, #-.
Returns the element at the given precision, if in bounds, otherwise executes the given block and returns its value.
Returns the element at the given index, if in bounds, otherwise executes the given block and returns its value.
Converts a planned phase (offset from the current epoch) to a planned
duration relative to self.
Returns the epoch phase, which represents the number of time quanta which
separates self from the beginning of the current epoch.
Measure the difference between self and another instance of self.
The difference is expressed by a Duration value.
If the exact difference between the time points cannot be represented, an approximation is returned.
See also #-.
Converts a planned duration to a planned phase.
The planned phase represents an offset from the current epoch relative to
self.
Refines a planned Duration to match another planned duration precision,
relative to self.
Note: The implementation diverge from the paper algoithm.
Returns the order of magnitude of self, based on its #precision
and the number of stored integers on a base-1000 scale.
Convert self to a Float64. Express values in a base precision, e.g.
Scale::BASE.
Note: this conversion can lose information about the overall magnitude of
self.
Convert this TimePoint to an Int32.
Note: this conversion can lose information about the overall magnitude of
self as well as return a result with the opposite sign.
Convert this TimePoint to an Int64. Express values relative to
its #precision.
Note: this conversion can lose information about the overall magnitude of
self as well as return a result with the opposite sign.