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, dormant_capable?, #dormant_capable?, dump, #extend_period, for, #from_data, handles, handles?, #humanized_span, #initialize, #kind_inquiry, #last_completed, legend, load, notation, #notation, #range, register, registry, #reset_by, #satisfied_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
10
11
12
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 10
def self.description
"Lookback End of Period - occurrences within a prior time period, expiring at the end of the calendar period"
end
|
.examples ⇒ Object
14
15
16
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 14
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
8
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 8
def self.recurring? = true
|
Instance Method Details
#expiration_of(completion_dates, anchor: Date.current) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 20
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
27
28
29
30
31
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 27
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
34
35
36
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 34
def start_date(anchor)
time_span.begin_date_of_period(time_span.begin_date(anchor.to_date))
end
|
#to_s ⇒ Object
18
|
# File 'lib/sof/cycles/lookback_end_of.rb', line 18
def to_s = "#{volume}x in the prior #{period_count} #{humanized_period} (end of period)"
|