Class: Net::HTTPExt::Response

Inherits:
String show all
Defined in:
lib/vex/base/net/http_ext.rb

Overview

This is a combination of a string (for the response body) and of a “hash” for the response header

Defined Under Namespace

Classes: Headers

Constant Summary

Constants inherited from String

String::INSP_TRUNCATE_LEN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from String

#constantize, #ends_with?, #insp, #starts_with?

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



46
47
48
49
# File 'lib/vex/base/net/http_ext.rb', line 46

def initialize(response)
  super(response.body) if response.body
  @response, @headers = response, Headers.new(response)
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



40
41
42
# File 'lib/vex/base/net/http_ext.rb', line 40

def headers
  @headers
end

#responseObject (readonly)

Returns the value of attribute response.



39
40
41
# File 'lib/vex/base/net/http_ext.rb', line 39

def response
  @response
end

Instance Method Details

#codeObject



42
# File 'lib/vex/base/net/http_ext.rb', line 42

def code;     Integer(response.code); end

#good?Boolean

Returns:

  • (Boolean)


43
# File 'lib/vex/base/net/http_ext.rb', line 43

def good?;    code >= 200 && code < 300; end

#messageObject



44
# File 'lib/vex/base/net/http_ext.rb', line 44

def message;  response.message;       end