Class: SPOT::ApiResponse
- Inherits:
-
Object
- Object
- SPOT::ApiResponse
- Extended by:
- Forwardable
- Defined in:
- lib/spot-gps/api_response.rb
Instance Method Summary collapse
-
#body ⇒ Object
Return the body of the API response.
-
#initialize(response) ⇒ ApiResponse
constructor
A new instance of ApiResponse.
-
#json? ⇒ Boolean
Returns true if the response is JSON.
Constructor Details
#initialize(response) ⇒ ApiResponse
Returns a new instance of ApiResponse.
9 10 11 |
# File 'lib/spot-gps/api_response.rb', line 9 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
Return the body of the API response
14 15 16 |
# File 'lib/spot-gps/api_response.rb', line 14 def body json? ? handle_json : handle_raw end |
#json? ⇒ Boolean
Returns true if the response is JSON
19 20 21 22 |
# File 'lib/spot-gps/api_response.rb', line 19 def json? content_type = @response.headers[:content_type] || '' content_type.include?('application/json') end |