Class: Web::Response
- Inherits:
-
Object
- Object
- Web::Response
- Defined in:
- lib/web/response.rb
Overview
A class which represents data from a response
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(code, body, headers) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(code, body, headers) ⇒ Response
Returns a new instance of Response.
19 20 21 22 23 |
# File 'lib/web/response.rb', line 19 def initialize(code, body, headers) @code = code @body = body @headers = headers || {} end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/web/response.rb', line 8 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/web/response.rb', line 8 def code @code end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/web/response.rb', line 8 def headers @headers end |
Class Method Details
.load(data) ⇒ Object
14 15 16 17 |
# File 'lib/web/response.rb', line 14 def self.load(data) data = JSON::parse(data) self.new(data['code'], data['body'], data['headers']) end |
Instance Method Details
#dump ⇒ Object
10 11 12 |
# File 'lib/web/response.rb', line 10 def dump { :code => @code, :headers => @headers, :body => @body }.to_json end |