Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42,706 changes: 42,693 additions & 13 deletions data/zipcodes.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.zip_codes
@zip_codes
end

@regions = ["REGION", "NJ", "DC", "CT", "MB", "AL", "WA", "ME", "ID", "CA", "TX", "NY", "PA", "OH", "IL", "MN", "IN", "LA", "ON", "MS", "GA", "MI", "FL", "MD", "BAHAMAS", "BARBADOS", "BC", "NC", "WI", "ANGUILLA", "ANTIGUA AND BARBUDA", "KY", "VA", "BRITISH VIRGIN ISLANDS", "DE", "CO", "WV", "SK", "WY", "NE", "MO", "KS", "IA", "MA", "USVI", "CAYMAN ISLANDS", "RI", "AB", "OK", "MT", "QC", "TN", "UT", "BERMUDA", "RESERVED", "GRENADA", "AR", "AZ", "OR", "NM", "NB", "NH", "SD", "TURKS & CAICOS ISLANDS", "MONTSERRAT", "MP", "GU", "AS", "ND", "NV", "NL", "US GOVERNMENT", "ST. LUCIA", "DOMINICA", "ST. VINCENT & GRENADINES", "PR", "TOLL FREE", "VT", "SC", "HI", "DOMINICAN REPUBLIC", "YT", "TRINIDAD & TOBAGO", "ST. KITTS & NEVIS", "JAMAICA", "TOLL CALLS", "NS", "AK"]
@regions = ["REGION", "New Jersey", "DC", "Connecticut", "MB", "Alabama", "Washington", "Maine", "Idaho", "California", "Texas", "New York", "Pennsylvania", "Ohio", "Illinois", "Minnesota", "Indiana", "Louisiana", "ON", "Mississippi", "Georgia", "Michigan", "Florida", "Maryland", "BAHAMAS", "BARBADOS", "BC", "North Carolina", "Wisconsin", "ANGUILLA", "ANTIGUA AND BARBUDA", "Kentucky", "Virginia", "BRITISH VIRGIN ISLANDS", "Delaware", "Colorado", "West Virginia", "SK", "Wyoming", "Nebraska", "Missouri", "Kansas", "Iowa", "Massachusetts", "USVI", "CAYMAN ISLANDS", "Rhode Island", "AB", "Oklahoma", "Montana", "QC", "Tennessee", "Utah", "BERMUDA", "RESERVED", "GRENADA", "Arkansas", "Arizona", "Oregon", "New Mexico", "NB", "New Hampshire", "South Dakota", "TURKS & CAICOS ISLANDS", "MONTSERRAT", "MP", "GU", "AS", "North Dakota", "Nevada", "NL", "US GOVERNMENT", "ST. LUCIA", "DOMINICA", "ST. VINCENT & GRENADINES", "PR", "TOLL FREE", "Vermont", "South Carolina", "Hawaii", "DOMINICAN REPUBLIC", "YT", "TRINIDAD & TOBAGO", "ST. KITTS & NEVIS", "JAMAICA", "TOLL CALLS", "NS", "Alaska", "NJ", "CT", "AL", "WA", "ME", "ID", "CA", "TX", "NY", "PA", "OH", "IL", "MN", "IN", "LA", "MS", "GA", "MI", "FL", "MD", "NC", "WI", "KY", "VA", "DE", "CO", "WV", "WY", "NE", "MO", "KS", "IA", "MA", "RI", "OK", "MT", "TN", "UT", "AR", "AZ", "OR", "NM", "NH", "SD", "ND", "NV", "VT", "SC", "HI", "AK"]

def self.code?(code)
if code.to_s.length == 3
Expand Down
2 changes: 1 addition & 1 deletion lib/area/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Array
# # => "Brooklyn, NY"
#
# ['40.71209', '-73.95427'].to_region(:state => true)
# # => "NY"
# # => "New York"
#
# Returns a String representation of the lat/lon pair.
def to_region(options = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/area/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class String
#
# Examples
#
# "CT".to_area
# "Connecticut".to_area
# # => ["203", "860"]
#
# Returns an Array of converted area codes.
Expand Down
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ In your gemfile: `gem 'area'`

#### Convert a state to an area code
```` ruby
"AK".to_area #=> ["907"]
"CT".to_area #=> ["203", "860"]
"Alaska".to_area #=> ["907"]
"Connecticut".to_area #=> ["203", "860"]
```

#### Convert a place to a zip code
Expand All @@ -45,7 +45,7 @@ In your gemfile: `gem 'area'`
```` ruby
"11211".to_region #=> "Brooklyn, NY"
"11211".to_region(:city => true) #=> "Brooklyn"
"11211".to_region(:state => true) #=> "NY"
"11211".to_region(:state => true) #=> "New York"
```

#### Convert a zip code to a lat/lon
Expand All @@ -70,7 +70,7 @@ In your gemfile: `gem 'area'`

#### Get the GMT offset of a state
```` ruby
"NY".to_gmt_offset #=> "-5" # by state
"New York".to_gmt_offset #=> "-5" # by state
```

#### Convert a lat/lon pair to a zipcode
Expand Down
14 changes: 7 additions & 7 deletions test/unit/area_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class TestInteger < MiniTest::Unit::TestCase

def test_that_it_converts_area_code_to_region
assert_equal "NY", 646.to_region
assert_equal "New York", 646.to_region
end

def test_that_it_converts_zip_code_to_latlon
Expand Down Expand Up @@ -36,7 +36,7 @@ def test_that_it_handles_bad_area_codes
class TestString < MiniTest::Unit::TestCase

def test_that_it_converts_area_code_to_region
assert_equal "NY", "646".to_region
assert_equal "New York", "646".to_region
end

def test_that_it_converts_zip_code_to_region
Expand All @@ -45,12 +45,12 @@ def test_that_it_converts_zip_code_to_region

def test_that_it_supports_options
assert_equal "Brooklyn", "11211".to_region(:city => true)
assert_equal "NY", "11211".to_region(:state => true)
assert_equal "New York", "11211".to_region(:state => true)
end

def test_that_it_converts_to_area_code
assert_equal ["907"], "AK".to_area
assert_equal ["203", "860"], "CT".to_area
assert_equal ["907"], "Alaska".to_area
assert_equal ["203", "860"], "Connecticut".to_area
end

def test_that_it_converts_to_zip_code
Expand All @@ -63,7 +63,7 @@ def test_that_it_converts_city_state_to_zip_code
end

def test_that_it_converts_to_offset
assert_equal "-5", "ny".to_gmt_offset
assert_equal "-5", "New York".to_gmt_offset
end

def test_that_it_handles_incorrect_zips
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_that_it_converts_latlon_to_region
end

def test_that_it_converts_latlon_to_region_with_options
assert_equal "NY", [40.71209, -73.95427].to_region(:state => true)
assert_equal "New York", [40.71209, -73.95427].to_region(:state => true)
end

def test_that_it_converts_latlon_to_gmt_offset
Expand Down