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
Class Method Details
.advance(intervals, from: from) ⇒ Object
139
140
141
|
# File 'lib/mudrat_projector/date_diff.rb', line 139
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
131
132
133
|
# File 'lib/mudrat_projector/date_diff.rb', line 131
def advance_one_unit date
date.next_month.next_month.next_month
end
|
#fetch_unit(date) ⇒ Object
121
122
123
124
125
126
127
128
129
|
# File 'lib/mudrat_projector/date_diff.rb', line 121
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
135
136
137
|
# File 'lib/mudrat_projector/date_diff.rb', line 135
def rewind_one_unit date
date.prev_month.prev_month.prev_month
end
|