locationator 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjZjZGRmNGE4M2ZkMDJjNDc1OTk5NjFmMjlhYWIwNDNkNGQ3YjJjNQ==
4
+ ZTkxZGU5ZTZkODY4MDQ5OWI1YjhkMDA1YzRiZjAzODgzNWMwNGViZA==
5
5
  data.tar.gz: !binary |-
6
- ZWE0ZjcxMzU1M2U3ZDhiYjYxNGIwYjZiZWI2ZDQwMWQ3OTVlOTE4OQ==
6
+ MjZlNjAwMzM2MGI0MWQyN2VkMjJkOTkxYWIzZmE0M2IyNzMyYWQyZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YmJiZjg1YTBjM2NiZWYxYzcwZDQ3ZTk4OTk4OTFmODE4ZjA4ZDA2ZDI2NzU2
10
- NTkyYWMyMGI0YWEwOTQ4MGMxMzdkNTIxNDY5YjcwZjBiOWYzOTI0OTUwZGQy
11
- ZTM4Yzk5NjY1N2Y3MzJmMzIzYWRhYzI5ZGNjZmI0OWU1NjU2M2U=
9
+ NWExZGE2ZjU4NWI1Zjk3NmUwOWU5ZDUxZWViN2Q0NWNiNThhYjMyNTRkNzAw
10
+ MTRjYmY0NDA2MmMwZTk5M2NmMjRhYzY2ZWI3NmI2N2M2MzVlOTI5ZDNmZjUz
11
+ ZTgzZDk4ZWE5YTQ5MDBlNWRjZWYyMDM0N2Q4NGI5NjcxZDBlNjk=
12
12
  data.tar.gz: !binary |-
13
- NzlhOTA3NWU2Y2M5NjU5ZjI1NWFkM2Q0ZTNhMjZjN2RkZGM3Mzk1YTQxYjFk
14
- ODUyZGMyMzhlY2Q0ZDNkZjgxODVjZjIxYWViZDE5MTA1ZmYxYWE1M2JlOWMz
15
- MTk1MWRmYjAwOWUyZGVmYzA3MTU2NzgwZjJlMjFjYTY0ZWRiOWM=
13
+ NDg4YWE3YWE1Mzc0YjAwM2QxYzg5YjNlYmY0ZjQ3ZDliMDhlMjlmMjFiYTc5
14
+ ODg5YTcyOWIzY2FhYjczMTQ1OWRhYmE0ZTM4MWZhZTE4MGZkNDAyOWFmMWJh
15
+ MDYyMzdkZDE5ZWU1MTg2ZWE5NmUwNTVlMGJhODc0OWZhYjdlNjg=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locationator (0.1.2)
4
+ locationator (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/locationator.rb CHANGED
@@ -8,28 +8,33 @@ module Locationator
8
8
  # Returns the latitude
9
9
  def self.lat(address)
10
10
  geocodeResponse = get_data(address)
11
- result = geocodeResponse["status"] == "ZERO_RESULTS" ? "Address not found." : geocodeResponse["results"][0]["geometry"]["location"]["lat"]
11
+ result = geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["geometry"]["location"]["lat"]
12
12
  end
13
13
 
14
14
  # Returns the longitude
15
15
  def self.lng(address)
16
16
  geocodeResponse = get_data(address)
17
- result = geocodeResponse["status"] == "ZERO_RESULTS" ? "Address not found." : geocodeResponse["results"][0]["geometry"]["location"]["lng"]
17
+ result = geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["geometry"]["location"]["lng"]
18
18
  end
19
19
 
20
20
  # Builds an array of the latitude and longitude
21
21
  def self.lat_lng(address)
22
- lat_lng_array = []
23
- lat_lng_array.push(self.lat(address))
24
- lat_lng_array.push(self.lng(address))
25
- result = lat_lng_array == ["Address not found.", "Address not found."] ? "Address not found." : lat_lng_array
22
+ myArray = []
23
+ geocodeResponse = get_data(address)
24
+ myArray.push(geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["geometry"]["location"]["lat"])
25
+ myArray.push(geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["geometry"]["location"]["lng"])
26
+ if myArray == [nil, nil]
27
+ result = nil
28
+ else
29
+ result = myArray
30
+ end
26
31
  end
27
32
 
28
33
  # Returns the zip code for an address
29
34
  def self.zip(address)
30
35
  geocodeResponse = get_data(address)
31
36
  if geocodeResponse["status"] == "ZERO_RESULTS"
32
- zip = "Address not found."
37
+ zip = nil
33
38
  else
34
39
  components = geocodeResponse["results"][0]["address_components"]
35
40
  # The postal code is always the last address component returned
@@ -41,7 +46,7 @@ module Locationator
41
46
  # Returns a properly formatted address
42
47
  def self.format(address)
43
48
  geocodeResponse = get_data(address)
44
- result = geocodeResponse["status"] == "ZERO_RESULTS" ? "Address not found." : geocodeResponse["results"][0]["formatted_address"]
49
+ result = geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["formatted_address"]
45
50
  end
46
51
 
47
52
  # Returns the latitude based on the current user's IP address
@@ -59,7 +64,7 @@ module Locationator
59
64
  # Returns an array of the latitude and longitude based on the current user's IP address
60
65
  def self.ip_lat_lng
61
66
  myArray = []
62
- geocodeResponse = get_data(address)
67
+ geocodeResponse = get_ip_data
63
68
  myArray.push(geocodeResponse["latitude"])
64
69
  myArray.push(geocodeResponse["longitude"])
65
70
  result = myArray
@@ -1,3 +1,3 @@
1
1
  module Locationator
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locationator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lawrence Davis