class VirtualTime
- VirtualTime
- Reference
- Object
Included Modules
- Comparable(Time)
- YAML::Serializable
Defined in:
virtualtime.crConstant Summary
-
VERSION =
[VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION].join('.')
-
VERSION_MAJOR =
1
-
VERSION_MINOR =
1
-
VERSION_REVISION =
6
Constructors
- .new(year : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, month : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, day : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, week : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, day_of_week : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, day_of_year : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, hour : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, minute : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, second : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, millisecond : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, nanosecond : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, location : Nil | Time::Location)
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(year : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, month : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, day : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, hour : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, minute : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, second : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, *, millisecond : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, nanosecond : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, day_of_week : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, day_of_year : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, week : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil)
- .new(*, year : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, week : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil, day_of_week : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, hour : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, minute : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, second : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, millisecond : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil, nanosecond : Array(Int32) | Bool | Int32 | Int32 -> Bool | Range(Int32, Int32) | Steppable::StepIterator(Int32, Int32, Int32) | Nil = nil)
Class Method Summary
-
.default_match=(default_match : Bool)
Default match result if one of field values matched is
nil
-
.default_match? : Bool
Default match result if one of field values matched is
nil
-
.from_time(time : Time, *, milliseconds = false, nanoseconds = true)
Creates
VirtualTime
fromTime
. -
.matches?(a : Nil, b, max = nil)
Performs matching between VirtualTime and other supported types
-
.matches?(a : Bool, b, max = nil)
Performs matching between VirtualTime and other supported types
-
.matches?(a : Int, b : Int, max = nil)
Performs matching between VirtualTime and other supported types
-
.matches?(a : Enumerable(Int), b : Int, max = nil)
Performs matching between VirtualTime and other supported types
-
.matches?(a : Enumerable(Int), b : Enumerable(Int), max = nil)
Performs matching between VirtualTime and other supported types
-
.matches?(a : Enumerable(Int), b : VirtualProc, max = nil)
Performs matching between VirtualTime and other supported types
-
.matches?(a : VirtualProc, b : Int, max = nil)
Performs matching between VirtualTime and other supported types
-
.matches?(a : VirtualProc, b : VirtualProc, max = nil)
Performs matching between VirtualTime and other supported types
- .matches?(a, b, max = nil)
-
.materialize(value : Nil, default : Int32, max = nil, strict = true)
Materialize a particular value with the help of a hint/default value.
-
.materialize(value : Bool, default : Int32, max = nil, strict = true)
Materialize a particular value with the help of a hint/default value.
-
.materialize(value : Int, default : Int32, max = nil, strict = true)
Materialize a particular value with the help of a hint/default value.
-
.materialize(value : Range(Int, Int), default : Int32, max = nil, strict = true)
Materialize a particular value with the help of a hint/default value.
-
.materialize(value : Enumerable(Int), default : Int32, max = nil, strict = true)
Materialize a particular value with the help of a hint/default value.
-
.materialize(value : Proc(Virtual, Bool), default : Int32, max = nil, strict = true)
Materialize a particular value with the help of a hint/default value.
Instance Method Summary
-
#<=>(other : Time)
Compares
VirtualTime
toTime
instance -
#==(time : TimeOrVirtualTime = Time.local)
Returns whether
VirtualTime
matches the specified time -
#==(other : self)
Returns
true
if this reference is the same as other. -
#adjust_day(day : Int, acceptable_day : Int, wrap_day : Int)
"Rewinds"
#day
forward enough to reachacceptable_day
. - #day : Virtual
- #day=(day : Virtual)
- #day_of_week : Virtual
- #day_of_week=(day_of_week : Virtual)
- #day_of_year : Virtual
- #day_of_year=(day_of_year : Virtual)
-
#expand
Expands VirtualTime containing ranges or lists into a list of individual VirtualTimes with specific values E.g.
- #hour : Virtual
- #hour=(hour : Virtual)
- #location : Time::Location | Nil
- #location=(location : Time::Location | Nil)
-
#matches?(time : TimeOrVirtualTime = Time.local)
Returns whether
VirtualTime
matches the specified time -
#matches_date?(time : TimeOrVirtualTime = Time.local)
Returns whether
VirtualTime
matches the date part of specified time -
#matches_time?(time : TimeOrVirtualTime = Time.local)
Returns whether
VirtualTime
matches the time part of specified time -
#materialize(hint = Time.local, strict = true)
Returns a new, "materialized" VirtualTime.
- #millisecond : Virtual
- #millisecond=(millisecond : Virtual)
- #minute : Virtual
- #minute=(minute : Virtual)
- #month : Virtual
- #month=(month : Virtual)
- #nanosecond : Virtual
- #nanosecond=(nanosecond : Virtual)
- #nil_date!
- #nil_time!
- #second : Virtual
- #second=(second : Virtual)
-
#to_time(hint = Time.local, strict = true)
Converts a VirtualTime to a specific Time object that hopefully matches the VirtualTime.
-
#to_tuple
Outputs VirtualTime instance as a tuple with signature
Tuple(11x Virtual, Time::Location?)
- #week : Virtual
- #week=(week : Virtual)
- #year : Virtual
- #year=(year : Virtual)
Constructor Detail
Class Method Detail
Default match result if one of field values matched is nil
Creates VirtualTime
from Time
.
This can be useful to produce a VT with many fields filled in quickly, and then set fields of choice to more interesting values rather than fixed integers.
Note that this copies all values from Time
to VirtualTime
, including week number, day of week, day of year.
That results in a very fixed VirtualTime
which is probably not useful unless some values are afterwards reset to nil or set to other VT-specific options.
Millisecond and nanosecond values are copied from Time
into VirtualTime
only if options milliseconds=
and nanoseconds=
are set to true.
Default is currently true for nanoseconds.
Whether these options are useful, or whether they should be removed, or whether all fields should get a corresponding option like this, remains be seen.
Performs matching between VirtualTime and other supported types
Performs matching between VirtualTime and other supported types
Performs matching between VirtualTime and other supported types
Performs matching between VirtualTime and other supported types
Performs matching between VirtualTime and other supported types
Performs matching between VirtualTime and other supported types
Performs matching between VirtualTime and other supported types
Performs matching between VirtualTime and other supported types
Materialize a particular value with the help of a hint/default value. If 'strict' is true and default value does not satisfy predefined range or requirements, the default is replaced with the first/earliest value from allowed range.
Materialize a particular value with the help of a hint/default value. If 'strict' is true and default value does not satisfy predefined range or requirements, the default is replaced with the first/earliest value from allowed range.
Materialize a particular value with the help of a hint/default value. If 'strict' is true and default value does not satisfy predefined range or requirements, the default is replaced with the first/earliest value from allowed range.
Materialize a particular value with the help of a hint/default value. If 'strict' is true and default value does not satisfy predefined range or requirements, the default is replaced with the first/earliest value from allowed range.
Materialize a particular value with the help of a hint/default value. If 'strict' is true and default value does not satisfy predefined range or requirements, the default is replaced with the first/earliest value from allowed range.
Materialize a particular value with the help of a hint/default value. If 'strict' is true and default value does not satisfy predefined range or requirements, the default is replaced with the first/earliest value from allowed range.
Instance Method Detail
Returns whether VirtualTime
matches the specified time
Alias for #matches?
.
Returns true
if this reference is the same as other. Invokes same?
.
"Rewinds" #day
forward enough to reach acceptable_day
.
It wraps around wrap_day
, so e.g. #adjust_day(25, 5, 30)
returns 10.days
Expands VirtualTime containing ranges or lists into a list of individual VirtualTimes with specific values
E.g. VirtualTime with day=1..2
gets expanded into two separate VirtualTimes, day=1 and day=2
Returns whether VirtualTime
matches the specified time
Returns whether VirtualTime
matches the date part of specified time
Returns whether VirtualTime
matches the time part of specified time
Returns a new, "materialized" VirtualTime. I.e., it converts VirtualTime object to a Time-like value, where all fields have "materialized"/specific values
Converts a VirtualTime to a specific Time object that hopefully matches the VirtualTime.
Value is converted using a time hint, which defaults to the current time. Lists and ranges of values materialize to their min / begin value.
Additionally, any requirements for week number, day of week, and day of year are also met, possibly by doing multiple iterations to find a suitable date. The process is limited to 10 attempts of trying to find a value that simultaneously satisfies all constraints.