Class: LunarCalendar::LunarYear
- Inherits:
-
Object
- Object
- LunarCalendar::LunarYear
- Defined in:
- lib/lunar_calendar/lunar_year.rb
Overview
The leap and months of specify year
Instance Method Summary collapse
-
#binary ⇒ Number
The packed leap data.
-
#initialize(offset) ⇒ LunarYear
constructor
A new instance of LunarYear.
-
#leap_month ⇒ Number
The leap month.
-
#month_days ⇒ Array<Number>
Month days.
Constructor Details
#initialize(offset) ⇒ LunarYear
Returns a new instance of LunarYear.
11 12 13 |
# File 'lib/lunar_calendar/lunar_year.rb', line 11 def initialize(offset) @offset = offset end |
Instance Method Details
#binary ⇒ Number
Returns the packed leap data.
16 17 18 |
# File 'lib/lunar_calendar/lunar_year.rb', line 16 def binary @binary ||= LunarCalendar::Data::LEAP_MONTHS[@offset] end |
#leap_month ⇒ Number
Returns the leap month.
28 29 30 |
# File 'lib/lunar_calendar/lunar_year.rb', line 28 def leap_month @leap_month ||= LunarCalendar::Utils.decode(binary, 4, 13) end |
#month_days ⇒ Array<Number>
Returns month days.
21 22 23 24 25 |
# File 'lib/lunar_calendar/lunar_year.rb', line 21 def month_days (0..12).map do |month| LunarCalendar::Utils.decode(binary, 1, 12 - month) == 1 ? 30 : 29 end end |