Class: CalendariumRomanum::Celebration
- Inherits:
-
Object
- Object
- CalendariumRomanum::Celebration
- Includes:
- RankPredicates
- Defined in:
- lib/calendarium-romanum/day.rb
Overview
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
Instance Attribute Summary collapse
-
#colour ⇒ Colour
(also: #color)
readonly
Liturgical colour.
-
#cycle ⇒ :sanctorale, :temporale
readonly
Describes the celebration as belonging either to the temporale or sanctorale cycle.
-
#date ⇒ AbstractDate?
readonly
Usual date of the celebration.
- #rank ⇒ Rank readonly
-
#symbol ⇒ Symbol?
readonly
Symbol uniquely identifying the celebration.
Instance Method Summary collapse
- #==(b) ⇒ Object
-
#change(title: nil, rank: nil, colour: nil, color: nil, symbol: nil, date: nil, cycle: nil, sunday: nil) ⇒ Celebration
Build a new instance using the receiver’s attributes for all properties for which (a non-nil) value was not passed.
-
#initialize(title = '', rank = Ranks::FERIAL, colour = Colours::GREEN, symbol = nil, date = nil, cycle = :sanctorale, sunday = false, **kwargs) ⇒ Celebration
constructor
All arguments can be passed either as positional or keyword arguments.
-
#sanctorale? ⇒ Boolean
Does the celebration belong to the sanctorale cycle?.
-
#sunday? ⇒ Boolean
Is the celebration a Sunday?.
-
#temporale? ⇒ Boolean
Does the celebration belong to the temporale cycle?.
-
#title ⇒ String
Feast title/name.
-
#to_s ⇒ String
String representation of the object’s contents (not very pretty, intended mostly for development inspections).
Methods included from RankPredicates
#feast?, #ferial?, #memorial?, #obligatory_memorial?, #optional_memorial?, #solemnity?
Constructor Details
#initialize(title = '', rank = Ranks::FERIAL, colour = Colours::GREEN, symbol = nil, date = nil, cycle = :sanctorale, sunday = false, **kwargs) ⇒ Celebration
All arguments can be passed either as positional or keyword arguments. In case of conflict keyword arguments win.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# 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 |
Instance Attribute Details
#colour ⇒ Colour (readonly) Also known as: color
Liturgical colour
181 182 183 |
# File 'lib/calendarium-romanum/day.rb', line 181 def colour @colour end |
#cycle ⇒ :sanctorale, :temporale (readonly)
Describes the celebration as belonging either to the temporale or sanctorale cycle
206 207 208 |
# File 'lib/calendarium-romanum/day.rb', line 206 def cycle @cycle end |
#date ⇒ AbstractDate? (readonly)
199 200 201 |
# File 'lib/calendarium-romanum/day.rb', line 199 def date @date end |
#rank ⇒ Rank (readonly)
165 166 167 |
# File 'lib/calendarium-romanum/day.rb', line 165 def rank @rank end |
#symbol ⇒ Symbol? (readonly)
Symbol uniquely identifying the celebration
188 189 190 |
# File 'lib/calendarium-romanum/day.rb', line 188 def symbol @symbol end |
Instance Method Details
#==(b) ⇒ Object
208 209 210 211 212 213 214 215 216 |
# 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 |
#change(title: nil, rank: nil, colour: nil, color: nil, symbol: nil, date: nil, cycle: nil, sunday: nil) ⇒ Celebration
Build a new instance using the receiver’s attributes for all properties for which (a non-nil) value was not passed.
152 153 154 155 156 157 158 159 160 161 162 |
# 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 |
#sanctorale? ⇒ Boolean
Does the celebration belong to the sanctorale cycle?
230 231 232 |
# File 'lib/calendarium-romanum/day.rb', line 230 def sanctorale? cycle == :sanctorale end |
#sunday? ⇒ Boolean
Is the celebration a Sunday?
Please note that for “privileged Sundays” true is returned, while RankPredicates#sunday? returns false (because not all celebrations of that rank are Sundays).
240 241 242 |
# File 'lib/calendarium-romanum/day.rb', line 240 def sunday? rank.sunday? || @sunday end |
#temporale? ⇒ Boolean
Does the celebration belong to the temporale cycle?
222 223 224 |
# File 'lib/calendarium-romanum/day.rb', line 222 def temporale? cycle == :temporale end |
#title ⇒ String
Feast title/name
170 171 172 173 174 175 176 |
# File 'lib/calendarium-romanum/day.rb', line 170 def title if @title.respond_to? :call @title.call else @title end end |
#to_s ⇒ String
String representation of the object’s contents (not very pretty, intended mostly for development inspections).
249 250 251 |
# 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 |