Class: CalendariumRomanum::Ordinalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/calendarium-romanum/ordinalizer.rb

Overview

Knows how to produce localized ordinals.

Used by Temporale for building names of Sundays and ferials.

Class Method Summary collapse

Class Method Details

.ordinal(number, locale: nil) ⇒ String, Integer

Returns ordinal, or unchanged number if Ordinalizer cannot build ordinals for the given locale.

Parameters:

  • number (Integer)

    number to build ordinal for

  • locale (Symbol, nil) (defaults to: nil)

    locale; I18n.locale (i.e. the ‘i18n` gem’s current locale) is used if not provided

Returns:

  • (String, Integer)

    ordinal, or unchanged number if Ordinalizer cannot build ordinals for the given locale



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/calendarium-romanum/ordinalizer.rb', line 16

def ordinal(number, locale: nil)
  locale ||= I18n.locale

  case locale
  when :cs
    "#{number}."
  when :en
    english_ordinal(number)
  when :fr
    french_ordinal(number)
  when :la, :it
    RomanNumerals.to_roman number
  else
    number
  end
end