Class: Dry::Inflector::Rules Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/inflector/rules.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A set of inflection rules

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initializeRules

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Rules.

Since:

  • 0.1.0



12
13
14
# File 'lib/dry/inflector/rules.rb', line 12

def initialize
  @rules = []
end

Instance Method Details

#apply_to(word) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



18
19
20
21
22
23
24
25
# File 'lib/dry/inflector/rules.rb', line 18

def apply_to(word)
  matching_rule = @rules.find { |rule, _replacement| rule.match? word }
  if matching_rule
    word.gsub(matching_rule[0], matching_rule[1])
  else
    word
  end.dup
end

#insert(index, array) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



29
30
31
# File 'lib/dry/inflector/rules.rb', line 29

def insert(index, array)
  @rules.insert(index, array)
end