Class: Wreq::Response

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

Instance Method Summary collapse

Instance Method Details

#inspectString

Returns a compact string representation for debugging.

Format: #<Wreq::Response STATUS content-type="..." body=SIZE>

Examples:

p response
# => #<Wreq::Response 200 content-type="application/json" body=456B>

Returns:

  • (String)

    Compact formatted response information



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/wreq_ruby/response.rb', line 171

def inspect
  parts = ["#<Wreq::Response"]

  parts << code.to_s

  if headers.respond_to?(:get)
    content_type = headers.get("content-type")
    parts << "content-type=#{content_type.inspect}" if content_type
  end

  if content_length
    parts << "body=#{format_bytes(content_length)}"
  end

  parts.join(" ") + ">"
end

#to_sString

Returns the response body as a string.

Examples:

puts response.to_s
puts response
File.write("page.html", response)

Returns:

  • (String)

    Response body text



159
160
161
# File 'lib/wreq_ruby/response.rb', line 159

def to_s
  text
end