Class: Month
- Includes:
- Comparable
- Defined in:
- lib/qualitysmith_extensions/month.rb
Instance Attribute Summary collapse
-
#month ⇒ Object
readonly
Returns the value of attribute month.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(year, month) ⇒ Month
constructor
A new instance of Month.
- #inspect ⇒ Object
- #succ ⇒ Object
- #to_date ⇒ Object
Constructor Details
#initialize(year, month) ⇒ Month
Returns a new instance of Month.
18 19 20 21 |
# File 'lib/qualitysmith_extensions/month.rb', line 18 def initialize(year, month) @year = year @month = month end |
Instance Attribute Details
#month ⇒ Object (readonly)
Returns the value of attribute month.
16 17 18 |
# File 'lib/qualitysmith_extensions/month.rb', line 16 def month @month end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
16 17 18 |
# File 'lib/qualitysmith_extensions/month.rb', line 16 def year @year end |
Instance Method Details
#<=>(other) ⇒ Object
31 32 33 34 |
# File 'lib/qualitysmith_extensions/month.rb', line 31 def <=>(other) #puts "#{self.inspect} <=> #{other.inspect}" return self.to_date <=> other.to_date end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/qualitysmith_extensions/month.rb', line 36 def inspect "#{@year}-#{@month}" end |
#succ ⇒ Object
23 24 25 |
# File 'lib/qualitysmith_extensions/month.rb', line 23 def succ (to_date >> 1).to_month end |