Project

ziptedu

0.0
No commit activity in last 3 years
No release in over 3 years
Functions for looking up zipcode, city, state, latitude and longitude using a zipcode, city + state, or latitude + longitude. You can also get random sets of this data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 10.0
~> 3.0
 Project Readme

Ziptedu

Build Status

Collection of data and utilities to lookup postal-code based location information. This gem is HEAVILY INSPIRED by Thomas Leen's zippity-do-dah (Node.js module that does pretty much the same thing).

Functions for looking up zipcode, city, state, latitude and longitude using a zipcode, city + state, or latitude + longitude. You can also get random sets of this data.

Data sourced from federalgovernmentzipcodes.us. This is primary data, meaning data that maps to multiple locations will return only the primary location.

NOTE: The data is self-contained inside the gem, so no internet connection is required in order to use it.

Installation

Add this line to your application's Gemfile:

gem 'ziptedu'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ziptedu

Usage

require('ziptedu')

puts Ziptedu.random(3)
puts Ziptedu.zipcode(21208).city
puts Ziptedu.random
puts Ziptedu.citystate("Baltimore", "MD")
puts Ziptedu.latlong('32.09', '-96.71')

API

Lookups

All lookups will return nil (if lookup was unsuccessful) or an instance of Ziptedu::Zipcode class with the following attributes:

  • zipcode
  • type (standard, military, po box)
  • city
  • state
  • latitude
  • longitude

These attributes may be empty if not applicable to the specific location returned.

.zipcode(zipcode)

Lookup data by 5 digit zipcode (the argument can be either an integer or a string)

.citystate(city, state)

Lookup data by city and state, capitalization does not matter.

.latlong(latitude, longitude)

Lookup date by latitude and longitude, lat/long must have two decimal digits only (-)xx.xx.

Utilities

.random([number])

Will return a single random result, if number is specified and > 1 will return an array of random results.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kalmanh/ziptedu.

License

The gem is available as open source under the terms of the MIT License.