Class: MudratProjector::DateDiff::QuarterCalculator
Instance Attribute Summary
#first_unit
Attributes inherited from Calculator
#from, #to
Class Method Summary
collapse
Instance Method Summary
collapse
#calculate, #initialize
Methods inherited from Calculator
#calculate, #to_big_decimal
Class Method Details
.advance(intervals, from: from) ⇒ Object
154
155
156
|
# File 'lib/mudrat_projector/date_diff.rb', line 154
def self.advance intervals, from: from
(intervals * 3).times.inject from do |date, _| date.next_month; end
end
|
Instance Method Details
#advance_one_unit(date) ⇒ Object
146
147
148
|
# File 'lib/mudrat_projector/date_diff.rb', line 146
def advance_one_unit date
date.next_month.next_month.next_month
end
|
#fetch_unit(date) ⇒ Object
136
137
138
139
140
141
142
143
144
|
# File 'lib/mudrat_projector/date_diff.rb', line 136
def fetch_unit date
[1, 4, 7, 10].each do |quarter|
if (quarter..quarter + 2).include? date.month
start_of_quarter = Date.new(date.year, quarter)
return (start_of_quarter..(start_of_quarter.next_month.next_month.next_month - 1))
end
end
fail "Date month was #{date.month}"
end
|
#rewind_one_unit(date) ⇒ Object
150
151
152
|
# File 'lib/mudrat_projector/date_diff.rb', line 150
def rewind_one_unit date
date.prev_month.prev_month.prev_month
end
|