locationator 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/locationator.rb +4 -20
- data/lib/locationator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjBkZDI0Nzc2NTk2ZTgxNmU4MWIxNmY4MmFmYzljMmY4ODEwOGE2ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGNiZTk2ODhiODVjZWU1OTRlNDE5YzFkMjU2MjJiY2U1N2MwNmNhNQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NThkYThiMDNmZDllMjViMGZjZTZmZDk4YjFmZDBkZDFmMDI2NzRiNzViZWM4
|
10
|
+
ZDNiZDA3ZDdiNWRkNDk1NWVkMDQyYjVjZWE5ODA4OTFhNWVjOWVhNmU3MWVj
|
11
|
+
ZjlhMWY5YzYzZDYyZjMxMjYyNDEwMTNkYmU2NTYwNGFhMDMzYTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDQyYzZhMzQ4NGJhNzNmMjg0YjVmNWRlNTlhMzgyZTk3Nzk2ZjZhNzIyYWRl
|
14
|
+
ZTI4YzM2YTdiNTlmYjRhZWM4NjBmNmJlYmM1MzlkZGU0ZjEyZjdjY2NiZTYy
|
15
|
+
OGMzNmM0NWExMTE2NTk2NDg0NDM3NWFiMDIxMjAzYmY2YTY1ZDI=
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -40,7 +40,7 @@ Return the postal (zip) code of an address:
|
|
40
40
|
|
41
41
|
Return the properly formatted version of an address
|
42
42
|
|
43
|
-
$ Locationator.
|
43
|
+
$ Locationator.format("800 W. Huron St Chicago, IL")
|
44
44
|
=> "800 West Huron Street, Chicago, IL 60642, USA"
|
45
45
|
|
46
46
|
## Contributing
|
data/lib/locationator.rb
CHANGED
@@ -8,21 +8,13 @@ module Locationator
|
|
8
8
|
# Returns the latitude
|
9
9
|
def self.lat(address)
|
10
10
|
geocodeResponse = get_data(address)
|
11
|
-
|
12
|
-
lat = "Address not found."
|
13
|
-
else
|
14
|
-
lat = geocodeResponse["results"][0]["geometry"]["location"]["lat"]
|
15
|
-
end
|
11
|
+
result = geocodeResponse["status"] == "ZERO_RESULTS" ? "Address not found." : geocodeResponse["results"][0]["geometry"]["location"]["lat"]
|
16
12
|
end
|
17
13
|
|
18
14
|
# Returns the longitude
|
19
15
|
def self.lng(address)
|
20
16
|
geocodeResponse = get_data(address)
|
21
|
-
|
22
|
-
lng = "Address not found."
|
23
|
-
else
|
24
|
-
lng = geocodeResponse["results"][0]["geometry"]["location"]["lng"]
|
25
|
-
end
|
17
|
+
result = geocodeResponse["status"] == "ZERO_RESULTS" ? "Address not found." : geocodeResponse["results"][0]["geometry"]["location"]["lng"]
|
26
18
|
end
|
27
19
|
|
28
20
|
# Builds an array of the latitude and longitude
|
@@ -30,11 +22,7 @@ module Locationator
|
|
30
22
|
lat_lng_array = []
|
31
23
|
lat_lng_array.push(self.lat(address))
|
32
24
|
lat_lng_array.push(self.lng(address))
|
33
|
-
|
34
|
-
lat_lng_array = "Address not found."
|
35
|
-
else
|
36
|
-
lat_lng_array
|
37
|
-
end
|
25
|
+
result = lat_lng_array == ["Address not found.", "Address not found."] ? "Address not found." : lat_lng_array
|
38
26
|
end
|
39
27
|
|
40
28
|
# Returns the zip code for an address
|
@@ -53,11 +41,7 @@ module Locationator
|
|
53
41
|
# Returns a properly formatted address
|
54
42
|
def self.format(address)
|
55
43
|
geocodeResponse = get_data(address)
|
56
|
-
|
57
|
-
formatted = "Address not found."
|
58
|
-
else
|
59
|
-
formatted = geocodeResponse["results"][0]["formatted_address"]
|
60
|
-
end
|
44
|
+
result = geocodeResponse["status"] == "ZERO_RESULTS" ? "Address not found." : geocodeResponse["results"][0]["formatted_address"]
|
61
45
|
end
|
62
46
|
|
63
47
|
private
|
data/lib/locationator/version.rb
CHANGED