class ActiveSupport::Inflector::Inflections

already have been loaded.
pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may
New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the
end
inflect.uncountable “equipment”
inflect.irregular ‘octopus’, ‘octopi’
inflect.singular /^(ox)en/i, ‘1’
inflect.plural /^(ox)$/i, ‘12en’
ActiveSupport::Inflector.inflections do |inflect|
inflection rules. Examples:
A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional

def self.instance

def self.instance
  @__instance__ ||= new
end

def acronym(word)

camelize 'mcdonald' #=> 'McDonald'
underscore 'McDonald' #=> 'mcdonald'
acronym 'McDonald'

camelize 'restful_controller' #=> 'RESTfulController'
camelize 'restful' #=> 'RESTful'
titleize 'RESTfulController' #=> 'RESTful Controller'
underscore 'RESTfulController' #=> 'restful_controller'
underscore 'RESTful' #=> 'restful'
acronym 'RESTful'
Examples:

capitalization. The only restriction is that the word must begin with a capital letter.
`acronym` may be used to specify any word that contains an acronym or otherwise needs to maintain a non-standard

camelize(pluralize('api')) #=> 'APIs'
acronym 'APIs'

camelize(pluralize('api')) #=> 'Apis'
acronym 'API'

acronym as well:
a delimited unit in the pluralized result. To work around this, you must specify the pluralized form as an
Note: Acronyms that are passed to `pluralize` will no longer be recognized, since the acronym will not occur as

underscore 'HTTPS' #=> 'https'
camelize 'https' #=> 'HTTPS'
acronym 'HTTPS'

underscore 'HTTPS' #=> 'http_s', not 'https'
camelize 'https' #=> 'Https', not 'HTTPs'
camelize 'my_http_delimited' #=> 'MyHTTPDelimited'
acronym 'HTTP'

The acronym, however, must occur as a delimited unit and not be part of another word for conversions to recognize it:

underscore 'MyHTML' #=> 'my_html'
camelize 'html' #=> 'HTML'
titleize 'html' #=> 'HTML'
acronym 'HTML'
Examples:

convert the acronym into a non-delimited single lowercase word when passed to +underscore+.
A camelized string that contains the acronym will maintain the acronym when titleized or humanized, and will
string that contains the acronym will retain the acronym when passed to `camelize`, `humanize`, or `titleize`.
Specifies a new acronym. An acronym must be specified as it will appear in a camelized string. An underscore
def acronym(word)
  @acronyms[word.downcase] = word
  @acronym_regex = /#{@acronyms.values.join("|")}/
end

def clear(scope = :all)

clear :plurals
clear :all
Examples:

:singulars, :uncountables, :humans.
Give the scope as a symbol of the inflection type, the options are: :plurals,
Clears the loaded inflections within a given scope (default is :all).
def clear(scope = :all)
  case scope
    when :all
      @plurals, @singulars, @uncountables, @humans = [], [], [], []
    else
      instance_variable_set "@#{scope}", []
  end
end

def human(rule, replacement)

human "legacy_col_person_name", "Name"
human /_cnt$/i, '\1_count'
Examples:

When a string is used, the human form should be specified as desired (example: 'The name', not 'the_name')
When using a regular expression based replacement, the normal humanize formatting is called after the replacement.
Specifies a humanized form of a string by a regular expression rule or by a string mapping.
def human(rule, replacement)
  @humans.insert(0, [rule, replacement])
end

def initialize

def initialize
  @plurals, @singulars, @uncountables, @humans, @acronyms, @acronym_regex = [], [], [], [], {}, /(?=a)b/
end

def irregular(singular, plural)

irregular 'person', 'people'
irregular 'octopus', 'octopi'
Examples:

for strings, not regular expressions. You simply pass the irregular in singular and plural form.
Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used
def irregular(singular, plural)
  @uncountables.delete(singular)
  @uncountables.delete(plural)
  if singular[0,1].upcase == plural[0,1].upcase
    plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
    plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + plural[1..-1])
    singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
  else
    plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
    plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
    plural(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
    plural(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
    singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
    singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
  end
end

def plural(rule, replacement)

The replacement should always be a string that may include references to the matched data from the rule.
Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
def plural(rule, replacement)
  @uncountables.delete(rule) if rule.is_a?(String)
  @uncountables.delete(replacement)
  @plurals.insert(0, [rule, replacement])
end

def singular(rule, replacement)

The replacement should always be a string that may include references to the matched data from the rule.
Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression.
def singular(rule, replacement)
  @uncountables.delete(rule) if rule.is_a?(String)
  @uncountables.delete(replacement)
  @singulars.insert(0, [rule, replacement])
end

def uncountable(*words)

uncountable %w( money information rice )
uncountable "money", "information"
uncountable "money"
Examples:

Add uncountable words that shouldn't be attempted inflected.
def uncountable(*words)
  (@uncountables << words).flatten!
end