Module: Rich::Pluralization::Inflector

Extended by:
Inflector
Included in:
Inflector
Defined in:
lib/rich/pluralization/inflector.rb,
lib/rich/pluralization/inflector/inflections.rb

Defined Under Namespace

Classes: Inflections

Instance Method Summary collapse

Instance Method Details

#inflections(locale = nil) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/rich/pluralization/inflector.rb', line 7

def inflections(locale = nil)
  Inflections.instance.locale = locale
  if block_given?
    yield Inflections.instance
  else
    Inflections.instance
  end
end

#pluralize(word, count = nil) ⇒ Object



20
21
22
# File 'lib/rich/pluralization/inflector.rb', line 20

def pluralize(word, count = nil)
  count == 1 ? singularize(word) : (in_english? ? word.pluralize.cp_case(word) : inflect(:plurals, word))
end

#singularize(word) ⇒ Object



16
17
18
# File 'lib/rich/pluralization/inflector.rb', line 16

def singularize(word)
  in_english? ? word.singularize.cp_case(word) : inflect(:singulars, word)
end