Class: Temporal::PlainMonthDay
- Inherits:
-
Object
- Object
- Temporal::PlainMonthDay
- Defined in:
- lib/temporal/plain_month_day.rb
Constant Summary collapse
- IMPLICIT_YEAR =
1972
Instance Attribute Summary collapse
-
#calendar_id ⇒ Object
readonly
Returns the value of attribute calendar_id.
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#month ⇒ Object
readonly
Returns the value of attribute month.
Instance Method Summary collapse
- #era ⇒ Object
-
#initialize(month, day, year: nil, calendar_id: nil) ⇒ PlainMonthDay
constructor
A new instance of PlainMonthDay.
- #month_code ⇒ Object
- #to_s(calendar_name: nil) ⇒ Object
- #year ⇒ Object
Constructor Details
#initialize(month, day, year: nil, calendar_id: nil) ⇒ PlainMonthDay
Returns a new instance of PlainMonthDay.
9 10 11 12 13 14 15 |
# File 'lib/temporal/plain_month_day.rb', line 9 def initialize(month, day, year: nil, calendar_id: nil) @year = (Units::Year.new(year) if year) @month = Units::Month.new(month, @year) @day = Units::Day.new(day, @month) @month.lower = @day self.calendar_id = calendar_id end |
Instance Attribute Details
#calendar_id ⇒ Object
Returns the value of attribute calendar_id.
5 6 7 |
# File 'lib/temporal/plain_month_day.rb', line 5 def calendar_id @calendar_id end |
#day ⇒ Object (readonly)
Returns the value of attribute day.
5 6 7 |
# File 'lib/temporal/plain_month_day.rb', line 5 def day @day end |
#month ⇒ Object (readonly)
Returns the value of attribute month.
5 6 7 |
# File 'lib/temporal/plain_month_day.rb', line 5 def month @month end |
Instance Method Details
#era ⇒ Object
23 |
# File 'lib/temporal/plain_month_day.rb', line 23 def era = nil |
#month_code ⇒ Object
21 |
# File 'lib/temporal/plain_month_day.rb', line 21 def month_code = :"#{format("M%02d", month)}" |
#to_s(calendar_name: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/temporal/plain_month_day.rb', line 25 def to_s(calendar_name: nil) if calendar_name == :always "#{year}-#{@month}-#{@day}[u-ca=#{calendar_id}]" elsif year "#{year}-#{@month}-#{@day}" else "#{@month}-#{@day}" end end |
#year ⇒ Object
17 18 19 |
# File 'lib/temporal/plain_month_day.rb', line 17 def year @year || IMPLICIT_YEAR end |