Class: Periplus::BingResponse
- Inherits:
-
Object
- Object
- Periplus::BingResponse
- Defined in:
- lib/periplus/bing_response.rb
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(httparty_response) ⇒ BingResponse
constructor
A new instance of BingResponse.
- #parse ⇒ Object
Constructor Details
#initialize(httparty_response) ⇒ BingResponse
Returns a new instance of BingResponse.
5 6 7 8 9 10 11 |
# File 'lib/periplus/bing_response.rb', line 5 def initialize(httparty_response) @response = httparty_response raise error if @response.response.kind_of? Net::HTTPClientError parse end |
Instance Method Details
#error ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/periplus/bing_response.rb', line 23 def error http_code = @response.response.code = @response.response. = "An error has occurred communicating with the Bing Maps service. HTTP Status: #{http_code} (#{})" if Periplus.verbose << "\n URL: #{@response.request.path}" << "\n Response:" << "\n #{PP.pp(@response.response.body, "")}" end end |
#parse ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/periplus/bing_response.rb', line 13 def parse resource_sets = @response.parsed_response["resourceSets"] raise "Not found." if resource_sets == nil or resource_sets.length == 0 resources = resource_sets.first["resources"] raise "Not found." if resources == nil or resources.length == 0 @primary_resource = resources.first end |