Class: Dry::Inflector::Rules Private
- Inherits:
-
Object
- Object
- Dry::Inflector::Rules
- 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
Instance Method Summary collapse
- #apply_to(word) ⇒ Object private
-
#initialize ⇒ Rules
constructor
private
A new instance of Rules.
- #insert(index, array) ⇒ Object private
Constructor Details
#initialize ⇒ Rules
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.
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.
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.
29 30 31 |
# File 'lib/dry/inflector/rules.rb', line 29 def insert(index, array) @rules.insert(index, array) end |