Class: CalendariumRomanum::Rank
- Inherits:
-
Object
- Object
- CalendariumRomanum::Rank
- Includes:
- Comparable
- Defined in:
- lib/calendarium-romanum/rank.rb
Instance Attribute Summary collapse
-
#priority ⇒ Object
(also: #to_f)
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #desc ⇒ Object
- #feast? ⇒ Boolean
- #ferial? ⇒ Boolean
-
#initialize(priority = nil, desc = nil, short_desc = nil) ⇒ Rank
constructor
A new instance of Rank.
- #memorial? ⇒ Boolean
- #short_desc ⇒ Object
- #solemnity? ⇒ Boolean
- #sunday? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(priority = nil, desc = nil, short_desc = nil) ⇒ Rank
Returns a new instance of Rank.
5 6 7 8 9 |
# File 'lib/calendarium-romanum/rank.rb', line 5 def initialize(priority = nil, desc = nil, short_desc = nil) @priority = priority @desc = desc @short_desc = short_desc end |
Instance Attribute Details
#priority ⇒ Object (readonly) Also known as: to_f
Returns the value of attribute priority
11 12 13 |
# File 'lib/calendarium-romanum/rank.rb', line 11 def priority @priority end |
Instance Method Details
#<=>(other) ⇒ Object
29 30 31 |
# File 'lib/calendarium-romanum/rank.rb', line 29 def <=>(other) other.priority <=> priority end |
#desc ⇒ Object
14 15 16 |
# File 'lib/calendarium-romanum/rank.rb', line 14 def desc @desc && I18n.t(@desc) end |
#feast? ⇒ Boolean
41 42 43 |
# File 'lib/calendarium-romanum/rank.rb', line 41 def feast? priority.to_i == 2 end |
#ferial? ⇒ Boolean
49 50 51 52 |
# File 'lib/calendarium-romanum/rank.rb', line 49 def ferial? self == Ranks::FERIAL || self == Ranks::FERIAL_PRIVILEGED end |
#memorial? ⇒ Boolean
45 46 47 |
# File 'lib/calendarium-romanum/rank.rb', line 45 def memorial? priority.to_i == 3 && priority <= 3.12 end |
#short_desc ⇒ Object
25 26 27 |
# File 'lib/calendarium-romanum/rank.rb', line 25 def short_desc @short_desc && I18n.t(@short_desc) end |
#solemnity? ⇒ Boolean
33 34 35 |
# File 'lib/calendarium-romanum/rank.rb', line 33 def solemnity? priority.to_i == 1 end |
#sunday? ⇒ Boolean
37 38 39 |
# File 'lib/calendarium-romanum/rank.rb', line 37 def sunday? self == Ranks::SUNDAY_UNPRIVILEGED end |
#to_s ⇒ Object
18 19 20 21 22 23 |
# File 'lib/calendarium-romanum/rank.rb', line 18 def to_s # 'desc' instead of '@desc' is intentional - # for a good reason we don't present contents of an instance # variable but result of an instance method "#<#{self.class.name} @priority=#{priority} desc=#{desc.inspect}>" end |