Class: Calrom::Month
- Defined in:
- lib/calrom/date_range.rb
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #each_month {|_self| ... } ⇒ Object
-
#initialize(year, month) ⇒ Month
constructor
A new instance of Month.
- #succ ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(year, month) ⇒ Month
Returns a new instance of Month.
45 46 47 48 49 |
# 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 |
Instance Method Details
#<=>(other) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# 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| ... } ⇒ Object
55 56 57 58 59 |
# File 'lib/calrom/date_range.rb', line 55 def each_month return to_enum(:each_month) unless block_given? yield self end |
#succ ⇒ Object
61 62 63 64 |
# File 'lib/calrom/date_range.rb', line 61 def succ n = next_month_beginning self.class.new(n.year, n.month) end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/calrom/date_range.rb', line 51 def to_s first.strftime '%B %Y' end |