Class: CalendariumRomanum::Transfers
- Inherits:
-
Object
- Object
- CalendariumRomanum::Transfers
- Defined in:
- lib/calendarium-romanum/transfers.rb
Overview
Calendar component. Resolves transfers of conflicting solemnities.
For any day Temporale has a Celebration. Often Sanctorale has one (or more), too. Calendar handles these conflicts, in most cases by throwing away all the proposed Celebrations except of the one of highest rank. But when there are two conflicting solemnities, one is celebrated on the given day and the less lucky one must be transferred to another day. However, not all days are valid as targets of solemnity transfer. This class handles the logic of transferring impeded solemnities to suitable dates.
Class Method Summary collapse
-
.call(temporale, sanctorale) ⇒ Hash<Date=>Celebration>
Resolves any conflict between temporale and sanctorale solemnities by deciding which of the conflicting solemnities is to take the original date, which is to be transferred, and specifying a date for both of them in the resulting Hash.
Instance Method Summary collapse
- #call ⇒ Hash<Date=>Celebration> private
-
#initialize(temporale, sanctorale) ⇒ Transfers
constructor
private
A new instance of Transfers.
Constructor Details
#initialize(temporale, sanctorale) ⇒ Transfers
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.
Returns a new instance of Transfers.
21 22 23 24 |
# File 'lib/calendarium-romanum/transfers.rb', line 21 def initialize(temporale, sanctorale) @temporale = temporale @sanctorale = sanctorale end |
Class Method Details
.call(temporale, sanctorale) ⇒ Hash<Date=>Celebration>
Resolves any conflict between temporale and sanctorale solemnities by deciding which of the conflicting solemnities is to take the original date, which is to be transferred, and specifying a date for both of them in the resulting Hash.
34 35 36 |
# File 'lib/calendarium-romanum/transfers.rb', line 34 def self.call(temporale, sanctorale) new(temporale, sanctorale).call end |
Instance Method Details
#call ⇒ Hash<Date=>Celebration>
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.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/calendarium-romanum/transfers.rb', line 40 def call @transferred = {} dates = @sanctorale.solemnities.keys.collect do |abstract_date| concretize_abstract_date abstract_date end.sort dates.each do |date| tc = @temporale[date] next unless tc.solemnity? sc = @sanctorale[date].first next unless sc && sc.solemnity? loser, winner = [sc, tc].sort_by(&:rank) transfer_to = if loser.symbol == :annunciation && in_holy_week?(date) monday_easter2 = @temporale.easter_sunday + 8 valid_destination?(monday_easter2) ? monday_easter2 : free_day_closest_to(monday_easter2) else free_day_closest_to(date) end @transferred[transfer_to] = loser # primary celebrations have noone to be beaten by, no need to harden their dates @transferred[date] = winner unless winner.rank == Ranks::PRIMARY end @transferred end |