Module: Hayfork::Unaccent
- Included in:
- Hayfork
- Defined in:
- lib/hayfork/unaccent.rb
Constant Summary collapse
- RULES =
Use Postgres’s own rules so this method’s behavior matches Postgres’s ‘unaccent` function.
Hash[File.read(File.("../../../postgres/unaccent.rules", __FILE__)).scan(/^([^\t]+)\t(.*)$/)].freeze
Instance Method Summary collapse
Instance Method Details
#unaccent(string) ⇒ Object
4 5 6 |
# File 'lib/hayfork/unaccent.rb', line 4 def unaccent(string) string.each_char.map { |char| RULES.fetch(char, char) }.join end |