Class: Elevate::HTTP::JSONHTTPResponse
- Inherits:
-
Object
- Object
- Elevate::HTTP::JSONHTTPResponse
- Defined in:
- lib/elevate/http/http_client.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #decode(data) ⇒ Object
-
#error ⇒ Object
TODO: delegate.
- #headers ⇒ Object
-
#initialize(response) ⇒ JSONHTTPResponse
constructor
A new instance of JSONHTTPResponse.
- #status_code ⇒ Object
Constructor Details
#initialize(response) ⇒ JSONHTTPResponse
Returns a new instance of JSONHTTPResponse.
87 88 89 90 |
# File 'lib/elevate/http/http_client.rb', line 87 def initialize(response) @response = response @body = decode(response.body) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
98 99 100 |
# File 'lib/elevate/http/http_client.rb', line 98 def body @body end |
Instance Method Details
#decode(data) ⇒ Object
92 93 94 95 96 |
# File 'lib/elevate/http/http_client.rb', line 92 def decode(data) return nil if data.nil? NSJSONSerialization.JSONObjectWithData(data, options:0, error:nil) end |
#error ⇒ Object
TODO: delegate
101 102 103 |
# File 'lib/elevate/http/http_client.rb', line 101 def error @response.error end |
#headers ⇒ Object
105 106 107 |
# File 'lib/elevate/http/http_client.rb', line 105 def headers @response.headers end |
#status_code ⇒ Object
109 110 111 |
# File 'lib/elevate/http/http_client.rb', line 109 def status_code @response.status_code end |