Class: Calrom::DateRange
- Inherits:
-
Range
- Object
- Range
- Calrom::DateRange
show all
- Defined in:
- lib/calrom/date_range.rb
Instance Method Summary
collapse
Instance Method Details
#each_month ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/calrom/date_range.rb', line 3
def each_month
return to_enum(:each_month) unless block_given?
if first.year == last.year && first.month == last.month
yield self
return
end
(Month.new(first.year, first.month) .. Month.new(last.year, last.month))
.each_with_index do |m,i|
if i == 0 && first.day > 1
yield self.class.new(first, m.last)
elsif m.first.year == last.year && m.first.month == last.month && last != m.last
yield self.class.new(m.first, last)
else
yield m
end
end
end
|
#spans_multiple_months? ⇒ Boolean
26
27
28
29
|
# File 'lib/calrom/date_range.rb', line 26
def spans_multiple_months?
first.month != last.month ||
first.year != last.year
end
|