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.
5 6 7 8 |
# File 'lib/cal/month.rb', line 5 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.
10 11 12 |
# File 'lib/cal/month.rb', line 10 def number @number end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
10 11 12 |
# File 'lib/cal/month.rb', line 10 def year @year end |
Instance Method Details
#<=>(other) ⇒ Object
14 15 16 |
# File 'lib/cal/month.rb', line 14 def <=>(other) date <=> other.send(:date) if other.is_a?(self.class) end |
#previous ⇒ Object
26 27 28 |
# File 'lib/cal/month.rb', line 26 def previous self.class.new *(number == 1 ? [(year - 1), 12] : [year, (number - 1)]) end |
#succ ⇒ Object
22 23 24 |
# File 'lib/cal/month.rb', line 22 def succ self.class.new *(number == 12 ? [(year + 1), 1] : [year, (number + 1)]) end |
#to_month ⇒ Object
30 31 32 |
# File 'lib/cal/month.rb', line 30 def to_month self end |
#to_s(*args) ⇒ Object
18 19 20 |
# File 'lib/cal/month.rb', line 18 def to_s(*args) date.strftime *args end |