Class: CalendariumRomanum::Rank

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

Overview

Celebration rank

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

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)



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

#priorityFloat? (readonly) Also known as: to_f

Returns:

  • (Float, nil)


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

#descString?

Full description - internationalized human-readable string.

Returns:

  • (String, nil)


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

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

#short_descString?

Short name - internationalized human-readable string.

Returns:

  • (String, nil)


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

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

#succRank

Returns the next higher rank.

Allows constructing ranges of ranks.

Returns:

Raises:

  • (StopIteration)

Since:

  • 0.8.0



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_sString

String representation mostly for debugging purposes.

Returns:

  • (String)


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