class Calrom::Month
Attributes
month[R]
year[R]
Public Class Methods
new(year, month)
click to toggle source
Calls superclass method
# File lib/calrom/date_range.rb, line 45 def initialize(year, month) @year = year @month = month super Date.new(year, month, 1), next_month_beginning - 1 end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/calrom/date_range.rb, line 66 def <=>(other) years_cmp = year <=> other.year if years_cmp != 0 years_cmp else month <=> other.month end end
each_month() { |self| ... }
click to toggle source
# File lib/calrom/date_range.rb, line 55 def each_month return to_enum(:each_month) unless block_given? yield self end
succ()
click to toggle source
# File lib/calrom/date_range.rb, line 61 def succ n = next_month_beginning self.class.new(n.year, n.month) end
to_s()
click to toggle source
# File lib/calrom/date_range.rb, line 51 def to_s first.strftime '%B %Y' end
Private Instance Methods
next_month_beginning()
click to toggle source
# File lib/calrom/date_range.rb, line 82 def next_month_beginning if @month == 12 Date.new(@year + 1, 1, 1) else Date.new(@year, @month + 1, 1) end end