Class: SOF::Cycles::Interval
- Inherits:
-
SOF::Cycle
- Object
- SOF::Cycle
- SOF::Cycles::Interval
- Defined in:
- lib/sof/cycles/interval.rb
Constant Summary
Constants inherited from SOF::Cycle
Instance Attribute Summary
Attributes inherited from SOF::Cycle
Class Method Summary collapse
Instance Method Summary collapse
-
#expiration_of(_ = nil, anchor: nil) ⇒ Date?
Returns the expiration date for the current window.
-
#final_date(_ = nil) ⇒ Date
Calculates the final date of the current window.
-
#last_completed(_ = nil) ⇒ Object
Returns the from_date as the last completed date.
-
#satisfied_by?(_ = nil, anchor: Date.current) ⇒ Boolean
Is the supplied anchor date within the current window?.
- #start_date(_ = nil) ⇒ Object
- #to_s ⇒ Object
Methods inherited from SOF::Cycle
#==, #as_json, class_for_kind, class_for_notation_id, #considered_dates, #cover?, #covered_dates, cycle_handlers, dump, #extend_period, for, #from_data, handles?, #humanized_span, inherited, #initialize, #kind_inquiry, legend, load, notation, #notation, #range, #to_h, validate_period, #validate_period, volume_only?, #volume_to_delay_expiration
Constructor Details
This class inherits a constructor from SOF::Cycle
Class Method Details
.description ⇒ Object
23 24 25 |
# File 'lib/sof/cycles/interval.rb', line 23 def self.description "Interval - occurrences within a repeating window that re-anchors from completion date" end |
.dormant_capable? ⇒ Boolean
21 |
# File 'lib/sof/cycles/interval.rb', line 21 def self.dormant_capable? = true |
.examples ⇒ Object
27 28 29 |
# File 'lib/sof/cycles/interval.rb', line 27 def self.examples ["V1I24MF2026-03-31 - once every 24 months from March 31, 2026 (re-anchors after completion)"] end |
.recurring? ⇒ Boolean
19 |
# File 'lib/sof/cycles/interval.rb', line 19 def self.recurring? = true |
Instance Method Details
#expiration_of(_ = nil, anchor: nil) ⇒ Date?
Returns the expiration date for the current window
40 41 42 |
# File 'lib/sof/cycles/interval.rb', line 40 def expiration_of(_ = nil, anchor: nil) final_date end |
#final_date(_ = nil) ⇒ Date
Calculates the final date of the current window
61 62 63 64 |
# File 'lib/sof/cycles/interval.rb', line 61 def final_date(_ = nil) return nil if start_date.nil? time_span.end_date(start_date) end |
#last_completed(_ = nil) ⇒ Object
Returns the from_date as the last completed date
52 |
# File 'lib/sof/cycles/interval.rb', line 52 def last_completed(_ = nil) = from_date&.to_date |
#satisfied_by?(_ = nil, anchor: Date.current) ⇒ Boolean
Is the supplied anchor date within the current window?
47 48 49 |
# File 'lib/sof/cycles/interval.rb', line 47 def satisfied_by?(_ = nil, anchor: Date.current) anchor <= final_date end |
#start_date(_ = nil) ⇒ Object
66 |
# File 'lib/sof/cycles/interval.rb', line 66 def start_date(_ = nil) = from_date&.to_date |
#to_s ⇒ Object
31 32 33 34 35 |
# File 'lib/sof/cycles/interval.rb', line 31 def to_s return dormant_to_s unless active? "#{volume}x every #{humanized_span} from #{start_date.to_fs(:american)}" end |