Class: Hundredth
- Inherits:
-
Object
- Object
- Hundredth
- Defined in:
- lib/hundredth.rb
Overview
Writes out ordinals to 100
Class Method Summary collapse
- .default_locale ⇒ Object
- .default_locale=(value) ⇒ Object
- .ordinal(number, locale = Thread.current[:locale] || I18n.config.default_locale) ⇒ Object
Class Method Details
.default_locale ⇒ Object
28 29 30 |
# File 'lib/hundredth.rb', line 28 def default_locale I18n.config.default_locale end |
.default_locale=(value) ⇒ Object
32 33 34 |
# File 'lib/hundredth.rb', line 32 def default_locale=(value) I18n.config.default_locale = value end |
.ordinal(number, locale = Thread.current[:locale] || I18n.config.default_locale) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hundredth.rb', line 14 def ordinal(number, locale = Thread.current[:locale] || I18n.config.default_locale) begin number = number.to_int rescue StandardError raise HundredthError, I18n.t('hundredth.not_an_integer', number) end raise HundredthError, I18n.t('hundredth.less_than_one', number) if number < 1 return beyond100(number, locale) if number > 100 I18n.t 'hundredth.num_' + number.to_s, locale: locale end |