Class: SOF::Cycles::LookbackEndOf
Constant Summary
Constants inherited
from SOF::Cycle
SOF::Cycle::VERSION
Instance Attribute Summary
Attributes inherited from SOF::Cycle
#parser
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SOF::Cycle
#==, #as_json, class_for_kind, class_for_notation_id, #considered_dates, #cover?, #covered_dates, cycle_handlers, dormant_capable?, dump, #extend_period, for, #from_data, handles?, #humanized_span, inherited, #initialize, #kind_inquiry, #last_completed, legend, load, notation, #notation, #range, #satisfied_by?, #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
13
14
15
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 13
def self.description
"Lookback End of Period - occurrences within a prior time period, expiring at the end of the calendar period"
end
|
.examples ⇒ Object
17
18
19
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 17
def self.examples
["V1LE24M - once in the prior 24 months (expires end of month)", "V2LE3W - twice in the prior 3 weeks (expires end of week)"]
end
|
.recurring? ⇒ Boolean
11
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 11
def self.recurring? = true
|
Instance Method Details
#expiration_of(completion_dates, anchor: Date.current) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 23
def expiration_of(completion_dates, anchor: Date.current)
oldest = completion_dates.max_by(volume) { it }.min
return unless satisfied_by?(completion_dates, anchor:)
final_date(oldest)
end
|
#final_date(anchor) ⇒ Object
Also known as:
window_end
30
31
32
33
34
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 30
def final_date(anchor)
return if anchor.nil?
time_span.end_date_of_period(time_span.end_date(anchor.to_date))
end
|
#start_date(anchor) ⇒ Object
Also known as:
window_start
37
38
39
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 37
def start_date(anchor)
time_span.begin_date_of_period(time_span.begin_date(anchor.to_date))
end
|
#to_s ⇒ Object
21
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 21
def to_s = "#{volume}x in the prior #{period_count} #{humanized_period} (end of period)"
|