area 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,10 +3,6 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
- - jruby-18mode # JRuby in 1.8 mode
7
- - jruby-19mode # JRuby in 1.9 mode
8
- - rbx-18mode
9
- - rbx-19mode
10
6
  notifications:
11
7
  email:
12
8
  - j@okfoc.us
@@ -1,4 +1,3 @@
1
- "zip","city","state","latitude","longitude","timezone","dst"
2
1
  "00210","Portsmouth","NH","43.005895","-71.013202","-5","1"
3
2
  "00211","Portsmouth","NH","43.005895","-71.013202","-5","1"
4
3
  "00212","Portsmouth","NH","43.005895","-71.013202","-5","1"
@@ -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
- db_lat = '%.3f' % row[3].to_f
23
- db_lon = '%.3f' % row[4].to_f
24
-
25
- if db_lat.to_s == lat.to_s and db_lon.to_s == lon.to_s
26
- return row[0]
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
@@ -1,3 +1,3 @@
1
1
  module Area
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -75,7 +75,7 @@ class TestArray < MiniTest::Unit::TestCase
75
75
  end
76
76
 
77
77
  def test_that_it_handles_latlon_precision
78
- assert_equal "11211", [40.7120912345, -73.9542712345].to_zip
78
+ assert_equal "11211", [40.71209123228157, -73.95488409019887].to_zip
79
79
  end
80
80
 
81
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: area
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: