Class: CalendariumRomanum::Calendar
- Inherits:
-
Object
- Object
- CalendariumRomanum::Calendar
- Extended by:
- Forwardable
- Defined in:
- lib/calendarium-romanum/calendar.rb
Overview
Provides complete information concerning a liturgical year, it’s days and celebrations occurring on them.
Constant Summary collapse
- EFFECTIVE_FROM =
Day when the implemented calendar system became effective
Date.new(1970, 1, 1).freeze
Instance Attribute Summary collapse
-
#sanctorale ⇒ Object
readonly
Returns the value of attribute sanctorale.
-
#temporale ⇒ Object
readonly
Returns the value of attribute temporale.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
-
.for_day(date, *constructor_args) ⇒ Object
creates a Calendar for the liturgical year including given date.
- .mk_date(*args) ⇒ Object
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#day(*args) ⇒ Object
accepts date information represented as Date, DateTime, or two to three integers (month - day or year - month - day); returns filled Day for the specified day.
-
#ferial_lectionary ⇒ Object
Ferial lectionary cycle.
- #freeze ⇒ Object
-
#initialize(year, sanctorale = nil, temporale = nil) ⇒ Calendar
constructor
year: Integer returns a calendar for the liturgical year beginning with Advent of the specified civil year.
-
#lectionary ⇒ Object
Sunday lectionary cycle.
Constructor Details
#initialize(year, sanctorale = nil, temporale = nil) ⇒ Calendar
year: Integer returns a calendar for the liturgical year beginning with Advent of the specified civil year.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/calendarium-romanum/calendar.rb', line 17 def initialize(year, sanctorale=nil, temporale=nil) if year < (EFFECTIVE_FROM.year - 1) raise system_not_effective end if temporale && temporale.year != year raise ArgumentError.new("Temporale year must be the same as year.") end @year = year @sanctorale = sanctorale || Sanctorale.new @temporale = temporale || Temporale.new(year) @transferred = Transfers.new(@temporale, @sanctorale) end |
Instance Attribute Details
#sanctorale ⇒ Object (readonly)
Returns the value of attribute sanctorale
66 67 68 |
# File 'lib/calendarium-romanum/calendar.rb', line 66 def sanctorale @sanctorale end |
#temporale ⇒ Object (readonly)
Returns the value of attribute temporale
65 66 67 |
# File 'lib/calendarium-romanum/calendar.rb', line 65 def temporale @temporale end |
#year ⇒ Object (readonly)
Returns the value of attribute year
64 65 66 |
# File 'lib/calendarium-romanum/calendar.rb', line 64 def year @year end |
Class Method Details
.for_day(date, *constructor_args) ⇒ Object
creates a Calendar for the liturgical year including given date
58 59 60 |
# File 'lib/calendarium-romanum/calendar.rb', line 58 def for_day(date, *constructor_args) return new(Temporale.liturgical_year(date), *constructor_args) end |
.mk_date(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/calendarium-romanum/calendar.rb', line 33 def mk_date(*args) ex = TypeError.new('Date, DateTime or three Integers expected') if args.size == 3 then args.each do |a| unless a.is_a? Integer raise ex end end return Date.new *args elsif args.size == 1 then a = args.first unless a.is_a? Date raise ex end return a else raise ex end end |
Instance Method Details
#==(obj) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/calendarium-romanum/calendar.rb', line 68 def ==(obj) unless obj.is_a? Calendar return false end return year == obj.year end |
#day(*args) ⇒ Object
accepts date information represented as Date, DateTime, or two to three integers (month - day or year - month - day); returns filled Day for the specified day
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/calendarium-romanum/calendar.rb', line 80 def day(*args) if args.size == 2 date = Date.new(@year, *args) unless @temporale.date_range.include? date date = Date.new(@year + 1, *args) end else date = self.class.mk_date *args range_check date end if date < EFFECTIVE_FROM raise system_not_effective end s = @temporale.season(date) return Day.new( date: date, season: s, season_week: @temporale.season_week(s, date), celebrations: celebrations_for(date) ) end |
#ferial_lectionary ⇒ Object
Ferial lectionary cycle
110 111 112 |
# File 'lib/calendarium-romanum/calendar.rb', line 110 def ferial_lectionary @year % 2 + 1 end |
#freeze ⇒ Object
114 115 116 117 118 |
# File 'lib/calendarium-romanum/calendar.rb', line 114 def freeze @temporale.freeze @sanctorale.freeze super end |
#lectionary ⇒ Object
Sunday lectionary cycle
105 106 107 |
# File 'lib/calendarium-romanum/calendar.rb', line 105 def lectionary LECTIONARY_CYCLES[@year % 3] end |