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.
-
#sensor ⇒ Object
readonly
Returns the value of attribute sensor.
Instance Method Summary collapse
-
#initialize(api_key = @api_key, sensor = false, options = {}) ⇒ Client
constructor
Creates a new Client instance which proxies the requests to the certain classes.
-
#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_pagetoken(pagetoken, options = {}) ⇒ Array<Spot>
Search for Spots with a pagetoken.
-
#spots_by_query(query, options = {}) ⇒ Array<Spot>
Search for Spots with a query.
-
#spots_by_radar(lat, lng, options = {}) ⇒ Array<Spot>
Radar Search Service allows you to search for up to 200 Places at once, but with less detail than is typically returned from a Text Search or Nearby Search request.
Constructor Details
#initialize(api_key = @api_key, sensor = false, options = {}) ⇒ Client
Creates a new Client instance which proxies the requests to the certain classes
47 48 49 50 51 |
# File 'lib/google_places/client.rb', line 47 def initialize(api_key = @api_key, sensor = false, = {}) api_key ? @api_key = api_key : @api_key = GooglePlaces.api_key @sensor = sensor @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 |
#sensor ⇒ Object (readonly)
Returns the value of attribute sensor.
8 9 10 |
# File 'lib/google_places/client.rb', line 8 def sensor @sensor end |
Instance Method Details
#spot(place_id, options = {}) ⇒ Spot
Search for a Spot with a reference key
119 120 121 |
# File 'lib/google_places/client.rb', line 119 def spot(place_id, = {}) Spot.find(place_id, @api_key, @sensor, @options.merge()) end |
#spots(lat, lng, options = {}) ⇒ Array<Spot>
Search for Spots at the provided location
99 100 101 |
# File 'lib/google_places/client.rb', line 99 def spots(lat, lng, = {}) Spot.list(lat, lng, @api_key, @sensor, @options.merge()) end |
#spots_by_pagetoken(pagetoken, options = {}) ⇒ Array<Spot>
Search for Spots with a pagetoken
180 181 182 |
# File 'lib/google_places/client.rb', line 180 def spots_by_pagetoken(pagetoken, = {}) Spot.list_by_pagetoken(pagetoken, @api_key, @sensor, @options.merge()) end |
#spots_by_query(query, options = {}) ⇒ Array<Spot>
Search for Spots with a query
162 163 164 |
# File 'lib/google_places/client.rb', line 162 def spots_by_query(query, = {}) Spot.list_by_query(query, @api_key, @sensor, @options.merge()) end |
#spots_by_radar(lat, lng, options = {}) ⇒ Array<Spot>
Radar Search Service allows you to search for up to 200 Places at once, but with less detail than is typically returned from a Text Search or Nearby Search request. The search response will include up to 200 Places, identified only by their geographic coordinates and reference. You can send a Place Details request for more information about any of them.
217 218 219 |
# File 'lib/google_places/client.rb', line 217 def spots_by_radar(lat, lng, = {}) Spot.list_by_radar(lat, lng, @api_key, @sensor, @options.merge()) end |