Class: CalendariumRomanum::Rank

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/calendarium-romanum/rank.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#priorityObject (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

#descObject



14
15
16
# File 'lib/calendarium-romanum/rank.rb', line 14

def desc
  @desc && I18n.t(@desc)
end

#feast?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/calendarium-romanum/rank.rb', line 41

def feast?
  priority.to_i == 2
end

#ferial?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


45
46
47
# File 'lib/calendarium-romanum/rank.rb', line 45

def memorial?
  priority.to_i == 3 && priority <= 3.12
end

#short_descObject



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

def short_desc
  @short_desc && I18n.t(@short_desc)
end

#solemnity?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/calendarium-romanum/rank.rb', line 33

def solemnity?
  priority.to_i == 1
end

#sunday?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/calendarium-romanum/rank.rb', line 37

def sunday?
  self == Ranks::SUNDAY_UNPRIVILEGED
end

#to_sObject



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