Class: CabbageDoc::Response
- Inherits:
-
Object
- Object
- CabbageDoc::Response
- Defined in:
- lib/cabbage_doc/response.rb
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.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url, params, response) ⇒ Response
constructor
A new instance of Response.
- #to_json ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(url, params, response) ⇒ Response
Returns a new instance of Response.
13 14 15 16 17 18 19 |
# File 'lib/cabbage_doc/response.rb', line 13 def initialize(url, params, response) @url = url @params = params @headers = convert_headers(response) @code = response.code @body = response.parsed_response end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/cabbage_doc/response.rb', line 5 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/cabbage_doc/response.rb', line 5 def code @code end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/cabbage_doc/response.rb', line 5 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/cabbage_doc/response.rb', line 5 def params @params end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/cabbage_doc/response.rb', line 5 def url @url end |
Class Method Details
.parse(s, tag = TAG) ⇒ Object
8 9 10 |
# File 'lib/cabbage_doc/response.rb', line 8 def parse(s, tag = TAG) YAML.load(s) end |
Instance Method Details
#to_json ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/cabbage_doc/response.rb', line 25 def to_json { url: url, query: params.to_query, code: code, headers: prettify(headers), body: prettify(body) }.to_json end |
#to_yaml ⇒ Object
21 22 23 |
# File 'lib/cabbage_doc/response.rb', line 21 def to_yaml YAML.dump(self) end |