Class: TypePadTemplate::Response
- Inherits:
-
Object
- Object
- TypePadTemplate::Response
- Defined in:
- lib/type_pad_template/response.rb
Instance Method Summary collapse
- #cookies ⇒ Object
- #doc ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #successful? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
3 4 5 |
# File 'lib/type_pad_template/response.rb', line 3 def initialize(response) @response = response end |
Instance Method Details
#cookies ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/type_pad_template/response.rb', line 11 def @cokies ||= Array(@response.headers_hash["Set-Cookie"]).inject({}) do |hash, | key, value = .split(/;/, 2).first.split(/=/, 2) hash[key] = value hash end end |
#doc ⇒ Object
19 20 21 |
# File 'lib/type_pad_template/response.rb', line 19 def doc @doc ||= Nokogiri::HTML.parse(@response.body) end |
#successful? ⇒ Boolean
7 8 9 |
# File 'lib/type_pad_template/response.rb', line 7 def successful? @response.code == 200 end |