class String

String extensions.

Constants

ACCENTMAP

Public Instance Methods

unaccent() click to toggle source

Replace a string's accented characters with unaccented characters.

@example

s = "Å Ç ß"
s.unaccent = > "AA C ss"

@return [String] a string that has no accents

# File lib/sixarm_ruby_unaccent/string.rb, line 15
def unaccent
  unaccent_via_scan
end
unaccent_via_each_char() click to toggle source

Replace a string's accented characters with unaccented characters, by using string `#each_char` to iterate on characters.

@example

s = "Å Ç ß"
s.unaccent_via_each_char = > "AA C ss"

@return [String] a string that has no accents

# File lib/sixarm_ruby_unaccent/string.rb, line 41
def unaccent_via_each_char
  result=""; each_char{|c| result += (ACCENTMAP[c] || c) }; result
end
unaccent_via_scan() click to toggle source

Replace a string's accented characters with unaccented characters, by using string `#scan` to iterate on characters.

@example

s = "Å Ç ß"
s.unaccent_via_scan = > "AA C ss"

@return [String] a string that has no accents

# File lib/sixarm_ruby_unaccent/string.rb, line 28
def unaccent_via_scan
  result=""; scan(/./){|c| result += (ACCENTMAP[c] || c) }; result
end
unaccent_via_split_map() click to toggle source

Replace a string's accented characters with unaccented characters, by using string `#split` and `#map` to iterate on characters.

@example

s = "Å Ç ß"
s.unaccent_via_split_map = > "AA C ss"

@return [String] a string that has no accents

# File lib/sixarm_ruby_unaccent/string.rb, line 54
def unaccent_via_split_map
  split(//u).map{|c| ACCENTMAP[c] || c }.join("")
end