Sha256: 2462ab8d44942d2a9d6e4cfcf89a296b5230172a035496ac0f5b00e3ffc56f4c
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
module AccentBuster::StringExtension # @deprecated Use [Buster] or include [AccentBuster] to use #buster method refine String do ACCENT_DOWNCASE = "áéíóúâêîôûäëïöüãõñç" NO_ACCENT_DOWNCASE = "aeiouaeiouaeiouaonc" ACCENT_UPCASE = "ÁÉÍÓÚÂÊÎÔÛÄËÏÖÜÃÕÑÇ" NO_ACCENT_UPCASE = "AEIOUAEIOUAEIOUAONC" # Convert diacritics chars to their non-diacritic equivalents. # # Works for latin languages only. # # Returns a copy of the string with diacritics removed. def accent_buster self.tr(ACCENT_DOWNCASE + ACCENT_UPCASE, NO_ACCENT_DOWNCASE + NO_ACCENT_UPCASE) end # Convert diacritics chars to their non-diacritic equivalents. # # Works for latin languages only. # # Convert the string in place. # # Returns the string or nil if no changes were made. def accent_buster! self.tr!(ACCENT_DOWNCASE + ACCENT_UPCASE, NO_ACCENT_DOWNCASE + NO_ACCENT_UPCASE) end def downcase super.tr(ACCENT_UPCASE, ACCENT_DOWNCASE) end def downcase! super self.tr!(ACCENT_UPCASE, ACCENT_DOWNCASE) end def upcase super.tr(ACCENT_DOWNCASE, ACCENT_UPCASE) end def upcase! super self.tr!(ACCENT_DOWNCASE, ACCENT_UPCASE) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
accent-buster-2.0.0 | lib/accent-buster/string_extension.rb |