Class: Excon::Response
- Inherits:
-
Object
- Object
- Excon::Response
- Defined in:
- lib/excon/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #body ⇒ Object
-
#body=(new_body) ⇒ Object
backwards compatability reader/writers.
-
#get_header(name) ⇒ Object
Retrieve a specific header value.
- #headers ⇒ Object
- #headers=(new_headers) ⇒ Object
-
#initialize(params = {}) ⇒ Response
constructor
A new instance of Response.
- #params ⇒ Object
- #remote_ip ⇒ Object
- #remote_ip=(new_remote_ip) ⇒ Object
- #status ⇒ Object
- #status=(new_status) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Response
Returns a new instance of Response.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/excon/response.rb', line 32 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
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/excon/response.rb', line 4 def data @data end |
Instance Method Details
#[](key) ⇒ Object
43 44 45 |
# File 'lib/excon/response.rb', line 43 def [](key) @data[key] end |
#body ⇒ Object
10 11 12 |
# File 'lib/excon/response.rb', line 10 def body @data[:body] end |
#body=(new_body) ⇒ Object
backwards compatability reader/writers
7 8 9 |
# File 'lib/excon/response.rb', line 7 def body=(new_body) @data[:body] = new_body end |
#get_header(name) ⇒ Object
Retrieve a specific header value. Header names are treated case-insensitively.
@param [String] name Header name
54 55 56 57 58 59 60 61 |
# File 'lib/excon/response.rb', line 54 def get_header(name) headers.each do |key,value| if key.casecmp(name) == 0 return value end end nil end |
#headers ⇒ Object
16 17 18 |
# File 'lib/excon/response.rb', line 16 def headers @data[:headers] end |
#headers=(new_headers) ⇒ Object
13 14 15 |
# File 'lib/excon/response.rb', line 13 def headers=(new_headers) @data[:headers] = new_headers end |
#params ⇒ Object
47 48 49 50 |
# File 'lib/excon/response.rb', line 47 def params $stderr.puts("Excon::Response#params is deprecated use Excon::Response#data instead (#{caller.first})") data end |
#remote_ip ⇒ Object
28 29 30 |
# File 'lib/excon/response.rb', line 28 def remote_ip @data[:remote_ip] end |
#remote_ip=(new_remote_ip) ⇒ Object
25 26 27 |
# File 'lib/excon/response.rb', line 25 def remote_ip=(new_remote_ip) @data[:remote_ip] = new_remote_ip end |
#status ⇒ Object
22 23 24 |
# File 'lib/excon/response.rb', line 22 def status @data[:status] end |
#status=(new_status) ⇒ Object
19 20 21 |
# File 'lib/excon/response.rb', line 19 def status=(new_status) @data[:status] = new_status end |