Class: Requests::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, body) ⇒ Response

Returns a new instance of Response.


82
83
84
# File 'lib/requests.rb', line 82

def initialize(status, headers, body)
  @status, @headers, @body = Integer(status), headers, body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body


80
81
82
# File 'lib/requests.rb', line 80

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers


79
80
81
# File 'lib/requests.rb', line 79

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status


78
79
80
# File 'lib/requests.rb', line 78

def status
  @status
end

Instance Method Details

#encodingObject

TODO Verify that this is based on content-type header


92
93
94
# File 'lib/requests.rb', line 92

def encoding
  @body.encoding
end

#jsonObject

TODO Verify that JSON can parse data without encoding stuff


87
88
89
# File 'lib/requests.rb', line 87

def json
  JSON.parse(@body)
end

#textObject

TODO this will probably do something related to encoding if necessary


97
98
99
# File 'lib/requests.rb', line 97

def text
  @body
end