Class: Browze::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/browze/response.rb

Overview

Wrap the HTTParty response to assign custom attributes.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/browze/response.rb', line 8

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



8
9
10
# File 'lib/browze/response.rb', line 8

def code
  @code
end

#originalObject (readonly)

Returns the value of attribute original.



8
9
10
# File 'lib/browze/response.rb', line 8

def original
  @original
end

Instance Method Details

#parsedNokogiri::HTML4::Document

Returns the response parsed with nokogiri.



24
25
26
# File 'lib/browze/response.rb', line 24

def parsed
  Nokogiri::HTML(body)
end

Get the cookies in the set-cookie header field.



31
32
33
# File 'lib/browze/response.rb', line 31

def set_cookie
  original.get_fields('Set-Cookie') || []
end