Class: Fluidinfo::Response
- Inherits:
-
Object
- Object
- Fluidinfo::Response
- Defined in:
- lib/fluidinfo/response.rb
Overview
Instance Attribute Summary (collapse)
-
- (Object) content
readonly
- String, nil
-
The raw response.
-
- (Object) error
readonly
- String
-
The error, if any, returned by Fluidinfo.
-
- (Object) headers
readonly
- Hash
-
The returned headers.
-
- (Object) status
readonly
- Integer
-
The return code of the API call.
-
- (Object) value
readonly
- Hash, String
-
The parsed response if the Content-Type was one of JSON_TYPES, otherwise equivalent to #content.
Instance Method Summary (collapse)
-
- (Object) [](key)
A shortcut for Response.value#[].
-
- (Response) initialize(response)
constructor
A new instance of Response.
Constructor Details
- (Response) initialize(response)
A new instance of Response
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fluidinfo/response.rb', line 21 def initialize(response) @status = response.code @headers = response.headers @error = @headers[:x_fluiddb_error_class] @content = response.body @value = if JSON_TYPES.include? @headers[:content_type] Yajl.load @content else @content end end |
Instance Attribute Details
- (Object) content (readonly)
- String, nil
-
The raw response
15 16 17 |
# File 'lib/fluidinfo/response.rb', line 15 def content @content end |
- (Object) error (readonly)
- String
-
The error, if any, returned by Fluidinfo
19 20 21 |
# File 'lib/fluidinfo/response.rb', line 19 def error @error end |
- (Object) headers (readonly)
- Hash
-
The returned headers.
13 14 15 |
# File 'lib/fluidinfo/response.rb', line 13 def headers @headers end |
- (Object) status (readonly)
- Integer
-
The return code of the API call.
11 12 13 |
# File 'lib/fluidinfo/response.rb', line 11 def status @status end |
- (Object) value (readonly)
- Hash, String
-
The parsed response if the Content-Type was one of JSON_TYPES, otherwise equivalent to #content.
17 18 19 |
# File 'lib/fluidinfo/response.rb', line 17 def value @value end |
Instance Method Details
- (Object) [](key)
A shortcut for Response.value#[].
35 36 37 |
# File 'lib/fluidinfo/response.rb', line 35 def [](key) @value[key] end |