Class: WebSpeak::ResponseAccessor
- Inherits:
-
Object
- Object
- WebSpeak::ResponseAccessor
- Defined in:
- lib/webspeak/response_accessor.rb
Instance Method Summary collapse
- #body ⇒ Object
- #cookies ⇒ Object
- #headers ⇒ Object
- #http_response ⇒ Object
-
#initialize(response) ⇒ ResponseAccessor
constructor
A new instance of ResponseAccessor.
Constructor Details
#initialize(response) ⇒ ResponseAccessor
Returns a new instance of ResponseAccessor.
3 4 5 |
# File 'lib/webspeak/response_accessor.rb', line 3 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
34 35 36 |
# File 'lib/webspeak/response_accessor.rb', line 34 def body @response.body end |
#cookies ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/webspeak/response_accessor.rb', line 19 def res = "" @response.get_fields('set-cookie').each do || elems = .split(";") = elems.shift # the rest of the elements are expiry, domain, path, ... name, value = .split("=", 2) res << "#{name.strip} => #{value.strip}\n" elems.each do |attr| name, value = attr.split("=", 2) res << " #{name.strip}: #{value.strip}\n" end end res end |
#headers ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/webspeak/response_accessor.rb', line 11 def headers res = "" @response.each_header do |name, values| values.each {|val| res << "#{name} => #{val}\n"} unless name == 'set-cookie' end res end |
#http_response ⇒ Object
7 8 9 |
# File 'lib/webspeak/response_accessor.rb', line 7 def http_response @response end |