Module: Pagy::I18n::P11n::EastSlavic

Defined in:
lib/pagy/modules/i18n/p11n/east_slavic.rb

Class Method Summary collapse

Class Method Details

.plural_for(n = 0) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pagy/modules/i18n/p11n/east_slavic.rb', line 9

def plural_for(n = 0)
  mod10  = n % 10
  mod100 = n % 100

  case
  when mod10 == 1 && mod100 != 11
    :one
  when (2..4).to_a.include?(mod10) && !(12..14).to_a.include?(mod100)
    :few
  when mod10 == 0 || (5..9).to_a.include?(mod10) || (11..14).to_a.include?(mod100) # rubocop:disable Style/NumericPredicate
    :many
  else
    :other
  end
end