google_places 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/google_places.gemspec +1 -1
- data/lib/google_places/spot.rb +33 -15
- data/spec/google_places/spot_spec.rb +1 -1
- metadata +4 -4
data/google_places.gemspec
CHANGED
data/lib/google_places/spot.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module GooglePlaces
|
2
2
|
class Spot
|
3
|
-
attr_accessor :lat, :lng, :name, :icon, :reference, :vicinity, :types, :id, :formatted_phone_number, :formatted_address, :address_components, :rating, :url, :cid
|
3
|
+
attr_accessor :lat, :lng, :name, :icon, :reference, :vicinity, :types, :id, :formatted_phone_number, :international_phone_number, :formatted_address, :address_components, :street_number, :street, :city, :region, :postal_code, :country, :rating, :url, :cid, :website
|
4
4
|
|
5
5
|
def self.list(lat, lng, api_key, options = {})
|
6
6
|
radius = options.delete(:radius) || 200
|
@@ -55,20 +55,38 @@ module GooglePlaces
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def initialize(json_result_object)
|
58
|
-
@reference
|
59
|
-
@vicinity
|
60
|
-
@lat
|
61
|
-
@lng
|
62
|
-
@name
|
63
|
-
@icon
|
64
|
-
@types
|
65
|
-
@id
|
66
|
-
@formatted_phone_number
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@
|
70
|
-
@
|
71
|
-
@
|
58
|
+
@reference = json_result_object['reference']
|
59
|
+
@vicinity = json_result_object['vicinity']
|
60
|
+
@lat = json_result_object['geometry']['location']['lat']
|
61
|
+
@lng = json_result_object['geometry']['location']['lng']
|
62
|
+
@name = json_result_object['name']
|
63
|
+
@icon = json_result_object['icon']
|
64
|
+
@types = json_result_object['types']
|
65
|
+
@id = json_result_object['id']
|
66
|
+
@formatted_phone_number = json_result_object['formatted_phone_number']
|
67
|
+
@international_phone_number = json_result_object['international_phone_number']
|
68
|
+
@formatted_address = json_result_object['formatted_address']
|
69
|
+
@address_components = json_result_object['address_components']
|
70
|
+
@street_number = address_component(:street_number, 'short_name')
|
71
|
+
@street = address_component(:route, 'long_name')
|
72
|
+
@city = address_component(:locality, 'long_name')
|
73
|
+
@region = address_component(:administrative_area_level_1, 'long_name')
|
74
|
+
@postal_code = address_component(:postal_code, 'long_name')
|
75
|
+
@country = address_component(:country, 'long_name')
|
76
|
+
@rating = json_result_object['rating']
|
77
|
+
@url = json_result_object['url']
|
78
|
+
@cid = json_result_object['url'].to_i
|
79
|
+
@website = json_result_object['website']
|
80
|
+
end
|
81
|
+
|
82
|
+
def address_component(address_component_type, address_component_length)
|
83
|
+
if component = address_components_of_type(address_component_type)
|
84
|
+
component.first[address_component_length] unless component.first.nil?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def address_components_of_type(type)
|
89
|
+
@address_components.select{ |c| c['types'].include?(type.to_s) } unless @address_components.nil?
|
72
90
|
end
|
73
91
|
|
74
92
|
end
|
@@ -127,7 +127,7 @@ describe GooglePlaces::Spot do
|
|
127
127
|
@spot.class.should == GooglePlaces::Spot
|
128
128
|
end
|
129
129
|
|
130
|
-
%w(reference vicinity lat lng name icon types id formatted_phone_number formatted_address address_components rating url types).each do |attribute|
|
130
|
+
%w(reference vicinity lat lng name icon types id formatted_phone_number international_phone_number formatted_address address_components street_number street city region postal_code country rating url types website).each do |attribute|
|
131
131
|
it "should have the attribute: #{attribute}" do
|
132
132
|
@spot.respond_to?(attribute).should == true
|
133
133
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_places
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcel de Graaf
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-12-
|
18
|
+
date: 2011-12-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: httparty
|