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 ⇒ Fixnum
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 ⇒ Fixnum
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
.
16 17 18 19 20 21 22 |
# File 'lib/calendarium-romanum/day.rb', line 16 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.
57 58 59 |
# File 'lib/calendarium-romanum/day.rb', line 57 def celebrations @celebrations end |
#date ⇒ Date (readonly)
25 26 27 |
# File 'lib/calendarium-romanum/day.rb', line 25 def date @date end |
#season ⇒ Season (readonly)
43 44 45 |
# File 'lib/calendarium-romanum/day.rb', line 43 def season @season end |
#season_week ⇒ Fixnum (readonly)
Week of the season
48 49 50 |
# File 'lib/calendarium-romanum/day.rb', line 48 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).
68 69 70 |
# File 'lib/calendarium-romanum/day.rb', line 68 def vespers @vespers end |
Instance Method Details
#==(other) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/calendarium-romanum/day.rb', line 70 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.
92 93 94 95 96 97 98 99 |
# File 'lib/calendarium-romanum/day.rb', line 92 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?
83 84 85 |
# File 'lib/calendarium-romanum/day.rb', line 83 def vespers_from_following? !vespers.nil? end |
#weekday ⇒ Fixnum
Weekday as integer (Sunday is 0)
30 31 32 |
# File 'lib/calendarium-romanum/day.rb', line 30 def weekday date.wday end |
#weekday_name ⇒ String
Weekday as internationalized string
38 39 40 |
# File 'lib/calendarium-romanum/day.rb', line 38 def weekday_name I18n.t(date.wday, scope: 'weekday') end |