area 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +0 -4
- data/data/zipcodes.csv +0 -1
- data/lib/area/array.rb +11 -8
- data/lib/area/version.rb +1 -1
- data/test/unit/area_test.rb +1 -1
- metadata +1 -1
data/.travis.yml
CHANGED
data/data/zipcodes.csv
CHANGED
data/lib/area/array.rb
CHANGED
@@ -15,17 +15,20 @@ class Array
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_zip
|
18
|
-
lat = '%.3f' % self[0]
|
19
|
-
lon = '%.3f' % self[1]
|
20
|
-
|
21
18
|
Area::ZIP_CODES.each do |row|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
if row[3] and row[4]
|
20
|
+
db_lat_len = row[3].split('.').length
|
21
|
+
db_lon_len = row[4].split('.').length
|
22
|
+
lat = "%.#{db_lat_len}f" % self[0]
|
23
|
+
lon = "%.#{db_lon_len}f" % self[1]
|
24
|
+
db_lat = "%.#{db_lat_len}f" % row[3].to_f
|
25
|
+
db_lon = "%.#{db_lon_len}f" % row[4].to_f
|
26
|
+
if db_lat.to_s == lat.to_s and db_lon.to_s == lon.to_s
|
27
|
+
@zip = row[0]
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
31
|
+
@zip || nil
|
29
32
|
end
|
30
33
|
|
31
34
|
def to_gmt_offset
|
data/lib/area/version.rb
CHANGED
data/test/unit/area_test.rb
CHANGED