Class: Dry::Inflector::Acronyms Private
- Inherits:
-
Object
- Object
- Dry::Inflector::Acronyms
- Defined in:
- lib/dry/inflector/acronyms.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 acronyms
Instance Attribute Summary collapse
- #regex ⇒ Object readonly private
Instance Method Summary collapse
- #add(rule, replacement) ⇒ Object private
- #apply_to(word, capitalize: true) ⇒ Object private
-
#initialize ⇒ Acronyms
constructor
private
A new instance of Acronyms.
Constructor Details
#initialize ⇒ Acronyms
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 Acronyms.
14 15 16 17 |
# File 'lib/dry/inflector/acronyms.rb', line 14 def initialize @rules = {} define_regex_patterns end |
Instance Attribute Details
#regex ⇒ Object (readonly)
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.
10 11 12 |
# File 'lib/dry/inflector/acronyms.rb', line 10 def regex @regex end |
Instance Method Details
#add(rule, replacement) ⇒ 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.
27 28 29 30 |
# File 'lib/dry/inflector/acronyms.rb', line 27 def add(rule, replacement) @rules[rule] = replacement define_regex_patterns end |
#apply_to(word, capitalize: true) ⇒ 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.
21 22 23 |
# File 'lib/dry/inflector/acronyms.rb', line 21 def apply_to(word, capitalize: true) @rules[word.downcase] || (capitalize ? word.capitalize : word) end |