class CalendariumRomanum::Celebration
One particular celebration of the liturgical year (like a Sunday, feast or memorial); some days have one, some have more among which one is to be chosen
Attributes
Liturgical colour
@return [Colour]
Liturgical colour
@return [Colour]
Describes the celebration as belonging either to the temporale or sanctorale cycle
@return [:sanctorale, :temporale] @since 0.6.0
Usual date of the celebration.
Only set for celebrations with fixed date. (Only) In case of solemnities it may happen that {Celebration#date} differs from {Day#date} due to transfer of an impeded solemnity.
@return [AbstractDate, nil] @since 0.6.0
@return [Rank]
Symbol uniquely identifying the celebration
@return [Symbol, nil] @since 0.5.0
Public Class Methods
All arguments can be passed either as positional or keyword arguments. In case of conflict keyword arguments win. @example
Celebration.new('Lost title', title: 'Winning title') # will have title 'Winning title'
@param title [String|Proc]
Celebration title/name. If a +Proc+ is passed, it is expected not to receive arguments and to return a +String+. (Used for celebration titles which have to be internationalizable - the +Proc+ is called whenever {#title} is invoked, which allows the value to vary depending e.g. on state of the +Proc+ or some global setting - like +I18n.locale+ - it may access.)
@param rank [Rank] Celebration
rank @param colour [Colour] Liturgical colour @param symbol [Symbol, nil]
Unique machine-readable identifier of the celebration
@param date [AbstractDate, nil]
Normal fixed date of the celebration
@param cycle [:sanctorale, :temporale]
Cycle the celebration belongs to
# File lib/calendarium-romanum/day.rb, line 129 def initialize(title = '', rank = Ranks::FERIAL, colour = Colours::GREEN, symbol = nil, date = nil, cycle = :sanctorale, sunday = false, **kwargs) @title = kwargs.delete(:title) || title @rank = kwargs.delete(:rank) || rank @colour = kwargs.delete(:colour) || kwargs.delete(:color) || colour @symbol = kwargs.delete(:symbol) || symbol @date = kwargs.delete(:date) || date @cycle = kwargs.delete(:cycle) || cycle @sunday = kwargs.delete(:sunday) || sunday unless kwargs.empty? raise ArgumentError.new('Unexpected keyword arguments: ' + kwargs.keys.inspect) end if @sunday && ![Ranks::SUNDAY_UNPRIVILEGED, Ranks::PRIMARY].include?(@rank) raise ArgumentError.new("Rank #{@rank} cannot be Sunday") end end
Public Instance Methods
# File lib/calendarium-romanum/day.rb, line 208 def ==(b) self.class == b.class && title == b.title && rank == b.rank && colour == b.colour && symbol == b.symbol && date == b.date && cycle == b.cycle end
Build a new instance using the receiver's attributes for all properties for which (a non-nil) value was not passed.
@return [Celebration] @since 0.5.0
# File lib/calendarium-romanum/day.rb, line 152 def change(title: nil, rank: nil, colour: nil, color: nil, symbol: nil, date: nil, cycle: nil, sunday: nil) self.class.new( title: title || self.title, rank: rank || self.rank, colour: colour || color || self.colour, symbol: symbol || self.symbol, date: date || self.date, cycle: cycle || self.cycle, sunday: sunday || @sunday ) end
Does the celebration belong to the sanctorale cycle?
@return [Boolean] @since 0.6.0
# File lib/calendarium-romanum/day.rb, line 230 def sanctorale? cycle == :sanctorale end
Is the celebration a Sunday?
Please note that for “privileged Sundays” true is returned, while {Rank#sunday?} returns false (because not all celebrations of that rank are Sundays).
@return [Boolean]
# File lib/calendarium-romanum/day.rb, line 240 def sunday? rank.sunday? || @sunday end
Does the celebration belong to the temporale cycle?
@return [Boolean] @since 0.6.0
# File lib/calendarium-romanum/day.rb, line 222 def temporale? cycle == :temporale end
Feast title/name
@return [String]
# File lib/calendarium-romanum/day.rb, line 170 def title if @title.respond_to? :call @title.call else @title end end
String representation of the object's contents (not very pretty, intended mostly for development inspections).
@return [String] @since 0.7.0
# File lib/calendarium-romanum/day.rb, line 249 def to_s "#<#{self.class.name} @title=\"#{title}\" @rank=#{rank} @colour=#{colour} symbol=#{symbol.inspect} date=#{date.inspect} cycle=#{cycle.inspect}>" end