Class: Hanami::Utils::Inflector::IrregularRules Private
- Inherits:
-
Object
- Object
- Hanami::Utils::Inflector::IrregularRules
- Defined in:
- lib/hanami/utils/inflector.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.
Rules for irregular plurals
Instance Method Summary collapse
- #===(other) ⇒ Object private
- #add(key, value) ⇒ Object private
- #apply(string) ⇒ Object private
-
#initialize(rules) ⇒ IrregularRules
constructor
private
A new instance of IrregularRules.
Constructor Details
#initialize(rules) ⇒ IrregularRules
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 IrregularRules.
17 18 19 |
# File 'lib/hanami/utils/inflector.rb', line 17 def initialize(rules) @rules = rules end |
Instance Method Details
#===(other) ⇒ 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 32 |
# File 'lib/hanami/utils/inflector.rb', line 29 def ===(other) key = other.downcase @rules.key?(key) || @rules.value?(key) end |
#add(key, value) ⇒ 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.
23 24 25 |
# File 'lib/hanami/utils/inflector.rb', line 23 def add(key, value) @rules[key.downcase] = value.downcase end |
#apply(string) ⇒ 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.
36 37 38 39 40 41 |
# File 'lib/hanami/utils/inflector.rb', line 36 def apply(string) key = string.downcase result = @rules[key] || @rules.rassoc(key).last string[0] + result[1..-1] end |