lib/accent-buster/string_extension.rb in accent-buster-0.9.0 vs lib/accent-buster/string_extension.rb in accent-buster-1.0.0
- old
+ new
@@ -1,21 +1,23 @@
-class String
- # 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('áéíóúâêîôûäëïöüãõñçÁÉÍÓÚÂÊÎÔÛÄËÏÖÜÃÕÑÇ', 'aeiouaeiouaeiouaoncAEIOUAEIOUAEIOUAONC')
- end
+module AccentBuster::StringExtension
+ refine String do
+ # 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('áéíóúâêîôûäëïöüãõñçÁÉÍÓÚÂÊÎÔÛÄËÏÖÜÃÕÑÇ', 'aeiouaeiouaeiouaoncAEIOUAEIOUAEIOUAONC')
+ 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!('áéíóúâêîôûäëïöüãõñçÁÉÍÓÚÂÊÎÔÛÄËÏÖÜÃÕÑÇ', 'aeiouaeiouaeiouaoncAEIOUAEIOUAEIOUAONC')
+ # 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!('áéíóúâêîôûäëïöüãõñçÁÉÍÓÚÂÊÎÔÛÄËÏÖÜÃÕÑÇ', 'aeiouaeiouaeiouaoncAEIOUAEIOUAEIOUAONC')
+ end
end
end