Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Returns the state and city of the Sectional Center Facility for a given zip code.
Ruby
branch: master
Failed to load latest commit information.
data Update zip code data from Wikipedia
dev Ability to look up cities and states
lib Handle extended zip codes #3
spec Handle extended zip codes #3
.document
.gitignore Initial commit to zip-code-info.
.rspec Initial commit to zip-code-info.
Gemfile Upgrade to rspec 3. Fix spaces and quotes.
Gemfile.lock Upgrade to rspec 3. Fix spaces and quotes.
LICENSE.txt Initial commit to zip-code-info.
README.md
Rakefile Fix Rakefile
VERSION
zip-code-info.gemspec Regenerate gemspec for version 0.2.1

README.md

zip-code-info

This gem returns the state and city of the Sectional Center Facility for a given zip code. It does not use an external API. It looks up the zip code in a yml file.

The zip code data has been taken from http://en.wikipedia.org/wiki/ZIP_code_prefixes

Usage

In your Gemfile

gem "zip-code-info"

The code runs out of a Singleton class. Right now you can call these two methods.

  ZipCodeInfo.instance.state_for '99163'
  #=> WA
  ZipCodeInfo.instance.scf_city_for '99163'
  #=> Spokane

Limitations

  • The city returned is the city where the USPS Sectional Center Facility (SCF) is located.
  • Sometimes the state that a zip code is bound to for USPS is different from the actual state the zip code is in. There are plans to provide both states.
Something went wrong with that request. Please try again.