Module: Identificamex::Nombre::Mayusculas

Included in:
NombreCompleto, NormalizadorNombre, RazonSocial
Defined in:
lib/identificamex/nombre/mayusculas.rb

Instance Method Summary collapse

Instance Method Details

#hash_vocalesObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/identificamex/nombre/mayusculas.rb', line 18

def hash_vocales
  @hash_vocales ||= {'á' => 'a',
                     'é' => 'e',
                     'í' => 'i',
                     'ó' => 'o',
                     'ú' => 'u',
                     'ü' => 'u',
                     'Á' => 'A',
                     'É' => 'E',
                     'Í' => 'I',
                     'Ó' => 'O',
                     'Ú' => 'U',
                     'Ü' => 'U'}
end

#mayusculas(str) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/identificamex/nombre/mayusculas.rb', line 5

def mayusculas(str)
  return if str.nil?
  str
  .gsub(/[ÁÉÍÓÚÜáéíóúü]/, hash_vocales)
  .upcase
  .gsub(/ñ/, 'Ñ')
  .gsub(/,/, '')
  .gsub(/'/, '')
  .gsub(/\./, ' ')
  .squeeze(' ')
  .strip
end