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.



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

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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



75
76
77
# File 'lib/requests.rb', line 75

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



74
75
76
# File 'lib/requests.rb', line 74

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



73
74
75
# File 'lib/requests.rb', line 73

def status
  @status
end

Instance Method Details

#encodingObject

TODO Verify that this is based on content-type header



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

def encoding
  @body.encoding
end

#jsonObject

TODO Verify that JSON can parse data without encoding stuff



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

def json
  JSON.parse(@body)
end

#textObject

TODO this will probably do something related to encoding if necessary



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

def text
  @body
end