Class: Cal::Month
Instance Attribute Summary collapse
-
#number ⇒ Object
(also: #to_i)
readonly
Returns the value of attribute number.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(year, number) ⇒ Month
constructor
A new instance of Month.
- #previous ⇒ Object
- #succ ⇒ Object
- #to_month ⇒ Object
- #to_s(*args) ⇒ Object
Constructor Details
#initialize(year, number) ⇒ Month
Returns a new instance of Month.
6 7 8 9 |
# File 'lib/cal/month.rb', line 6 def initialize(year, number) @year = year.to_i @number = number.to_i end |
Instance Attribute Details
#number ⇒ Object (readonly) Also known as: to_i
Returns the value of attribute number.
11 12 13 |
# File 'lib/cal/month.rb', line 11 def number @number end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
11 12 13 |
# File 'lib/cal/month.rb', line 11 def year @year end |
Instance Method Details
#<=>(other) ⇒ Object
15 16 17 |
# File 'lib/cal/month.rb', line 15 def <=>(other) date <=> other.send(:date) if other.is_a?(self.class) end |
#previous ⇒ Object
27 28 29 |
# File 'lib/cal/month.rb', line 27 def previous self.class.new *(number == 1 ? [(year - 1), 12] : [year, (number - 1)]) end |
#succ ⇒ Object
23 24 25 |
# File 'lib/cal/month.rb', line 23 def succ self.class.new *(number == 12 ? [(year + 1), 1] : [year, (number + 1)]) end |
#to_month ⇒ Object
31 32 33 |
# File 'lib/cal/month.rb', line 31 def to_month self end |
#to_s(*args) ⇒ Object
19 20 21 |
# File 'lib/cal/month.rb', line 19 def to_s(*args) date.strftime *args end |