Method: Date#month_step
- Defined in:
- lib/quality_extensions/date/month_ranges.rb
#month_step(max, step, &block) ⇒ Object
This is based on the implementation of Time.step. The main difference is that it uses >>= (increment by 1 month) instead of += (increment by 1 day).
18 19 20 21 22 23 24 25 26 |
# File 'lib/quality_extensions/date/month_ranges.rb', line 18 def month_step(max, step, &block) # { |date| ...} time = self op = [:-,:<=,:>=][step<=>0] while time.__send__(op, max) block.call time time >>= step end self end |