Skip to content

Instantly share code, notes, and snippets.

@igneus
Last active July 8, 2024 09:10
Show Gist options
  • Save igneus/8a9634d422d3645fb8f1053506296d71 to your computer and use it in GitHub Desktop.
Save igneus/8a9634d422d3645fb8f1053506296d71 to your computer and use it in GitHub Desktop.
Is the Psalter of Liturgia horarum ever said whole without interruption?
require 'calendarium-romanum/cr'
require 'set'
require 'colorize'
require 'optparse'
MEMORIALS_WITH_FESTAL_PSALMS = Set.new(%i[
agnes
baptist_beheading
bvm_sorrows
guardian_angels
bvm_rosary
martin
])
def is_privileged_sunday_or_ferial?(celebration)
celebration.title.include?('Sunday') ||
celebration.title.include?('of Holy Week')
end
def has_festal_psalms?(celebration)
(celebration.rank >= CR::Ranks::FEAST_PROPER &&
!is_privileged_sunday_or_ferial?(celebration)) ||
MEMORIALS_WITH_FESTAL_PSALMS.include?(celebration.symbol)
end
def announce(psalter_days, date, verbose = false)
return if psalter_days <= 0
color =
if psalter_days >= 28 # whole Psalter has 4 weeks
:green
elsif psalter_days > 20
:yellow
elsif psalter_days > 10
:red
else
:white
end
puts "#{psalter_days} til #{date}".colorize(color) if color == :green || verbose
sleep 3 if color == :green && verbose
end
verbose = false
OptionParser.new do |opts|
opts.on '-v', '--verbose' do
verbose = true
end
end.parse!
calendar = CR::PerpetualCalendar.new sanctorale: CR::Data::GENERAL_ROMAN_ENGLISH.load
psalter_days = 0
last_season = nil
(Date.new(2000, 1, 1) .. Date.new(2050, 1, 1))
.each do |date|
day = calendar[date]
if day.season != last_season
# new season resets the Psalter
puts "#{date}: #{day.season} begins, Psalter reset" if verbose
announce psalter_days, date, verbose
psalter_days = 0
last_season = day.season
end
celebration = day.celebrations.first # take the first celebration, ignore optional memorials
if has_festal_psalms?(celebration)
puts "#{date}: #{celebration.title} has festal psalms" if verbose
announce psalter_days, date, verbose
psalter_days = 0
next
end
psalter_days += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment