Class: GoogleGeocodings::Client
- Inherits:
-
Object
- Object
- GoogleGeocodings::Client
- Defined in:
- lib/google_geocodings/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ String
readonly
The provided api key.
Instance Method Summary collapse
-
#geocode(address, options = {}) ⇒ Array<Geocoding>
geocode.
-
#initialize(api_key = @api_key) ⇒ Client
constructor
Creates a new Client instance which proxies the requests to the certain classes.
-
#reverse_geocode(latitude, longitude, options = {}) ⇒ Array<Geocoding>
reverse geocode.
Constructor Details
#initialize(api_key = @api_key) ⇒ Client
Creates a new Client instance which proxies the requests to the certain classes
9 10 11 |
# File 'lib/google_geocodings/client.rb', line 9 def initialize(api_key = @api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ String (readonly)
Returns the provided api key.
4 5 6 |
# File 'lib/google_geocodings/client.rb', line 4 def api_key @api_key end |
Instance Method Details
#geocode(address, options = {}) ⇒ Array<Geocoding>
geocode
see: developers.google.com/maps/documentation/geocoding/intro#geocoding NOTE: Not yet correspond to components param
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/google_geocodings/client.rb', line 27 def geocode(address, = {}) language = .delete(:language) region = .delete(:region) rectangle = Rectangle.new(.delete(:bounds)) = { key: api_key, address: address, language: language, region: region, bounds: rectangle.format, } request(:geocode, ) end |
#reverse_geocode(latitude, longitude, options = {}) ⇒ Array<Geocoding>
reverse geocode
see: developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding NOTE: Not yet correspond to components param
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/google_geocodings/client.rb', line 56 def reverse_geocode(latitude, longitude, = {}) language = .delete(:language) region = .delete(:region) rectangle = Rectangle.new(.delete(:bounds)) = { key: api_key, latlng: Location.new(latitude, longitude).format, language: language, region: region, bounds: rectangle.format, } request(:geocode, ) end |