Class: GooglePlaces::Client
- Inherits:
-
Object
- Object
- GooglePlaces::Client
- Defined in:
- lib/google_places/client.rb
Overview
This class acts as a proxy to the working classes when requesting data from the API.
Instance Attribute Summary collapse
-
#api_key ⇒ String
readonly
The provided api key.
-
#options ⇒ Hash
readonly
The provided options hash.
Instance Method Summary collapse
-
#initialize(api_key = @api_key, options = {}) ⇒ Client
constructor
Creates a new Client instance which proxies the requests to the certain classes.
-
#predictions_by_input(input, options = {}) ⇒ Array<Prediction>
Query for Place Predictions.
-
#spot(place_id, options = {}) ⇒ Spot
Search for a Spot with a reference key.
-
#spots(lat, lng, options = {}) ⇒ Array<Spot>
Search for Spots at the provided location.
-
#spots_by_bounds(bounds, options = {}) ⇒ Array<Spot>
Search for Spots within a give SW|NE bounds with query.
-
#spots_by_pagetoken(pagetoken, options = {}) ⇒ Array<Spot>
Search for Spots with a pagetoken.
-
#spots_by_query(query, options = {}) ⇒ Array<Spot>
Search for Spots with a query.
Constructor Details
#initialize(api_key = @api_key, options = {}) ⇒ Client
Creates a new Client instance which proxies the requests to the certain classes
44 45 46 47 |
# File 'lib/google_places/client.rb', line 44 def initialize(api_key = @api_key, = {}) api_key ? @api_key = api_key : @api_key = GooglePlaces.api_key @options = end |
Instance Attribute Details
#api_key ⇒ String (readonly)
Returns the provided api key.
5 6 7 |
# File 'lib/google_places/client.rb', line 5 def api_key @api_key end |
#options ⇒ Hash (readonly)
Returns the provided options hash.
7 8 9 |
# File 'lib/google_places/client.rb', line 7 def @options end |
Instance Method Details
#predictions_by_input(input, options = {}) ⇒ Array<Prediction>
Query for Place Predictions
292 293 294 |
# File 'lib/google_places/client.rb', line 292 def predictions_by_input(input, = {}) Prediction.list_by_input(input, @api_key, @options.merge()) end |
#spot(place_id, options = {}) ⇒ Spot
Search for a Spot with a reference key
117 118 119 |
# File 'lib/google_places/client.rb', line 117 def spot(place_id, = {}) Spot.find(place_id, @api_key, @options.merge()) end |
#spots(lat, lng, options = {}) ⇒ Array<Spot>
Search for Spots at the provided location
95 96 97 98 99 100 101 102 |
# File 'lib/google_places/client.rb', line 95 def spots(lat, lng, = {}) = @options.merge() detail = .delete(:detail) collection_detail_level( Spot.list(lat, lng, @api_key, ), detail ) end |
#spots_by_bounds(bounds, options = {}) ⇒ Array<Spot>
Search for Spots within a give SW|NE bounds with query
204 205 206 207 208 209 210 211 |
# File 'lib/google_places/client.rb', line 204 def spots_by_bounds(bounds, = {}) = @options.merge() detail = .delete(:detail) collection_detail_level( Spot.list_by_bounds(bounds, @api_key, ), detail ) end |
#spots_by_pagetoken(pagetoken, options = {}) ⇒ Array<Spot>
Search for Spots with a pagetoken
229 230 231 232 233 234 235 236 |
# File 'lib/google_places/client.rb', line 229 def spots_by_pagetoken(pagetoken, = {}) = @options.merge() detail = .delete(:detail) collection_detail_level( Spot.list_by_pagetoken(pagetoken, @api_key, ), detail ) end |
#spots_by_query(query, options = {}) ⇒ Array<Spot>
Search for Spots with a query
160 161 162 163 164 165 166 167 |
# File 'lib/google_places/client.rb', line 160 def spots_by_query(query, = {}) = @options.merge() detail = .delete(:detail) collection_detail_level( Spot.list_by_query(query, @api_key, ), detail ) end |