Class: CalendariumRomanum::Day
- Inherits:
-
Object
- Object
- CalendariumRomanum::Day
- Defined in:
- lib/calendarium-romanum/day.rb
Overview
Information on one particular day of the liturgical year
Instance Attribute Summary collapse
-
#celebrations ⇒ Array<Celebration>
readonly
List of celebrations for the given day.
- #date ⇒ Date readonly
- #season ⇒ Season readonly
-
#season_week ⇒ Integer
readonly
Week of the season.
-
#vespers ⇒ Celebration?
readonly
Celebration whose first Vespers are celebrated in place of Vespers of the day’s Celebration(s).
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(date: nil, season: nil, season_week: nil, celebrations: nil, vespers: nil) ⇒ Day
constructor
Note: despite of all constructor arguments being nullable, instances returned by Calendar always have all of them set, the only exception being
vespers
. -
#to_s ⇒ String
String representation of the instance listing it’s contents.
-
#vespers_from_following? ⇒ Boolean
Are the day’s Vespers suppressed in favour of first Vespers of a Sunday or solemnity?.
-
#weekday ⇒ Integer
Weekday as integer (Sunday is 0).
-
#weekday_name ⇒ String
Weekday as internationalized string.
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
.
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
#celebrations ⇒ Array<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.
55 56 57 |
# File 'lib/calendarium-romanum/day.rb', line 55 def celebrations @celebrations end |
#date ⇒ Date (readonly)
23 24 25 |
# File 'lib/calendarium-romanum/day.rb', line 23 def date @date end |
#season ⇒ Season (readonly)
41 42 43 |
# File 'lib/calendarium-romanum/day.rb', line 41 def season @season end |
#season_week ⇒ Integer (readonly)
Week of the season
46 47 48 |
# File 'lib/calendarium-romanum/day.rb', line 46 def season_week @season_week end |
#vespers ⇒ Celebration? (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).
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_s ⇒ String
String representation of the instance listing it’s contents. Intended mostly for debugging purposes.
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?
81 82 83 |
# File 'lib/calendarium-romanum/day.rb', line 81 def vespers_from_following? !vespers.nil? end |
#weekday ⇒ Integer
Weekday as integer (Sunday is 0)
28 29 30 |
# File 'lib/calendarium-romanum/day.rb', line 28 def weekday date.wday end |
#weekday_name ⇒ String
Weekday as internationalized string
36 37 38 |
# File 'lib/calendarium-romanum/day.rb', line 36 def weekday_name I18n.t(date.wday, scope: 'weekday') end |