Created
March 3, 2016 20:25
-
-
Save denoww/75efd1dc2d6add01a75d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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