Class: Excon::Response
- Inherits:
-
Object
- Object
- Excon::Response
- Defined in:
- lib/excon/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#data ⇒ Object
Returns the value of attribute data.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#remote_ip ⇒ Object
Returns the value of attribute remote_ip.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#get_header(name) ⇒ Object
Retrieve a specific header value.
-
#initialize(params = {}) ⇒ Response
constructor
A new instance of Response.
- #params ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/excon/response.rb', line 6 def initialize(params={}) @data = { :body => '', :headers => {} }.merge(params) @body = @data[:body] @headers = @data[:headers] @status = @data[:status] @remote_ip = @data[:remote_ip] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/excon/response.rb', line 4 def body @body end |
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/excon/response.rb', line 4 def data @data end |
#headers ⇒ Object
Returns the value of attribute headers.
4 5 6 |
# File 'lib/excon/response.rb', line 4 def headers @headers end |
#remote_ip ⇒ Object
Returns the value of attribute remote_ip.
4 5 6 |
# File 'lib/excon/response.rb', line 4 def remote_ip @remote_ip end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/excon/response.rb', line 4 def status @status end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 |
# File 'lib/excon/response.rb', line 17 def [](key) @data[key] end |
#get_header(name) ⇒ Object
Retrieve a specific header value. Header names are treated case-insensitively.
@param [String] name Header name
28 29 30 31 32 33 34 35 |
# File 'lib/excon/response.rb', line 28 def get_header(name) headers.each do |key,value| if key.casecmp(name) == 0 return value end end nil end |
#params ⇒ Object
21 22 23 24 |
# File 'lib/excon/response.rb', line 21 def params $stderr.puts("Excon::Response#params is deprecated use Excon::Response#data instead (#{caller.first})") data end |