Class: CalendariumRomanum::Temporale
- Inherits:
-
Object
- Object
- CalendariumRomanum::Temporale
- Defined in:
- lib/calendarium-romanum/temporale.rb,
lib/calendarium-romanum/temporale/dates.rb,
lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb
Overview
determine seasons and dates of the Temporale feasts of the given year
Defined Under Namespace
Modules: Dates, Extensions
Constant Summary collapse
- WEEK =
7
Instance Attribute Summary collapse
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
-
.add_celebration(date_method, celebration) ⇒ Object
Hook point for extensions to add new celebrations.
-
.celebrations ⇒ Object
implementation detail, not to be touched by client code.
-
.for_day(date) ⇒ Object
creates a Calendar for the liturgical year including given date.
-
.liturgical_year(date) ⇒ Object
Determines liturgical year for the given date.
-
.with_extensions(*extensions) ⇒ Object
Creates a subclass with specified extension modules included.
Instance Method Summary collapse
- #date_range ⇒ Object
- #end_date ⇒ Object
-
#get(*args) ⇒ Object
returns a Celebration scheduled for the given day.
-
#initialize(year) ⇒ Temporale
constructor
year is Integer - the civil year when the liturgical year begins.
- #range_check(date) ⇒ Object
-
#season(date) ⇒ Object
which liturgical season is it?.
- #season_beginning(s) ⇒ Object
- #season_week(seasonn, date) ⇒ Object
- #start_date ⇒ Object
Constructor Details
#initialize(year) ⇒ Temporale
year is Integer - the civil year when the liturgical year begins
11 12 13 14 |
# File 'lib/calendarium-romanum/temporale.rb', line 11 def initialize(year) @year = year prepare_solemnities end |
Instance Attribute Details
#year ⇒ Object (readonly)
Returns the value of attribute year
16 17 18 |
# File 'lib/calendarium-romanum/temporale.rb', line 16 def year @year end |
Class Method Details
.add_celebration(date_method, celebration) ⇒ Object
Hook point for extensions to add new celebrations
79 80 81 82 83 84 85 |
# File 'lib/calendarium-romanum/temporale.rb', line 79 def add_celebration(date_method, celebration) if self == Temporale raise RuntimeError.new("Don't add celebrations to Temporale itself, subclass it and modify the subclass.") end celebrations << C.new(date_method, celebration) end |
.celebrations ⇒ Object
implementation detail, not to be touched by client code
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/calendarium-romanum/temporale.rb', line 48 def celebrations @celebrations ||= begin [ c(:nativity, Ranks::PRIMARY), c(:holy_family, Ranks::FEAST_LORD_GENERAL), c(:mother_of_god, Ranks::SOLEMNITY_GENERAL), c(:epiphany, Ranks::PRIMARY), c(:baptism_of_lord, Ranks::FEAST_LORD_GENERAL), c(:ash_wednesday, Ranks::PRIMARY, Colours::VIOLET), c(:good_friday, Ranks::TRIDUUM, Colours::RED), c(:holy_saturday, Ranks::TRIDUUM, Colours::VIOLET), c(:palm_sunday, Ranks::PRIMARY, Colours::RED), c(:easter_sunday, Ranks::TRIDUUM), c(:ascension, Ranks::PRIMARY), c(:pentecost, Ranks::PRIMARY, Colours::RED), c(:holy_trinity, Ranks::SOLEMNITY_GENERAL), c(:body_blood, Ranks::SOLEMNITY_GENERAL), c(:sacred_heart, Ranks::SOLEMNITY_GENERAL), c(:christ_king, Ranks::SOLEMNITY_GENERAL), # Immaculate Heart of Mary is actually (currently the only one) # movable *sanctorale* feast, but as it would make little sense # to add support for movable sanctorale feasts because of # a single one, we cheat a bit and handle it in temporale. c(:immaculate_heart, Ranks::MEMORIAL_GENERAL), ] end end |
.for_day(date) ⇒ Object
creates a Calendar for the liturgical year including given date
40 41 42 |
# File 'lib/calendarium-romanum/temporale.rb', line 40 def for_day(date) return new(liturgical_year(date)) end |
.liturgical_year(date) ⇒ Object
Determines liturgical year for the given date
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/calendarium-romanum/temporale.rb', line 27 def liturgical_year(date) year = date.year temporale = Temporale.new year if date < temporale.first_advent_sunday return year - 1 end return year end |
.with_extensions(*extensions) ⇒ Object
Creates a subclass with specified extension modules included
20 21 22 23 24 |
# File 'lib/calendarium-romanum/temporale.rb', line 20 def with_extensions(*extensions) Class.new(self) do extensions.each {|e| include e } end end |
Instance Method Details
#date_range ⇒ Object
107 108 109 |
# File 'lib/calendarium-romanum/temporale.rb', line 107 def date_range start_date .. end_date end |
#end_date ⇒ Object
103 104 105 |
# File 'lib/calendarium-romanum/temporale.rb', line 103 def end_date Dates.first_advent_sunday(year+1) - 1 end |
#get(*args) ⇒ Object
returns a Celebration scheduled for the given day
expected arguments: Date or two Integers (month, day)
212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/calendarium-romanum/temporale.rb', line 212 def get(*args) if args.size == 1 && args[0].is_a?(Date) date = args[0] else month, day = args date = Date.new @year, month, day unless date_range.include? date date = Date.new @year + 1, month, day end end return @solemnities[date] || @feasts[date] || sunday(date) || @memorials[date] || ferial(date) end |
#range_check(date) ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/calendarium-romanum/temporale.rb', line 111 def range_check(date) # necessary in order to handle Date correctly date = date.to_date if date.class != Date unless date_range.include? date raise RangeError.new "Date out of range #{date}" end end |
#season(date) ⇒ Object
which liturgical season is it?
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/calendarium-romanum/temporale.rb', line 146 def season(date) range_check date if first_advent_sunday <= date and nativity > date then Seasons::ADVENT elsif nativity <= date and baptism_of_lord >= date then Seasons::CHRISTMAS elsif ash_wednesday <= date and easter_sunday > date then Seasons::LENT elsif easter_sunday <= date and pentecost >= date then Seasons::EASTER else Seasons::ORDINARY end end |
#season_beginning(s) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/calendarium-romanum/temporale.rb', line 170 def season_beginning(s) case s when Seasons::ADVENT first_advent_sunday when Seasons::CHRISTMAS nativity when Seasons::LENT ash_wednesday when Seasons::EASTER easter_sunday else # ordinary time Dates.monday_after(baptism_of_lord) end end |
#season_week(seasonn, date) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/calendarium-romanum/temporale.rb', line 185 def season_week(seasonn, date) week1_beginning = season_beginning = season_beginning(seasonn) unless season_beginning.sunday? week1_beginning = Dates.sunday_after(season_beginning) end week = date_difference(date, week1_beginning) / Temporale::WEEK + 1 if seasonn == Seasons::ORDINARY # ordinary time does not begin with Sunday, but the first week # is week 1, not 0 week += 1 if date > pentecost weeks_after_date = date_difference(Dates.first_advent_sunday(@year + 1), date) / 7 week = 34 - weeks_after_date week += 1 if date.sunday? end end return week end |
#start_date ⇒ Object
99 100 101 |
# File 'lib/calendarium-romanum/temporale.rb', line 99 def start_date first_advent_sunday end |