Class: CalendariumRomanum::AbstractDate
- Inherits:
-
Object
- Object
- CalendariumRomanum::AbstractDate
- Includes:
- Comparable
- Defined in:
- lib/calendarium-romanum/abstract_date.rb
Overview
a date not bound to a particular year
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#month ⇒ Object
readonly
Returns the value of attribute month.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #concretize(year) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(month, day) ⇒ AbstractDate
constructor
A new instance of AbstractDate.
Constructor Details
#initialize(month, day) ⇒ AbstractDate
Returns a new instance of AbstractDate.
7 8 9 10 11 |
# File 'lib/calendarium-romanum/abstract_date.rb', line 7 def initialize(month, day) validate! month, day @month = month @day = day end |
Instance Attribute Details
#day ⇒ Object (readonly)
Returns the value of attribute day.
13 14 15 |
# File 'lib/calendarium-romanum/abstract_date.rb', line 13 def day @day end |
#month ⇒ Object (readonly)
Returns the value of attribute month.
13 14 15 |
# File 'lib/calendarium-romanum/abstract_date.rb', line 13 def month @month end |
Instance Method Details
#<=>(other) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/calendarium-romanum/abstract_date.rb', line 15 def <=>(other) if month != other.month month <=> other.month else day <=> other.day end end |
#concretize(year) ⇒ Object
31 32 33 |
# File 'lib/calendarium-romanum/abstract_date.rb', line 31 def concretize(year) Date.new(year, month, day) end |
#eql?(other) ⇒ Boolean
27 28 29 |
# File 'lib/calendarium-romanum/abstract_date.rb', line 27 def eql?(other) month == other.month && day == other.day end |
#hash ⇒ Object
23 24 25 |
# File 'lib/calendarium-romanum/abstract_date.rb', line 23 def hash (month * 100 + day).hash end |