Class: Apperol::Response
- Inherits:
-
Object
- Object
- Apperol::Response
- Defined in:
- lib/apperol/response.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#original_body ⇒ Object
Returns the value of attribute original_body.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #body ⇒ Object
- #header(key) ⇒ Object
-
#initialize(status, body, options = {}) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(status, body, options = {}) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 |
# File 'lib/apperol/response.rb', line 5 def initialize(status, body, = {}) @status = status.to_i @original_body = body @headers = [:headers] end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
3 4 5 |
# File 'lib/apperol/response.rb', line 3 def headers @headers end |
#original_body ⇒ Object
Returns the value of attribute original_body.
3 4 5 |
# File 'lib/apperol/response.rb', line 3 def original_body @original_body end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/apperol/response.rb', line 3 def status @status end |
Instance Method Details
#[](key) ⇒ Object
19 20 21 22 |
# File 'lib/apperol/response.rb', line 19 def [](key) puts @headers @headers[key.downcase].first end |
#body ⇒ Object
11 12 13 |
# File 'lib/apperol/response.rb', line 11 def body @body ||= JSON.parse(original_body) end |
#header(key) ⇒ Object
15 16 17 |
# File 'lib/apperol/response.rb', line 15 def header(key) @headers[key.downcase].first end |