class Frontline::Inflector::Inflections

Attributes

plurals[R]
singulars[R]
uncountables[R]

Public Class Methods

instance(locale = :en) click to toggle source
# File lib/frontline/inflect.rb, line 8
def self.instance(locale = :en)
  @__instance__[locale] ||= new
end
new() click to toggle source
# File lib/frontline/inflect.rb, line 14
def initialize
  @plurals, @singulars, @uncountables = [], [], []
end

Public Instance Methods

plural(rule, replacement) click to toggle source

Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression. The replacement should always be a string that may include references to the matched data from the rule.

# File lib/frontline/inflect.rb, line 22
def plural(rule, replacement)
  @uncountables.delete(rule) if rule.is_a?(String)
  @uncountables.delete(replacement)
  @plurals.unshift([rule, replacement])
end
singular(rule, replacement) click to toggle source

Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression. The replacement should always be a string that may include references to the matched data from the rule.

# File lib/frontline/inflect.rb, line 32
def singular(rule, replacement)
  @uncountables.delete(rule) if rule.is_a?(String)
  @uncountables.delete(replacement)
  @singulars.unshift([rule, replacement])
end
uncountable(*words) click to toggle source

Add uncountable words that shouldn't be attempted inflected.

uncountable 'money'
uncountable 'money', 'information'
uncountable %w( money information rice )
# File lib/frontline/inflect.rb, line 43
def uncountable(*words)
  (@uncountables << words).flatten!
end