module SwissMatch

From SwissMatch::Location Deal with swiss zip codes, cities, communities and cantons.

@note

All strings passed to SwissMatch are expected to be utf-8. All strings
returned by SwissMatch are also in utf-8.

@example Load the data

require 'swissmatch/location'
SwissMatch::Location.load
# alternatively, just require 'swissmatch/location/autoload'

@example Get the ONRP for a given zip-code + city

require 'swissmatch/location/autoload'
SwissMatch.zip_code(8000, 'Zürich').ordering_number # => 4384
SwissMatch.zip_code(4384).name # => "Zürich"(de, 0)

Constants

TransMatch1

@private Used to transliterate city names

TransMatch2

@private Used to transliterate city names

Transliteration1

@private Used to transliterate city names

Transliteration2

@private Used to transliterate city names

Public Class Methods

canton(*args, &block) click to toggle source

@see SwissMatch::Location::canton

# File lib/swissmatch/location.rb, line 217
def self.canton(*args, &block)
  SwissMatch::Location.canton(*args, &block)
end
cantons(*args, &block) click to toggle source

@see SwissMatch::Location::cantons

# File lib/swissmatch/location.rb, line 222
def self.cantons(*args, &block)
  SwissMatch::Location.cantons(*args, &block)
end
cities_for_zip_code(*args, &block) click to toggle source

@see SwissMatch::Location::cities_for_zip_code

# File lib/swissmatch/location.rb, line 262
def self.cities_for_zip_code(*args, &block)
  SwissMatch::Location.cities_for_zip_code(*args, &block)
end
city(*args, &block) click to toggle source

@see SwissMatch::Location::city

# File lib/swissmatch/location.rb, line 257
def self.city(*args, &block)
  SwissMatch::Location.city(*args, &block)
end
communities(*args, &block) click to toggle source

@see SwissMatch::Location::communities

# File lib/swissmatch/location.rb, line 242
def self.communities(*args, &block)
  SwissMatch::Location.communities(*args, &block)
end
community(*args, &block) click to toggle source

@see SwissMatch::Location::community

# File lib/swissmatch/location.rb, line 237
def self.community(*args, &block)
  SwissMatch::Location.community(*args, &block)
end
district(*args, &block) click to toggle source

@see SwissMatch::Location::district

# File lib/swissmatch/location.rb, line 227
def self.district(*args, &block)
  SwissMatch::Location.district(*args, &block)
end
districts(*args, &block) click to toggle source

@see SwissMatch::Location::districts

# File lib/swissmatch/location.rb, line 232
def self.districts(*args, &block)
  SwissMatch::Location.districts(*args, &block)
end
transliterate1(word) click to toggle source

@private Used to transliterate city names

# File lib/swissmatch/location.rb, line 303
def self.transliterate1(word)
  word.gsub(TransMatch1, Transliteration1).delete("^ A-Za-z").downcase
end
transliterate2(word) click to toggle source

@private Used to transliterate city names

# File lib/swissmatch/location.rb, line 309
def self.transliterate2(word)
  word.gsub(TransMatch2, Transliteration2).delete("^ A-Za-z").downcase
end
transliterated_words(string) click to toggle source

@private Transliterates a string into the unique transliterated (1 & 2) word list

# File lib/swissmatch/location.rb, line 315
def self.transliterated_words(string)
  "#{transliterate1(string)} #{transliterate2(string)}".split(" ").uniq
end
zip_code(*args, &block) click to toggle source

@see SwissMatch::Location::zip_code

# File lib/swissmatch/location.rb, line 252
def self.zip_code(*args, &block)
  SwissMatch::Location.zip_code(*args, &block)
end
zip_codes(*args, &block) click to toggle source

@see SwissMatch::Location::zip_codes

# File lib/swissmatch/location.rb, line 247
def self.zip_codes(*args, &block)
  SwissMatch::Location.zip_codes(*args, &block)
end