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 =
2 -
VERSION_REVISION =
1
Constructors
Instance Method Summary
-
#begin : VirtualTime::TimeOrVirtualTime | Nil
Absolute begin date/time.
-
#begin=(begin __arg0 : VirtualTime::TimeOrVirtualTime | Nil)
Absolute begin date/time.
-
#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)
- #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 : 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=(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_date?(time : VirtualTime::TimeOrVirtualTime, times : Array(VirtualTime), default)
- #matches_any_time?(time : VirtualTime::TimeOrVirtualTime, times : Array(VirtualTime), default)
-
#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)
- #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.
Constructor Detail
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.
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.)
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.
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)
Fixed override of #on? for this vdate. If set, takes precedence over begin/end/due/omit.
Same union as #shift.
Fixed override of #on? for this vdate. If set, takes precedence over begin/end/due/omit.
Same union as #shift.
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 if would be on, but can't be scheduled to a slot Returns Time::Span if it's shifted by some amount Returns nil if not applicable / not scheduled
(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.
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.
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.