Area

Perform a variety of conversions between places in the United States and area codes or zip codes.

View the Project on GitHub jgv/area

Build Status

Area

Hi. This gem allows you to perform the following conversions:

Area uses public domain data and does not rely on any external services (the internets). Usage is meant to be more lightweight than the Geocoder gem.

Installation

In your gemfile: gem 'area'

Usage

Convert an area code to a state/region

646.to_region #=> NY

Convert a state to an area code

"AK".to_area #=> "907"
"CT".to_area #=> ["203", "860"]

Convert a place to a zip code

"long island city, ny".to_zip #=> ["11101", "11109", "11120"]
"hastings on hudson".to_zip #=> "10706"

Convert a zip code to a place

"11211".to_region #=> "Brooklyn, NY"
"11211".to_region(:city => true) #=> "Brooklyn"
"11211".to_region(:state => true) #=> "NY"

Convert a zip code to a lat/lon

"11211".to_latlon #=> "40.71209, -73.95427"

Convert a zip code to a lat

"11211".to_lat #=> "40.71209"

Convert a zip code to a lon

"11211".to_lon #=> "40.71209, -73.95427"

Get the GMT offset of a zipcode

"11211".to_gmt_offset #=> "-5"

Get the GMT offset of a state

"NY".to_gmt_offset #=> "-5" # by state

Convert a lat/lon pair to a zipcode

[40.71209, -73.95427].to_zip #=> "11211"

Convert a lat/lon pair to a region

[40.71209, -73.95427].to_region #=> "Brooklyn, NY"

Get the GMT offset for a lat/lon pair

[40.71209, -73.95427].to_gmt_offset #=> "-5"

Testing and Contributing and Stuff

Contributions are more than welcome. I'm testing with minitest. This gem supports:

Copyright

Copyright (c) 2012 Jonathan Vingiano. See LICENSE for details.