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/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
SUNDAY_TRANSFERABLE_SOLEMNITIES =
%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

year is Integer - the civil year when the liturgical year begins


14
15
16
17
18
19
20
21
22
# File 'lib/calendarium-romanum/temporale.rb', line 14

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

  @extensions = extensions
  @transfer_to_sunday = transfer_to_sunday
  validate_sunday_transfer!

  prepare_solemnities
end

Instance Attribute Details

#yearObject (readonly)

Returns the value of attribute year


24
25
26
# File 'lib/calendarium-romanum/temporale.rb', line 24

def year
  @year
end

Class Method Details

.celebrationsObject

implementation detail, not to be touched by client code


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
77
# File 'lib/calendarium-romanum/temporale.rb', line 49

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(:corpus_christi, 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


41
42
43
# File 'lib/calendarium-romanum/temporale.rb', line 41

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

.liturgical_year(date) ⇒ Object

Determines liturgical year for the given date


28
29
30
31
32
33
34
35
36
37
# File 'lib/calendarium-romanum/temporale.rb', line 28

def liturgical_year(date)
  year = date.year
  temporale = Temporale.new year

  if date < temporale.first_advent_sunday
    return year - 1
  end

  return year
end

Instance Method Details

#date_rangeObject


103
104
105
# File 'lib/calendarium-romanum/temporale.rb', line 103

def date_range
  start_date .. end_date
end

#end_dateObject


99
100
101
# File 'lib/calendarium-romanum/temporale.rb', line 99

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)


218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/calendarium-romanum/temporale.rb', line 218

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


107
108
109
110
111
112
113
114
# File 'lib/calendarium-romanum/temporale.rb', line 107

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?


152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/calendarium-romanum/temporale.rb', line 152

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


176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/calendarium-romanum/temporale.rb', line 176

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


191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/calendarium-romanum/temporale.rb', line 191

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
    # 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_dateObject


95
96
97
# File 'lib/calendarium-romanum/temporale.rb', line 95

def start_date
  first_advent_sunday
end

#transferred_to_sunday?(solemnity) ⇒ Boolean

Returns:

  • (Boolean)

91
92
93
# File 'lib/calendarium-romanum/temporale.rb', line 91

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