Class: SOF::Cycles::EndOf
- Inherits:
-
SOF::Cycle
- Object
- SOF::Cycle
- SOF::Cycles::EndOf
- Defined in:
- lib/sof/cycles/end_of.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 cycle.
-
#final_date(_ = nil) ⇒ Date
Calculates the final date of the cycle.
-
#last_completed(_ = nil) ⇒ Object
Always returns the from_date.
-
#satisfied_by?(_ = nil, anchor: Date.current) ⇒ Boolean
Is the supplied anchor date prior to the final date?.
- #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/end_of.rb', line 20 def self.description "End of - occurrences by the end of a time period" end |
.dormant_capable? ⇒ Boolean
18 |
# File 'lib/sof/cycles/end_of.rb', line 18 def self.dormant_capable? = true |
.examples ⇒ Object
24 25 26 |
# File 'lib/sof/cycles/end_of.rb', line 24 def self.examples ["V1E1M - once by the end of next month", "V2E2Q - twice by the end of 2 quarters"] end |
.recurring? ⇒ Boolean
16 |
# File 'lib/sof/cycles/end_of.rb', line 16 def self.recurring? = true |
Instance Method Details
#expiration_of(_ = nil, anchor: nil) ⇒ Date
Returns the expiration date for the cycle
47 48 49 50 |
# File 'lib/sof/cycles/end_of.rb', line 47 def expiration_of(_ = nil, anchor: nil) return nil if parser.dormant? || from_date.nil? final_date end |
#final_date(_ = nil) ⇒ Date
Calculates the final date of the cycle
69 70 71 72 73 74 |
# File 'lib/sof/cycles/end_of.rb', line 69 def final_date(_ = nil) return nil if parser.dormant? || from_date.nil? time_span .end_date(start_date) .end_of_month end |
#last_completed(_ = nil) ⇒ Object
Always returns the from_date
35 |
# File 'lib/sof/cycles/end_of.rb', line 35 def last_completed(_ = nil) = from_date&.to_date |
#satisfied_by?(_ = nil, anchor: Date.current) ⇒ Boolean
Is the supplied anchor date prior to the final date?
55 56 57 58 |
# File 'lib/sof/cycles/end_of.rb', line 55 def satisfied_by?(_ = nil, anchor: Date.current) return false if parser.dormant? || from_date.nil? anchor <= final_date end |
#start_date(_ = nil) ⇒ Object
76 |
# File 'lib/sof/cycles/end_of.rb', line 76 def start_date(_ = nil) = from_date&.to_date |
#to_s ⇒ Object
28 29 30 31 32 |
# File 'lib/sof/cycles/end_of.rb', line 28 def to_s return dormant_to_s if parser.dormant? || from_date.nil? "#{volume}x by #{final_date.to_fs(:american)}" end |