Skip to content

Instantly share code, notes, and snippets.

@denoww
Created March 3, 2016 20:25
Show Gist options
  • Save denoww/75efd1dc2d6add01a75d to your computer and use it in GitHub Desktop.
Save denoww/75efd1dc2d6add01a75d to your computer and use it in GitHub Desktop.
def remover_acentos
return self if self.blank?
texto = self
texto = texto.gsub(/(á|à|ã|â|ä)/, 'a').gsub(/(é|è|ê|ë)/, 'e').gsub(/(í|ì|î|ï)/, 'i').gsub(/(ó|ò|õ|ô|ö)/, 'o').gsub(/(ú|ù|û|ü)/, 'u')
texto = texto.gsub(/(Á|À|Ã|Â|Ä)/, 'A').gsub(/(É|È|Ê|Ë)/, 'E').gsub(/(Í|Ì|Î|Ï)/, 'I').gsub(/(Ó|Ò|Õ|Ô|Ö)/, 'O').gsub(/(Ú|Ù|Û|Ü)/, 'U')
texto = texto.gsub(/ñ/, 'n').gsub(/Ñ/, 'N')
texto = texto.gsub(/ç/, 'c').gsub(/Ç/, 'C')
texto
end
def fileize
remover_acentos.underscore.gsub(" ", "_")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment