Skip to content
Browse files

Bugfixes.

  • Loading branch information...
1 parent e3ac40a commit b961283a67a22b2fe863a5fad08d732f50da1229 @awd-switzerland awd-switzerland committed Apr 4, 2013
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/swissmatch/zipcodes.rb
View
7 lib/swissmatch/zipcodes.rb
@@ -179,14 +179,15 @@ def autocomplete(string)
# @return [Array<String>]
# An array of ZipCode names which match the given string in an autocompletion.
# Sorted alphabetically (Umlaut-aware)
- def autocompleted_names(string)
+ def autocompleted_names(name)
name_dc = Unicode.downcase(name)
+ len = name_dc.length
base = autocomplete(name)
names = base.flat_map { |zip_code|
zip_code.reverse_name_transliteration_map.select { |transliterated_name, real_names|
Unicode.downcase(transliterated_name[0, len]) == name_dc
- }.values
- end
+ }.values.flatten(1)
+ }
names.uniq.sort(&Unicode.method(:strcmp))
end

0 comments on commit b961283

Please sign in to comment.
Something went wrong with that request. Please try again.