Module: NumbersAndWords::I18n::Plurals::Ru

Defined in:
lib/numbers_and_words/i18n/plurals/ru.rb

Constant Summary collapse

RULE =
lambda do |number|
  if one_conditions(number)
    :one
  elsif few_conditions(number)
    :few
  elsif many_conditions(number)
    :many
  else
    :other
  end
end

Class Method Summary collapse

Class Method Details

.few_conditions(number) ⇒ Object


25
26
27
28
# File 'lib/numbers_and_words/i18n/plurals/ru.rb', line 25

def few_conditions(number)
  [2, 3, 4].include?(number % 10) &&
    ![12, 13, 14].include?(number % 100)
end

.many_conditions(number) ⇒ Object


30
31
32
33
34
# File 'lib/numbers_and_words/i18n/plurals/ru.rb', line 30

def many_conditions(number)
  (number % 10).zero? ||
    [5, 6, 7, 8, 9].include?(number % 10) ||
    [11, 12, 13, 14].include?(number % 100)
end

.one_conditions(number) ⇒ Object


21
22
23
# File 'lib/numbers_and_words/i18n/plurals/ru.rb', line 21

def one_conditions(number)
  number % 10 == 1 && number % 100 != 11
end