Class: CalendariumRomanum::Temporale

Inherits:
Object
  • Object
show all
Defined in:
lib/calendarium-romanum/temporale.rb,
lib/calendarium-romanum/temporale/dates.rb,
lib/calendarium-romanum/temporale/extensions.rb,
lib/calendarium-romanum/temporale/date_helper.rb,
lib/calendarium-romanum/temporale/easter_table.rb,
lib/calendarium-romanum/temporale/celebration_factory.rb,
lib/calendarium-romanum/temporale/extensions/christ_eternal_priest.rb,
lib/calendarium-romanum/temporale/extensions/dedication_before_all_saints.rb

Overview

One of the two main Calendar components. Handles seasons and celebrations of the temporale cycle for a given liturgical year.

Defined Under Namespace

Modules: DateHelper, Dates, Extensions Classes: CelebrationFactory, EasterTable

Constant Summary collapse

WEEK =

How many days in a week

7
SUNDAY_TRANSFERABLE_SOLEMNITIES =

Which solemnities can be transferred to Sunday

%i(epiphany ascension corpus_christi).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(year, extensions: [], transfer_to_sunday: []) ⇒ Temporale

Returns a new instance of Temporale.

Parameters:

  • year (Integer)

    the civil year when the liturgical year begins

  • extensions (Array<#each_celebration>) (defaults to: [])

    extensions implementing custom temporale celebrations

  • transfer_to_sunday (Array<Symbol>) (defaults to: [])

    which solemnities should be transferred to a nearby Sunday - see SUNDAY_TRANSFERABLE_SOLEMNITIES for possible values



23
24
25
26
27
28
29
30
31
# File 'lib/calendarium-romanum/temporale.rb', line 23

def initialize(year, extensions: [], transfer_to_sunday: [])
  @year = year

  @extensions = extensions
  @transfer_to_sunday = transfer_to_sunday.sort
  validate_sunday_transfer!

  prepare_solemnities
end

Instance Attribute Details

#yearInteger (readonly)

Returns:

  • (Integer)


34
35
36
# File 'lib/calendarium-romanum/temporale.rb', line 34

def year
  @year
end

Class Method Details

.celebrationsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/calendarium-romanum/temporale.rb', line 80

def celebrations
  @celebrations ||=
    begin
      %i(
        nativity
        holy_family
        mother_of_god
        epiphany
        baptism_of_lord
        ash_wednesday
        good_friday
        holy_saturday
        palm_sunday
        easter_sunday
        ascension
        pentecost
        holy_trinity
        corpus_christi
        mother_of_church
        sacred_heart
        christ_king
        immaculate_heart
      ).collect do |symbol|
        date_method = symbol
        C.new(
          date_method,
          CelebrationFactory.public_send(symbol)
        )
      end
      # Immaculate Heart of Mary and Mary, Mother of the Church
      # are actually movable *sanctorale* feasts,
      # but as it would make little sense
      # to add support for movable sanctorale feasts because of
      # two, we cheat a bit and handle them in temporale.
    end
end

.create_celebration(title, rank, colour, symbol: nil, date: nil, sunday: nil) ⇒ Object

Factory method creating temporale Celebrations with sensible defaults

See Celebration#initialize for argument description.



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/calendarium-romanum/temporale.rb', line 64

def create_celebration(title, rank, colour, symbol: nil, date: nil, sunday: nil)
  Celebration.new(
    title: title,
    rank: rank,
    colour: colour,
    symbol: symbol,
    date: date,
    cycle: :temporale,
    sunday: sunday
  )
end

.for_day(date) ⇒ Temporale

Creates an instance for the liturgical year including given date

Parameters:

  • date (Date)

Returns:



56
57
58
# File 'lib/calendarium-romanum/temporale.rb', line 56

def for_day(date)
  new(liturgical_year(date))
end

.liturgical_year(date) ⇒ Integer

Determines liturgical year for the given date

Parameters:

  • date (Date)

Returns:

  • (Integer)


41
42
43
44
45
46
47
48
49
# File 'lib/calendarium-romanum/temporale.rb', line 41

def liturgical_year(date)
  year = date.year

  if date < Dates.first_advent_sunday(year)
    return year - 1
  end

  year
end

Instance Method Details

#==(b) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.6.0



349
350
351
352
353
354
# File 'lib/calendarium-romanum/temporale.rb', line 349

def ==(b)
  self.class == b.class &&
    year == b.year &&
    transfer_to_sunday == b.transfer_to_sunday &&
    Set.new(extensions) == Set.new(b.extensions)
end

#[](date) ⇒ Celebration

Retrieve temporale celebration for the given day

Parameters:

  • date (Date)

Returns:

Since:

  • 0.6.0



308
309
310
311
312
# File 'lib/calendarium-romanum/temporale.rb', line 308

def [](date)
  sw = season_and_week(date)

  @solemnities[date] || @feasts[date] || sunday(date, sw) || @memorials[date] || ferial(date, sw)
end

#ascensionDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#ash_wednesdayDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#baptism_of_lordDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#christ_kingDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#corpus_christiDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#date_rangeRange<Date>

Date range of the liturgical year

Returns:

  • (Range<Date>)


143
144
145
# File 'lib/calendarium-romanum/temporale.rb', line 143

def date_range
  start_date .. end_date
end

#each_day {|Date, Celebration| ... } ⇒ void, Enumerator

Enumerates dates and celebrations

Yields:

Returns:

  • (void, Enumerator)

    if called without a block, returns Enumerator

Since:

  • 0.8.0



341
342
343
344
345
# File 'lib/calendarium-romanum/temporale.rb', line 341

def each_day
  return to_enum(__method__) unless block_given?

  date_range.each {|date| yield date, self[date] }
end

#easter_sundayDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#end_dateDate

Last day of the liturgical year

Returns:

  • (Date)


136
137
138
# File 'lib/calendarium-romanum/temporale.rb', line 136

def end_date
  Dates.first_advent_sunday(year + 1) - 1
end

#epiphanyDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#first_advent_sundayDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#get(date) ⇒ Celebration #get(month, day) ⇒ Celebration

Retrieve temporale celebration for the given day

Overloads:

  • #get(date) ⇒ Celebration

    Parameters:

    • date (Date)
  • #get(month, day) ⇒ Celebration

    Parameters:

    • month (Integer)
    • day (Integer)

Returns:



322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/calendarium-romanum/temporale.rb', line 322

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

  self[date]
end

#good_fridayDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#holy_familyDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#holy_saturdayDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#holy_trinityDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#immaculate_heartDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#mother_of_churchDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#mother_of_godDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#nativityDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#palm_sundayDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#pentecostDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#provides_celebration?(symbol) ⇒ Boolean

Does this instance provide celebration identified by symbol symbol?

Parameters:

  • symbol (Symbol)

Returns:

  • (Boolean)

Since:

  • 0.9.0



361
362
363
# File 'lib/calendarium-romanum/temporale.rb', line 361

def provides_celebration?(symbol)
  @all_celebration_symbols.include? symbol
end

#range_check(date) ⇒ void

This method returns an undefined value.

Check that the date belongs to the liturgical year. If it does not, throw exception.

Parameters:

  • date (Date)

Raises:

  • (RangeError)


153
154
155
156
157
158
159
160
# File 'lib/calendarium-romanum/temporale.rb', line 153

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

#sacred_heartDate

Returns:

  • (Date)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/calendarium-romanum/temporale.rb', line 200

(celebrations.collect(&:date_method) + [:first_advent_sunday])
  .each do |feast|
  if SUNDAY_TRANSFERABLE_SOLEMNITIES.include? feast
    define_method feast do
      Dates.public_send feast, year, sunday: transferred_to_sunday?(feast)
    end
  elsif feast == :baptism_of_lord
    define_method feast do
      Dates.public_send feast, year, epiphany_on_sunday: transferred_to_sunday?(:epiphany)
    end
  else
    define_method feast do
      Dates.public_send feast, year
    end
  end
end

#season(date) ⇒ Season

Determine liturgical season for a given date

Parameters:

  • date (Date)

Returns:

Raises:

  • (RangeError)

    if the given date doesn’t belong to the liturgical year



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/calendarium-romanum/temporale.rb', line 223

def season(date)
  range_check date

  if first_advent_sunday <= date &&
     nativity > date
    Seasons::ADVENT

  elsif nativity <= date &&
        baptism_of_lord >= date
    Seasons::CHRISTMAS

  elsif ash_wednesday <= date &&
        good_friday > date
    Seasons::LENT

  elsif good_friday <= date &&
        easter_sunday >= date
    Seasons::TRIDUUM

  elsif easter_sunday < date &&
        pentecost >= date
    Seasons::EASTER

  else
    Seasons::ORDINARY
  end
end

#season_beginning(s) ⇒ Date

When the specified liturgical season begins

Parameters:

Returns:

  • (Date)


255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/calendarium-romanum/temporale.rb', line 255

def season_beginning(s)
  case s
  when Seasons::ADVENT
    first_advent_sunday
  when Seasons::CHRISTMAS
    nativity
  when Seasons::LENT
    ash_wednesday
  when Seasons::TRIDUUM
    good_friday
  when Seasons::EASTER
    easter_sunday + 1
  when Seasons::ORDINARY
    baptism_of_lord + 1
  else
    raise ArgumentError.new('unsupported season')
  end
end

#season_week(seasonn, date) ⇒ Object

Determine week of a season for a given date

Parameters:

  • seasonn (Season)
  • date (Date)


278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/calendarium-romanum/temporale.rb', line 278

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) / WEEK + 1

  if seasonn == Seasons::ORDINARY || seasonn == Seasons::EASTER
    # ordinary time does not begin with Sunday, but the first week
    # is week 1, not 0
    week += 1
  end

  if seasonn == Seasons::ORDINARY
    if date > pentecost
      weeks_after_date = date_difference(Dates.first_advent_sunday(@year + 1), date) / WEEK
      week = 34 - weeks_after_date
      week += 1 if date.sunday?
    end
  end

  week
end

#start_dateDate

First day of the liturgical year

Returns:

  • (Date)


129
130
131
# File 'lib/calendarium-romanum/temporale.rb', line 129

def start_date
  first_advent_sunday
end

#transferred_to_sunday?(solemnity) ⇒ Boolean

Does this instance transfer the specified solemnity to Sunday?

Parameters:

  • solemnity (Symbol)

Returns:

  • (Boolean)


122
123
124
# File 'lib/calendarium-romanum/temporale.rb', line 122

def transferred_to_sunday?(solemnity)
  @transfer_to_sunday.include?(solemnity)
end