Class: RAWS::HTTP::Typhoeus::Response
- Defined in:
- lib/raws/http/typhoeus.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #parse(params = {}) ⇒ Object
- #receive(&block) ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
66 67 68 69 70 71 72 73 74 |
# File 'lib/raws/http/typhoeus.rb', line 66 def initialize(response) @response, @body, @doc = response, nil, nil @header = @response.headers.split("\r\n").inject({}) do |ret, val| if md = /(.+?):\s*(.*)/.match(val) ret[md[1].downcase] = md[2] end ret end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
64 65 66 |
# File 'lib/raws/http/typhoeus.rb', line 64 def body @body end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
64 65 66 |
# File 'lib/raws/http/typhoeus.rb', line 64 def doc @doc end |
Instance Method Details
#code ⇒ Object
76 77 78 |
# File 'lib/raws/http/typhoeus.rb', line 76 def code @response.code end |
#parse(params = {}) ⇒ Object
88 89 90 |
# File 'lib/raws/http/typhoeus.rb', line 88 def parse(params={}) @doc = RAWS.xml.parse(receive, params) end |
#receive(&block) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/raws/http/typhoeus.rb', line 80 def receive(&block) if block_given? block.call(StringIO.new(@response.body)) # TODO エラーにした方が。。。 else @body = @response.body end end |