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.
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, sanctorale = nil) ⇒ Object
creates a Calendar for the liturgical year including given date.
- .mk_date(*args) ⇒ Object
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #celebrations_for(date) ⇒ 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.
-
#initialize(year, sanctorale = 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.
-
#pred ⇒ Object
returns a Calendar for the previous year.
-
#succ ⇒ Object
returns a Calendar for the subsequent year.
Constructor Details
#initialize(year, sanctorale = nil) ⇒ Calendar
year: Integer returns a calendar for the liturgical year beginning with Advent of the specified civil year.
15 16 17 18 19 20 |
# File 'lib/calendarium-romanum/calendar.rb', line 15 def initialize(year, sanctorale=nil) @year = year @temporale = Temporale.new(year) @sanctorale = sanctorale || Sanctorale.new @transferred = Transfers.new(@temporale, @sanctorale) end |
Instance Attribute Details
#sanctorale ⇒ Object (readonly)
Returns the value of attribute sanctorale.
56 57 58 |
# File 'lib/calendarium-romanum/calendar.rb', line 56 def sanctorale @sanctorale end |
#temporale ⇒ Object (readonly)
Returns the value of attribute temporale.
55 56 57 |
# File 'lib/calendarium-romanum/calendar.rb', line 55 def temporale @temporale end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
54 55 56 |
# File 'lib/calendarium-romanum/calendar.rb', line 54 def year @year end |
Class Method Details
.for_day(date, sanctorale = nil) ⇒ Object
creates a Calendar for the liturgical year including given date
48 49 50 |
# File 'lib/calendarium-romanum/calendar.rb', line 48 def for_day(date, sanctorale=nil) return new(Temporale.liturgical_year(date), sanctorale) end |
.mk_date(*args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/calendarium-romanum/calendar.rb', line 23 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
70 71 72 73 74 75 76 |
# File 'lib/calendarium-romanum/calendar.rb', line 70 def ==(obj) unless obj.is_a? Calendar return false end return year == obj.year end |
#celebrations_for(date) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/calendarium-romanum/calendar.rb', line 112 def celebrations_for(date) tr = @transferred.get(date) return [tr] if tr t = @temporale.get date st = @sanctorale.get date unless st.empty? if st.first.rank > t.rank if st.first.rank == Ranks::MEMORIAL_OPTIONAL st.unshift t return st else return st end end end return [t] 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
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/calendarium-romanum/calendar.rb', line 82 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 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
108 109 110 |
# File 'lib/calendarium-romanum/calendar.rb', line 108 def ferial_lectionary @year % 2 + 1 end |
#lectionary ⇒ Object
Sunday lectionary cycle
103 104 105 |
# File 'lib/calendarium-romanum/calendar.rb', line 103 def lectionary LECTIONARY_CYCLES[@year % 3] end |
#pred ⇒ Object
returns a Calendar for the previous year
65 66 67 68 |
# File 'lib/calendarium-romanum/calendar.rb', line 65 def pred c = Calendar.new @year - 1, @sanctorale return c end |
#succ ⇒ Object
returns a Calendar for the subsequent year
59 60 61 62 |
# File 'lib/calendarium-romanum/calendar.rb', line 59 def succ c = Calendar.new @year + 1, @sanctorale return c end |