class VirtualDate
- VirtualDate
- Reference
- Object
Overview
VirtualDate builds on VirtualTime to represent due/omit rules plus higher-level scheduling semantics.
Included Modules
- YAML::Serializable
Defined in:
virtualdate.crConstant Summary
-
VERSION =
[VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION].join('.') -
VERSION_MAJOR =
1 -
VERSION_MINOR =
5 -
VERSION_REVISION =
0
Constructors
Class Method Summary
-
.yaml_keys : Array(String)
All mapping keys
.from_yamlreads, derived from the serialized properties at compile time soYamlValidator's allowed-key check cannot drift from the class.
Instance Method Summary
-
#begin : VirtualTime::TimeOrVirtualTime | Nil
Absolute begin date/time.
-
#begin=(begin __arg0 : VirtualTime::TimeOrVirtualTime | Nil)
Absolute begin date/time.
-
#clamp_to_begin=(clamp_to_begin : Bool)
Governs what the Scheduler does with an occurrence that is already running when an absolute (
Time)#beginarrives -- e.g. -
#clamp_to_begin? : Bool
Governs what the Scheduler does with an occurrence that is already running when an absolute (
Time)#beginarrives -- e.g. -
#deadline : VirtualTime::TimeOrVirtualTime | Nil
Hard deadline — vdate MUST finish before this time or fails scheduling
-
#deadline=(deadline : VirtualTime::TimeOrVirtualTime | Nil)
Hard deadline — vdate MUST finish before this time or fails scheduling
-
#depends_on : Array(VirtualDate)
Optional dependencies: scheduler will try to place this vdate after all dependencies.
-
#depends_on=(depends_on : Array(VirtualDate))
Optional dependencies: scheduler will try to place this vdate after all dependencies.
-
#depends_on_ids : Array(String)
Serialized form
-
#depends_on_ids=(depends_on_ids : Array(String))
Serialized form
-
#due : Array(VirtualTime)
List of VirtualTimes on which the vdate is "on"/due/active.
-
#due=(due : Array(VirtualTime))
List of VirtualTimes on which the vdate is "on"/due/active.
-
#due_on?(time : VirtualTime::TimeOrVirtualTime = Time.local, times = @due)
Returns whether any of the vdate's
#duerules is on attime. - #due_on_any_date?(time : VirtualTime::TimeOrVirtualTime = Time.local, times = @due)
- #due_on_any_time?(time : VirtualTime::TimeOrVirtualTime = Time.local, times = @due)
- #duration : Time::Span
- #duration=(duration : Time::Span)
-
#end : VirtualTime::TimeOrVirtualTime | Nil
Absolute end date/time.
-
#end=(end __arg0 : VirtualTime::TimeOrVirtualTime | Nil)
Absolute end date/time.
-
#fixed=(fixed : Bool)
If true, Scheduler treats this vdate as non-movable due to conflicts (still movable by omit-rescheduling rules if you keep shift != false).
-
#fixed? : Bool
If true, Scheduler treats this vdate as non-movable due to conflicts (still movable by omit-rescheduling rules if you keep shift != false).
-
#flags : Set(String)
Flags/categories (e.g.
-
#flags=(flags : Set(String))
Flags/categories (e.g.
-
#id : String
Identifier (important for dependencies)
-
#id=(id : String)
Identifier (important for dependencies)
-
#matches_any?(time : VirtualTime::TimeOrVirtualTime, times : Array(VirtualTime), default)
Returns
defaultiftimesis empty,trueif at least one of them matchestimeoutright, andnilotherwise. -
#matches_any_date?(time : VirtualTime::TimeOrVirtualTime, times : Array(VirtualTime), default)
Returns
defaultiftimesis empty,trueif at least one of them matchestimeoutright, andnilotherwise. -
#matches_any_time?(time : VirtualTime::TimeOrVirtualTime, times : Array(VirtualTime), default)
Returns
defaultiftimesis empty,trueif at least one of them matchestimeoutright, andnilotherwise. -
#max_shift : Time::Span | Nil
Max amount of total time by which vdate can be shifted before it's considered unschedulable (false)
-
#max_shift=(max_shift : Time::Span | Nil)
Max amount of total time by which vdate can be shifted before it's considered unschedulable (false)
-
#max_shifts : Int32
Max amount of shift attempts, before it's considered unschedulable (false)
-
#max_shifts=(max_shifts : Int32)
Max amount of shift attempts, before it's considered unschedulable (false)
-
#omit : Array(VirtualTime)
List of VirtualTimes on which the vdate should be "omitted".
-
#omit=(omit : Array(VirtualTime))
List of VirtualTimes on which the vdate should be "omitted".
-
#omit_on?(time : VirtualTime::TimeOrVirtualTime = Time.local, times = @omit)
Returns whether any of the vdate's
#omitrules coverstime. - #omit_on_dates?(time : VirtualTime::TimeOrVirtualTime = Time.local, times = @omit)
- #omit_on_times?(time : VirtualTime::TimeOrVirtualTime = Time.local, times = @omit)
-
#on : Nil | Bool | Time::Span
Fixed override of
#on?for this vdate. -
#on=(on : Nil | Bool | Time::Span)
Fixed override of
#on?for this vdate. -
#on?(time : Time, *, max_shift = @max_shift, max_shifts = @max_shifts) : Bool
Checks if the vdate is effectively scheduled at
time. -
#parallel : Int32
Max number of overlapping vdates that share at least one common flag with this vdate.
-
#parallel=(parallel : Int32)
Max number of overlapping vdates that share at least one common flag with this vdate.
-
#priority : Int32
Higher wins conflict resolution when Scheduler must choose.
-
#priority=(priority : Int32)
Higher wins conflict resolution when Scheduler must choose.
-
#resolve(time : VirtualTime::TimeOrVirtualTime = Time.local, *, max_shift = @max_shift, max_shifts = @max_shifts, hint = time.is_a?(Time) ? time : Time.local) : Time | Bool | Nil
Resolves the asked VirtualTime to an effective scheduled Time.
- #resolve_dependencies!(index : Hash(String, VirtualDate))
-
#shift : Nil | Bool | Time::Span
Decision about an vdate to make if it falls on an omitted date/time.
-
#shift=(shift : Nil | Bool | Time::Span)
Decision about an vdate to make if it falls on an omitted date/time.
-
#stagger : Time::Span | Nil
Optional staggered parallel scheduling
-
#stagger=(stagger : Time::Span | Nil)
Optional staggered parallel scheduling
-
#strict_on?(time : VirtualTime::TimeOrVirtualTime = Time.local, *, max_shift = @max_shift, max_shifts = @max_shifts, hint = time.is_a?(Time) ? time : Time.local) : Nil | Bool | Time::Span
Checks whether the vdate is "on" on the specified date/time.
- #within_bounds?(time : Time) : Bool
Constructor Detail
Class Method Detail
All mapping keys .from_yaml reads, derived from the serialized
properties at compile time so YamlValidator's allowed-key check cannot
drift from the class. (A method rather than a constant because
instance_vars is only available inside method bodies.)
Instance Method Detail
Absolute begin date/time. Item is never "on" before this date.
Absolute begin date/time. Item is never "on" before this date.
Governs what the Scheduler does with an occurrence that is already running
when an absolute (Time) #begin arrives -- e.g. due: hour 8..12 with
begin: 10:30. By default the occurrence is dropped: it began before the
vdate existed. With this set, it is clamped to start at #begin instead,
the same way an occurrence already running at the window's from is
clamped to from. Has no effect on a VirtualTime-pattern #begin,
which is matched as a pattern rather than used as a boundary.
Governs what the Scheduler does with an occurrence that is already running
when an absolute (Time) #begin arrives -- e.g. due: hour 8..12 with
begin: 10:30. By default the occurrence is dropped: it began before the
vdate existed. With this set, it is clamped to start at #begin instead,
the same way an occurrence already running at the window's from is
clamped to from. Has no effect on a VirtualTime-pattern #begin,
which is matched as a pattern rather than used as a boundary.
Hard deadline — vdate MUST finish before this time or fails scheduling
Hard deadline — vdate MUST finish before this time or fails scheduling
Optional dependencies: scheduler will try to place this vdate after all dependencies. (Used only by Scheduler; VirtualDate itself does not enforce this.)
Optional dependencies: scheduler will try to place this vdate after all dependencies. (Used only by Scheduler; VirtualDate itself does not enforce this.)
Serialized form
Written out by #on_to_yaml, not by the generated serializer; see the note there.
Serialized form
Written out by #on_to_yaml, not by the generated serializer; see the note there.
Returns whether any of the vdate's #due rules is on at time.
An empty list means the vdate is always due.
Absolute end date/time. Item is never "on" after this date.
Absolute end date/time. Item is never "on" after this date.
If true, Scheduler treats this vdate as non-movable due to conflicts (still movable by omit-rescheduling rules if you keep shift != false).
If true, Scheduler treats this vdate as non-movable due to conflicts (still movable by omit-rescheduling rules if you keep shift != false).
Flags/categories (e.g. meeting, task, or passive/active/unimportant, or color-coded, or anything). Used by Scheduler for parallelism.
Flags/categories (e.g. meeting, task, or passive/active/unimportant, or color-coded, or anything). Used by Scheduler for parallelism.
Returns default if times is empty, true if at least one of them
matches time outright, and nil otherwise.
A rule has to match on both its date and its time part. Taking the date
from one rule and the time from another would report a match that none of
the rules on its own expresses -- and would, for instance, make an #omit
of "December 25" together with "12:00" omit every instant of the year,
since the first rule constrains no time and the second no date.
Returns default if times is empty, true if at least one of them
matches time outright, and nil otherwise.
A rule has to match on both its date and its time part. Taking the date
from one rule and the time from another would report a match that none of
the rules on its own expresses -- and would, for instance, make an #omit
of "December 25" together with "12:00" omit every instant of the year,
since the first rule constrains no time and the second no date.
Considers only the date part of each rule.
Returns default if times is empty, true if at least one of them
matches time outright, and nil otherwise.
A rule has to match on both its date and its time part. Taking the date
from one rule and the time from another would report a match that none of
the rules on its own expresses -- and would, for instance, make an #omit
of "December 25" together with "12:00" omit every instant of the year,
since the first rule constrains no time and the second no date.
Considers only the time part of each rule.
Max amount of total time by which vdate can be shifted before it's considered unschedulable (false)
Max amount of total time by which vdate can be shifted before it's considered unschedulable (false)
Max amount of shift attempts, before it's considered unschedulable (false)
Returns whether any of the vdate's #omit rules covers time.
An empty list means the vdate is never omitted.
Fixed override of #on? for this vdate. If set, takes precedence over begin/end/due/omit.
Same union as #shift.
Written out by #on_to_yaml, not by the generated serializer; see the note there.
Fixed override of #on? for this vdate. If set, takes precedence over begin/end/due/omit.
Same union as #shift.
Written out by #on_to_yaml, not by the generated serializer; see the note there.
Checks if the vdate is effectively scheduled at time.
Returns:
- true if it is on at
timedirectly, OR due at some base time that resolves (via shifting) to exactlytime - false otherwise (not applicable, not scheduled, or unschedulable)
Unlike #strict_on?, this method never returns nil or Time::Span.
(For omit-driven shifting (Time::Span), we can search candidate base times by shifting back in the opposide direction. This is deterministic, bounded by max_shifts/max_shift.)
Max number of overlapping vdates that share at least one common flag with this vdate. Example: flags={meeting}, parallel=2 means up to 2 meetings can overlap.
Max number of overlapping vdates that share at least one common flag with this vdate. Example: flags={meeting}, parallel=2 means up to 2 meetings can overlap.
Resolves the asked VirtualTime to an effective scheduled Time.
Returns:
- Time : resolved scheduled time
- true : scheduled "as asked" (same as returning
time, but preserved for symmetry) - nil : not scheduled
- false : due but unschedulable
Notes:
- For
Timeinput, returnedTimepreserves the timezone/location of the input time. - For
VirtualTimeinput, useshintfor materialization as in legacy#on?.
Decision about an vdate to make if it falls on an omitted date/time.
Allowed values are:
- nil: treat the vdate as non-applicable/not-scheduled on the specified date/time
- false: treat the vdate as not due due to falling on an omitted date/time, after a reschedule was not attempted or was not able to find another spot
- true: treat the vdate as due regardless of falling on an omitted date/time
- Time::Span: shift the scheduled date/time by specified time span. Can be negative or positive.
Written out by #on_to_yaml, not by the generated serializer; see the note there.
Decision about an vdate to make if it falls on an omitted date/time.
Allowed values are:
- nil: treat the vdate as non-applicable/not-scheduled on the specified date/time
- false: treat the vdate as not due due to falling on an omitted date/time, after a reschedule was not attempted or was not able to find another spot
- true: treat the vdate as due regardless of falling on an omitted date/time
- Time::Span: shift the scheduled date/time by specified time span. Can be negative or positive.
Written out by #on_to_yaml, not by the generated serializer; see the note there.
Checks whether the vdate is "on" on the specified date/time.
Return values: nil - vdate is not "on" / not due / not scheduled true - vdate is "on" (due and not omitted) false - vdate is due but omitted and no reschedule requested or possible Time::Span - the span to add to asked date to reach earliest/closest time when vdate is "on"
IMPORTANT: If the vdate is rescheduled away from the asked time,
#strict_on? returns a Time::Span, but querying #strict_on? at the rescheduled time will not
necessarily return true. Use #resolve or #on? to return a true falue for shifted dates/times.
ameba:disable Metrics/CyclomaticComplexity
Returns whether time falls within #begin and #end.
A bound that is a VirtualTime is matched as a pattern rather than used as
an ordering bound, the way #strict_on? treats it.