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, #dormant_capable?, dump, #extend_period, for, #from_data, handles, handles?, #humanized_span, #initialize, #kind_inquiry, legend, load, notation, #notation, #range, register, registry, #reset_by, #to_h, unregister, 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
20 21 22 |
# File 'lib/sof/cycles/interval.rb', line 20 def self.description "Interval - occurrences within a repeating window that re-anchors from completion date" end |
.dormant_capable? ⇒ Boolean
18 |
# File 'lib/sof/cycles/interval.rb', line 18 def self.dormant_capable? = true |
.examples ⇒ Object
24 25 26 |
# File 'lib/sof/cycles/interval.rb', line 24 def self.examples ["V1I24MF2026-03-31 - once every 24 months from March 31, 2026 (re-anchors after completion)"] end |
.recurring? ⇒ Boolean
16 |
# File 'lib/sof/cycles/interval.rb', line 16 def self.recurring? = true |
Instance Method Details
#expiration_of(_ = nil, anchor: nil) ⇒ Date?
Returns the expiration date for the current window
37 38 39 |
# File 'lib/sof/cycles/interval.rb', line 37 def expiration_of(_ = nil, anchor: nil) final_date end |
#final_date(_ = nil) ⇒ Date
Calculates the final date of the current window
58 59 60 61 |
# File 'lib/sof/cycles/interval.rb', line 58 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
49 |
# File 'lib/sof/cycles/interval.rb', line 49 def last_completed(_ = nil) = from_date&.to_date |
#satisfied_by?(_ = nil, anchor: Date.current) ⇒ Boolean
Is the supplied anchor date within the current window?
44 45 46 |
# File 'lib/sof/cycles/interval.rb', line 44 def satisfied_by?(_ = nil, anchor: Date.current) anchor <= final_date end |
#start_date(_ = nil) ⇒ Object
63 |
# File 'lib/sof/cycles/interval.rb', line 63 def start_date(_ = nil) = from_date&.to_date |
#to_s ⇒ Object
28 29 30 31 32 |
# File 'lib/sof/cycles/interval.rb', line 28 def to_s return dormant_to_s unless active? "#{volume}x every #{humanized_span} from #{start_date.to_fs(:american)}" end |