Class: CalendariumRomanum::PerpetualCalendar
- Inherits:
-
Object
- Object
- CalendariumRomanum::PerpetualCalendar
- Defined in:
- lib/calendarium-romanum/perpetual_calendar.rb
Overview
When you want to query a calendar without caring about civil and liturgical years and Calendar instances
Instance Method Summary collapse
- #[](arg) ⇒ Object
-
#calendar_for(*args) ⇒ Object
returns a Calendar instance for the liturgical year containing the specified day.
-
#calendar_for_year(year) ⇒ Object
returns a Calendar instance for the specified liturgical year.
-
#day(*args) ⇒ Object
returns a resolved Day.
-
#initialize(sanctorale: nil, temporale_factory: nil, temporale_options: nil, cache: {}) ⇒ PerpetualCalendar
constructor
A new instance of PerpetualCalendar.
Constructor Details
#initialize(sanctorale: nil, temporale_factory: nil, temporale_options: nil, cache: {}) ⇒ PerpetualCalendar
Returns a new instance of PerpetualCalendar.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/calendarium-romanum/perpetual_calendar.rb', line 5 def initialize(sanctorale: nil, temporale_factory: nil, temporale_options: nil, cache: {}) if temporale_factory && raise ArgumentError.new('Specify either temporale_factory or temporale_options, not both') end @sanctorale = sanctorale @temporale_factory = temporale_factory || build_temporale_factory() @cache = cache end |
Instance Method Details
#[](arg) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/calendarium-romanum/perpetual_calendar.rb', line 21 def [](arg) if arg.is_a? Range return arg.collect do |date| calendar_for(date).day(date) end end day(arg) end |
#calendar_for(*args) ⇒ Object
returns a Calendar instance for the liturgical year containing the specified day
33 34 35 36 37 |
# File 'lib/calendarium-romanum/perpetual_calendar.rb', line 33 def calendar_for(*args) date = Calendar.mk_date(*args) year = Temporale.liturgical_year date calendar_instance year end |
#calendar_for_year(year) ⇒ Object
returns a Calendar instance for the specified liturgical year
40 41 42 |
# File 'lib/calendarium-romanum/perpetual_calendar.rb', line 40 def calendar_for_year(year) calendar_instance year end |
#day(*args) ⇒ Object
returns a resolved Day
17 18 19 |
# File 'lib/calendarium-romanum/perpetual_calendar.rb', line 17 def day(*args) calendar_for(*args).day(*args) end |