Class: CalendariumRomanum::Celebration

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
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

Instance Method Summary collapse

Constructor Details

#initialize(title = '', rank = Ranks::FERIAL, colour = Colours::GREEN, symbol = nil, date = nil, cycle = :sanctorale) ⇒ Celebration

Returns a new instance of Celebration.

Parameters:

  • title (String|Proc) (defaults to: '')

    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.)

  • rank (Rank) (defaults to: Ranks::FERIAL)

    Celebration rank

  • colour (Colour) (defaults to: Colours::GREEN)

    Liturgical colour

  • symbol (Symbol, nil) (defaults to: nil)

    Unique machine-readable identifier of the celebration

  • date (AbstractDate, nil) (defaults to: nil)

    Normal fixed date of the celebration

  • cycle (:sanctorale, :temporale) (defaults to: :sanctorale)

    Cycle the celebration belongs to


126
127
128
129
130
131
132
133
# File 'lib/calendarium-romanum/day.rb', line 126

def initialize(title = '', rank = Ranks::FERIAL, colour = Colours::GREEN, symbol = nil, date = nil, cycle = :sanctorale)
  @title = title
  @rank = rank
  @colour = colour
  @symbol = symbol
  @date = date
  @cycle = cycle
end

Instance Attribute Details

#colourColour (readonly) Also known as: color

Liturgical colour

Returns:


166
167
168
# File 'lib/calendarium-romanum/day.rb', line 166

def colour
  @colour
end

#cycle:sanctorale, :temporale (readonly)

Describes the celebration as belonging either to the temporale or sanctorale cycle

Returns:

  • (:sanctorale, :temporale)

Since:

  • 0.6.0


191
192
193
# File 'lib/calendarium-romanum/day.rb', line 191

def cycle
  @cycle
end

#dateAbstractDate? (readonly)

Usual date of the celebration.

Only set for celebrations with fixed date. (Only) In case of solemnities it may happen that #date differs from Day#date due to transfer of an impeded solemnity.

Returns:

Since:

  • 0.6.0


184
185
186
# File 'lib/calendarium-romanum/day.rb', line 184

def date
  @date
end

#rankRank (readonly)

Returns:


136
137
138
# File 'lib/calendarium-romanum/day.rb', line 136

def rank
  @rank
end

#symbolSymbol? (readonly)

Symbol uniquely identifying the celebration

Returns:

  • (Symbol, nil)

Since:

  • 0.5.0


173
174
175
# File 'lib/calendarium-romanum/day.rb', line 173

def symbol
  @symbol
end

Instance Method Details

#==(b) ⇒ Object


193
194
195
196
197
198
199
200
201
# File 'lib/calendarium-romanum/day.rb', line 193

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) ⇒ Celebration

Build a new instance using the receiver's attributes for all properties for which (a non-nil) value was not passed.

Returns:

Since:

  • 0.5.0


224
225
226
227
228
229
230
231
232
233
# File 'lib/calendarium-romanum/day.rb', line 224

def change(title: nil, rank: nil, colour: nil, color: nil, symbol: nil, date: nil, cycle: nil)
  self.class.new(
    title || self.title,
    rank || self.rank,
    colour || color || self.colour,
    symbol || self.symbol,
    date || self.date,
    cycle || self.cycle,
  )
end

#feast?Boolean

Returns:

  • (Boolean)

150
# File 'lib/calendarium-romanum/day.rb', line 150

def_delegators :@rank, :solemnity?, :feast?, :memorial?, :sunday?, :ferial?

#ferial?Boolean

Returns:

  • (Boolean)

Since:

  • 0.6.0


150
# File 'lib/calendarium-romanum/day.rb', line 150

def_delegators :@rank, :solemnity?, :feast?, :memorial?, :sunday?, :ferial?

#memorial?Boolean

Returns:

  • (Boolean)

150
# File 'lib/calendarium-romanum/day.rb', line 150

def_delegators :@rank, :solemnity?, :feast?, :memorial?, :sunday?, :ferial?

#sanctorale?Boolean

Does the celebration belong to the sanctorale cycle?

Returns:

  • (Boolean)

Since:

  • 0.6.0


215
216
217
# File 'lib/calendarium-romanum/day.rb', line 215

def sanctorale?
  cycle == :sanctorale
end

#solemnity?Boolean

Returns:

  • (Boolean)

150
# File 'lib/calendarium-romanum/day.rb', line 150

def_delegators :@rank, :solemnity?, :feast?, :memorial?, :sunday?, :ferial?

#sunday?Boolean

Returns:

  • (Boolean)

Since:

  • 0.6.0


150
# File 'lib/calendarium-romanum/day.rb', line 150

def_delegators :@rank, :solemnity?, :feast?, :memorial?, :sunday?, :ferial?

#temporale?Boolean

Does the celebration belong to the temporale cycle?

Returns:

  • (Boolean)

Since:

  • 0.6.0


207
208
209
# File 'lib/calendarium-romanum/day.rb', line 207

def temporale?
  cycle == :temporale
end

#titleString

Feast title/name

Returns:

  • (String)

155
156
157
158
159
160
161
# File 'lib/calendarium-romanum/day.rb', line 155

def title
  if @title.respond_to? :call
    @title.call
  else
    @title
  end
end

#to_sString

String representation of the object's contents (not very pretty, intended mostly for development inspections).

Returns:

  • (String)

Since:

  • 0.7.0


240
241
242
# File 'lib/calendarium-romanum/day.rb', line 240

def to_s
  "#<#{self.class.name} @title=\"#{title}\" @rank=#{rank} @colour=#{colour} symbol=#{symbol.inspect} date=#{date.inspect} cycle=#{cycle.inspect}>"
end