Skip to content

Instantly share code, notes, and snippets.

@igneus
Created May 13, 2023 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igneus/89983eb9da497e50d6e3133bd5567a28 to your computer and use it in GitHub Desktop.
Save igneus/89983eb9da497e50d6e3133bd5567a28 to your computer and use it in GitHub Desktop.
calrom formatter summarizing the day's liturgy in just one or two characters
# custom formatter for calrom https://github.com/calendarium-romanum/calrom
# Don't expect calrom code to be already loaded, load all direct dependencies of our class - this allows usage like
# $ RUBYOPT="-I my/custom/code/dir -r ultra_condensed_formatter" calrom -f ultracondensed --today
require 'calrom/formatter/formatter'
module Calrom
module Formatter
# Prints just one or two characters signalling
# what kind of celebration is celebrated today.
# ("Is it a regular ferial/Sunday, or should I look in the
# detailed calendar?")
# Intended for use in WM panels on small displays.
class Ultracondensed < Formatter
def call(calendar, date_range)
calendar.each_day_in_range(date_range) {|d| day_rank d }
end
private
def day_rank(liturgical_day)
c = liturgical_day.celebrations.first
rank = c.rank
r =
if rank.solemnity?
'S'
elsif rank.feast?
'F'
elsif rank.sunday?
'D'
elsif rank.memorial?
'm'
elsif rank.ferial?
'f' + (liturgical_day.celebrations.size > 1 ? '+' : '')
else
raise "unexpected rank #{rank.inspect}"
end
puts r
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment