Class: Scheduling::Monthly
- Inherits:
-
Object
- Object
- Scheduling::Monthly
- Defined in:
- lib/scheduling/regularity/monthly.rb
Instance Method Summary collapse
-
#initialize(mday) ⇒ Monthly
constructor
A new instance of Monthly.
- #occurances(date_range) ⇒ Object
Constructor Details
#initialize(mday) ⇒ Monthly
Returns a new instance of Monthly.
5 6 7 8 9 10 |
# File 'lib/scheduling/regularity/monthly.rb', line 5 def initialize mday @mday = mday if mday > 28 @mday = 28 end end |
Instance Method Details
#occurances(date_range) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/scheduling/regularity/monthly.rb', line 12 def occurances date_range raise RangeDecreasingError if date_range.decreasing? cur = Date.new(date_range.min.year, date_range.min.month, @mday) start = date_range.min if cur < start cur = cur.next_month end occurances = [] stop = date_range.last if date_range.exclude_end? stop -= 1 end while cur <= stop occurances.push cur cur = cur.next_month end return occurances end |