Class: GeoStalker::Locator::Base
- Inherits:
-
Object
- Object
- GeoStalker::Locator::Base
- Defined in:
- lib/geo_stalker/locator/base.rb
Constant Summary collapse
- ENDPOINT =
"https://www.googleapis.com/geolocation/v1/geolocate?key="
Instance Method Summary collapse
-
#initialize(api_key) ⇒ Base
constructor
A new instance of Base.
- #location ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Base
Returns a new instance of Base.
10 11 12 |
# File 'lib/geo_stalker/locator/base.rb', line 10 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#location ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/geo_stalker/locator/base.rb', line 14 def location https.start do request = Net::HTTP::Post.new(uri.request_uri) request.body = params.to_json request["Content-Type"] = "application/json" response = https.request(request) JSON.parse(response.body) end end |