Class: Dry::Inflector::Acronyms Private

Inherits:
Object
  • Object
show all
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

Since:

  • 0.1.2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAcronyms

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.

Since:

  • 0.1.2



14
15
16
17
# File 'lib/dry/inflector/acronyms.rb', line 14

def initialize
  @rules = {}
  define_regex_patterns
end

Instance Attribute Details

#regexObject (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.

Since:

  • 0.1.2



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.

Since:

  • 0.1.2



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.

Since:

  • 0.1.2



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