Class: CalendariumRomanum::Ordinalizer

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

Overview

Knows how to produce localized ordinals

Class Method Summary collapse

Class Method Details

.english_ordinal(number) ⇒ Object


23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/calendarium-romanum/ordinalizer.rb', line 23

def english_ordinal(number)
  case number
  when 1
    '1st'
  when 2
    '2nd'
  when 3
    '3rd'
  else
    "#{number}th"
  end
end

.ordinal(number, locale: nil) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/calendarium-romanum/ordinalizer.rb', line 7

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

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