Sha256: 5f6fc958404ae546e7ed4a4a3293a6f5a11a37727f30638bd9064f50a25016ce

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

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

  # 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
accent-buster-0.9.0 lib/accent-buster/string_extension.rb