Class: CalendariumRomanum::Rank

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

Overview

Celebration rank

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.

Parameters:

  • priority (Float, nil) (defaults to: nil)

    number in the Table of Liturgical Days

  • desc (String, nil) (defaults to: nil)

    full description (translation string identifier)

  • short_desc (String, nil) (defaults to: nil)

    short rank name (translation string identifier)


11
12
13
14
15
# File 'lib/calendarium-romanum/rank.rb', line 11

def initialize(priority = nil, desc = nil, short_desc = nil)
  @priority = priority
  @desc = desc
  @short_desc = short_desc
end

Instance Attribute Details

#priorityFloat? (readonly) Also known as: to_f

Returns:

  • (Float, nil)

18
19
20
# File 'lib/calendarium-romanum/rank.rb', line 18

def priority
  @priority
end

Instance Method Details

#<=>(other) ⇒ Object


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

def <=>(other)
  other.priority <=> priority
end

#descString?

Full description - internationalized human-readable string.

Returns:

  • (String, nil)

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

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

#feast?Boolean

Returns:

  • (Boolean)

61
62
63
# File 'lib/calendarium-romanum/rank.rb', line 61

def feast?
  priority.to_i == 2
end

#ferial?Boolean

Returns:

  • (Boolean)

Since:

  • 0.6.0


72
73
74
75
# File 'lib/calendarium-romanum/rank.rb', line 72

def ferial?
  self == Ranks::FERIAL ||
    self == Ranks::FERIAL_PRIVILEGED
end

#memorial?Boolean

Returns:

  • (Boolean)

66
67
68
# File 'lib/calendarium-romanum/rank.rb', line 66

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

#short_descString?

Short name - internationalized human-readable string.

Returns:

  • (String, nil)

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

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

#solemnity?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'lib/calendarium-romanum/rank.rb', line 50

def solemnity?
  priority.to_i == 1
end

#sunday?Boolean

Returns:

  • (Boolean)

Since:

  • 0.6.0


56
57
58
# File 'lib/calendarium-romanum/rank.rb', line 56

def sunday?
  self == Ranks::SUNDAY_UNPRIVILEGED
end

#to_sString

String representation mostly for debugging purposes.

Returns:

  • (String)

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

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