Class: CabbageDoc::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cabbage_doc/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, params, response) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
11
# File 'lib/cabbage_doc/response.rb', line 5

def initialize(url, params, response)
  @url = url
  @params = params
  @headers = convert_headers(response)
  @code = response.code
  @body = response.parsed_response
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/cabbage_doc/response.rb', line 3

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/cabbage_doc/response.rb', line 3

def code
  @code
end

#headersObject (readonly)

Returns the value of attribute headers.



3
4
5
# File 'lib/cabbage_doc/response.rb', line 3

def headers
  @headers
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/cabbage_doc/response.rb', line 3

def params
  @params
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/cabbage_doc/response.rb', line 3

def url
  @url
end

Instance Method Details

#to_jsonObject



13
14
15
16
17
18
19
20
21
# File 'lib/cabbage_doc/response.rb', line 13

def to_json
  { 
    url: url,
    query: params.to_query, 
    code: code, 
    headers: prettify(headers),
    body: prettify(body) 
  }.to_json
end