Class: Lotus::Utils::Inflector::IrregularRules Private
- Inherits:
-
Object
- Object
- Lotus::Utils::Inflector::IrregularRules
- Defined in:
- lib/lotus/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.
16 17 18 |
# File 'lib/lotus/utils/inflector.rb', line 16 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.
28 29 30 31 |
# File 'lib/lotus/utils/inflector.rb', line 28 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.
22 23 24 |
# File 'lib/lotus/utils/inflector.rb', line 22 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.
35 36 37 38 39 40 |
# File 'lib/lotus/utils/inflector.rb', line 35 def apply(string) key = string.downcase result = @rules[key] || @rules.rassoc(key).last string[0] + result[1..-1] end |