Method: FiscalDate::ArithmeticExt#+
- Defined in:
- lib/fiscal_date/arithmetic_ext.rb
#+(quarters) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fiscal_date/arithmetic_ext.rb', line 17 def +(quarters) return self if quarters.zero? years = quarters / 4 quarters = (quarters % 4) + self.quarter # We can use modulo but we'd have to map the quarters 1-4 to 0-3, # this seemed easier. if quarters > 4 years += 1 quarters -= 4 end self.class.new(self.year + years, quarters) end |