Class: CalendariumRomanum::Day

Inherits:
Object
  • Object
show all
Defined in:
lib/calendarium-romanum/day.rb

Overview

Information on one particular day of the liturgical year

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date: nil, season: nil, season_week: nil, celebrations: nil, vespers: nil) ⇒ Day

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

Parameters:

  • date (Date, nil) (defaults to: nil)
  • season (Season, nil) (defaults to: nil)
  • season_week (Integer, nil) (defaults to: nil)
  • celebrations (Array<Celebration>, nil) (defaults to: nil)
  • vespers (Celebration, nil) (defaults to: nil)


14
15
16
17
18
19
20
# 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

Instance Attribute Details

#celebrationsArray<Celebration> (readonly)

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.

Returns:



55
56
57
# File 'lib/calendarium-romanum/day.rb', line 55

def celebrations
  @celebrations
end

#dateDate (readonly)

Returns:

  • (Date)


23
24
25
# File 'lib/calendarium-romanum/day.rb', line 23

def date
  @date
end

#seasonSeason (readonly)

Returns:



41
42
43
# File 'lib/calendarium-romanum/day.rb', line 41

def season
  @season
end

#season_weekInteger (readonly)

Week of the season

Returns:

  • (Integer)


46
47
48
# File 'lib/calendarium-romanum/day.rb', line 46

def season_week
  @season_week
end

#vespersCelebration? (readonly)

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

Returns:

Since:

  • 0.5.0



66
67
68
# File 'lib/calendarium-romanum/day.rb', line 66

def vespers
  @vespers
end

Instance Method Details

#==(other) ⇒ Object



68
69
70
71
72
73
74
75
# 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_sString

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

Returns:

  • (String)

Since:

  • 0.7.0



90
91
92
93
94
95
96
97
# 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?Boolean

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

Returns:

  • (Boolean)


81
82
83
# File 'lib/calendarium-romanum/day.rb', line 81

def vespers_from_following?
  !vespers.nil?
end

#weekdayInteger

Weekday as integer (Sunday is 0)

Returns:

  • (Integer)


28
29
30
# File 'lib/calendarium-romanum/day.rb', line 28

def weekday
  date.wday
end

#weekday_nameString

Weekday as internationalized string

Returns:

  • (String)

Since:

  • 0.7.0



36
37
38
# File 'lib/calendarium-romanum/day.rb', line 36

def weekday_name
  I18n.t(date.wday, scope: 'weekday')
end