class CalendariumRomanum::Day

Information on one particular day of the liturgical year

Attributes

celebrations[R]

List of celebrations for the given day.

In tests and other “less-standard” situations the array may be empty, but it's never empty for instances returned by {Calendar}.

@return [Array<Celebration>]

date[R]

@return [Date]

season[R]

@return [Season]

season_week[R]

Week of the season

@return [Integer]

vespers[R]

{Celebration} whose first Vespers are celebrated in place of Vespers of the day's {Celebration}(s). Please note that {Calendar} by default _doesn't_ populate Vespers, - it's an opt-in feature (see {Calendar#initialize}, {Calendar#populates_vespers?}, {Calendar#day}).

@return [Celebration, nil] @since 0.5.0

Public Class Methods

new(date: nil, season: nil, season_week: nil, celebrations: nil, vespers: nil) click to toggle source

Note: despite of all constructor arguments being nullable, instances returned by {Calendar} always have all of them set, the only exception being vespers.

@param date [Date, nil] @param season [Season, nil] @param season_week [Integer, nil] @param celebrations [Array<Celebration>, nil] @param vespers [Celebration, nil]

# File lib/calendarium-romanum/day.rb, line 14
def initialize(date: nil, season: nil, season_week: nil, celebrations: nil, vespers: nil)
  @date = date
  @season = season
  @season_week = season_week
  @celebrations = celebrations ? celebrations.dup : []
  @vespers = vespers
end

Public Instance Methods

==(other) click to toggle source
# File lib/calendarium-romanum/day.rb, line 68
def ==(other)
  self.class == other.class &&
    date == other.date &&
    season == other.season &&
    season_week == other.season_week &&
    celebrations == other.celebrations &&
    vespers == other.vespers
end
to_s() click to toggle source

String representation of the instance listing it's contents. Intended mostly for debugging purposes.

@return [String] @since 0.7.0

# File lib/calendarium-romanum/day.rb, line 90
def to_s
  celebrations_string = '['
  celebrations.each do |c|
    celebrations_string << c.to_s + ', '
  end
  celebrations_string = celebrations_string.chomp(', ') << ']'
  "#<#{self.class.name} @date=#{date} @season=#{season} @season_week=#{season_week} celebrations=#{celebrations_string} vespers=#{vespers.inspect}>"
end
vespers_from_following?() click to toggle source

Are the day's Vespers suppressed in favour of first Vespers of a Sunday or solemnity?

@return [Boolean]

# File lib/calendarium-romanum/day.rb, line 81
def vespers_from_following?
  !vespers.nil?
end
weekday() click to toggle source

Weekday as integer (Sunday is 0)

@return [Integer]

# File lib/calendarium-romanum/day.rb, line 28
def weekday
  date.wday
end
weekday_name() click to toggle source

Weekday as internationalized string

@return [String] @since 0.7.0

# File lib/calendarium-romanum/day.rb, line 36
def weekday_name
  I18n.t(date.wday, scope: 'weekday')
end