Class: CalendariumRomanum::Rank
- Inherits:
-
Object
- Object
- CalendariumRomanum::Rank
- Includes:
- RankPredicates, Comparable
- Defined in:
- lib/calendarium-romanum/rank.rb
Overview
Celebration rank
Instance Attribute Summary collapse
- #priority ⇒ Float? (also: #to_f) readonly
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#desc ⇒ String?
Full description - internationalized human-readable string.
-
#initialize(priority = nil, desc = nil, short_desc = nil) ⇒ Rank
constructor
A new instance of Rank.
-
#short_desc ⇒ String?
Short name - internationalized human-readable string.
-
#succ ⇒ Rank
Returns the next higher rank.
-
#to_s ⇒ String
String representation mostly for debugging purposes.
Methods included from RankPredicates
#feast?, #ferial?, #memorial?, #obligatory_memorial?, #optional_memorial?, #solemnity?, #sunday?
Constructor Details
#initialize(priority = nil, desc = nil, short_desc = nil) ⇒ Rank
Returns a new instance of Rank.
12 13 14 15 16 |
# File 'lib/calendarium-romanum/rank.rb', line 12 def initialize(priority = nil, desc = nil, short_desc = nil) @priority = priority @desc = desc @short_desc = short_desc end |
Instance Attribute Details
#priority ⇒ Float? (readonly) Also known as: to_f
19 20 21 |
# File 'lib/calendarium-romanum/rank.rb', line 19 def priority @priority end |
Instance Method Details
#<=>(other) ⇒ Object
46 47 48 |
# File 'lib/calendarium-romanum/rank.rb', line 46 def <=>(other) other.priority <=> priority end |
#desc ⇒ String?
Full description - internationalized human-readable string.
25 26 27 |
# File 'lib/calendarium-romanum/rank.rb', line 25 def desc @desc && I18n.t(@desc) end |
#short_desc ⇒ String?
Short name - internationalized human-readable string.
42 43 44 |
# File 'lib/calendarium-romanum/rank.rb', line 42 def short_desc @short_desc && I18n.t(@short_desc) end |
#succ ⇒ Rank
Returns the next higher rank.
Allows constructing ranges of ranks.
56 57 58 59 60 61 62 |
# File 'lib/calendarium-romanum/rank.rb', line 56 def succ all = CR::Ranks.all index = all.index(self) raise StopIteration.new if index == 0 all[index - 1] end |
#to_s ⇒ String
String representation mostly for debugging purposes.
32 33 34 35 36 37 |
# File 'lib/calendarium-romanum/rank.rb', line 32 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 |