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 (Fixnum, nil) (defaults to: nil)
  • celebrations (Array<Celebration>, nil) (defaults to: nil)
  • vespers (Celebration, nil) (defaults to: nil)


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

#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:



57
58
59
# File 'lib/calendarium-romanum/day.rb', line 57

def celebrations
  @celebrations
end

#dateDate (readonly)

Returns:

  • (Date)


25
26
27
# File 'lib/calendarium-romanum/day.rb', line 25

def date
  @date
end

#seasonSeason (readonly)

Returns:



43
44
45
# File 'lib/calendarium-romanum/day.rb', line 43

def season
  @season
end

#season_weekFixnum (readonly)

Week of the season

Returns:

  • (Fixnum)


48
49
50
# File 'lib/calendarium-romanum/day.rb', line 48

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



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_sString

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

Returns:

  • (String)

Since:

  • 0.7.0



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?

Returns:

  • (Boolean)


83
84
85
# File 'lib/calendarium-romanum/day.rb', line 83

def vespers_from_following?
  !vespers.nil?
end

#weekdayFixnum

Weekday as integer (Sunday is 0)

Returns:

  • (Fixnum)


30
31
32
# File 'lib/calendarium-romanum/day.rb', line 30

def weekday
  date.wday
end

#weekday_nameString

Weekday as internationalized string

Returns:

  • (String)

Since:

  • 0.7.0



38
39
40
# File 'lib/calendarium-romanum/day.rb', line 38

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