Class: Browze::Response
- Inherits:
-
Object
- Object
- Browze::Response
- Defined in:
- lib/browze/response.rb
Overview
Wrap the HTTParty response to assign custom attributes.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
Initialize the Response object with the original response data.
-
#parsed ⇒ Nokogiri::HTML4::Document
Returns the response parsed with nokogiri.
-
#set_cookie ⇒ Array
Get the cookies in the set-cookie header field.
Constructor Details
#initialize(response) ⇒ Response
Initialize the Response object with the original response data.
15 16 17 18 19 |
# File 'lib/browze/response.rb', line 15 def initialize(response) @body = response.body @code = response.code @original = response end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/browze/response.rb', line 8 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/browze/response.rb', line 8 def code @code end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
8 9 10 |
# File 'lib/browze/response.rb', line 8 def original @original end |
Instance Method Details
#parsed ⇒ Nokogiri::HTML4::Document
Returns the response parsed with nokogiri.
24 25 26 |
# File 'lib/browze/response.rb', line 24 def parsed Nokogiri::HTML(body) end |
#set_cookie ⇒ Array
Get the cookies in the set-cookie header field.
31 32 33 |
# File 'lib/browze/response.rb', line 31 def original.get_fields('Set-Cookie') || [] end |