class Dry::Inflector::Inflections

@since 0.1.0
Inflections

def self.build(&blk)

Other tags:
    Api: - private

Other tags:
    Since: - 0.1.0

Parameters:
  • blk (Proc) -- the optional, custom rules
def self.build(&blk)
  new do |inflect|
    Defaults.call(inflect)
    blk.call(inflect) if block_given?
  end
end

def acronym(*words)

Other tags:
    Since: - 0.1.2

Parameters:
  • words (Array) -- a list of acronyms
def acronym(*words)
  words.each { |word| @acronyms.add(word.downcase, word) }
end

def add_irregular(rule, replacement, target)

Other tags:
    Api: - private

Other tags:
    Since: - 0.1.0

Returns:
  • (undefined) -

Parameters:
  • replacement (String) -- the replacement
  • rule (String) -- the rule
def add_irregular(rule, replacement, target)
  head, *tail = rule.chars.to_a
  rule(/(#{head})#{tail.join}\z/i, "\\1#{replacement[1..]}", target)
end

def human(rule, replacement)

Other tags:
    Since: - 0.1.0

Parameters:
  • replacement (String) -- the replacement
  • rule (String, Regexp) -- the rule
def human(rule, replacement)
  humans.insert(0, [rule, replacement])
end

def initialize

Other tags:
    Api: - private

Other tags:
    Since: - 0.1.0

Other tags:
    Yieldparam: -

Returns:
  • (Dry::Inflector::Inflections) -
def initialize
  @plurals      = Rules.new
  @singulars    = Rules.new
  @humans       = Rules.new
  @uncountables = Set[]
  @acronyms     = Acronyms.new
  yield(self) if block_given?
end

def irregular(singular, plural)

Other tags:
    Since: - 0.1.0

Parameters:
  • plural (String) -- the plural
  • singular (String) -- the singular
def irregular(singular, plural)
  uncountables.delete(singular)
  uncountables.delete(plural)
  add_irregular(singular, plural, plurals)
  add_irregular(plural, singular, singulars)
end

def plural(rule, replacement)

Other tags:
    Since: - 0.1.0

Parameters:
  • replacement (String) -- the replacement
  • rule (String, Regexp) -- the rule
def plural(rule, replacement)
  rule(rule, replacement, plurals)
end

def rule(rule, replacement, target)

Other tags:
    Api: - private

Other tags:
    Since: - 0.1.0

Parameters:
  • target (Dry::Inflector::Rules) -- the target
  • replacement (String, Regexp) -- the replacement
  • rule (String, Regexp) -- the rule
def rule(rule, replacement, target)
  uncountables.delete(rule)
  uncountables.delete(replacement)
  target.insert(0, [rule, replacement])
end

def singular(rule, replacement)

Other tags:
    Since: - 0.1.0

Parameters:
  • replacement (String) -- the replacement
  • rule (String, Regexp) -- the rule
def singular(rule, replacement)
  rule(rule, replacement, singulars)
end

def uncountable(*words)

Other tags:
    Since: - 0.1.0

Parameters:
  • words (Enumerable) --
def uncountable(*words)
  uncountables.merge(words.flatten)
end