Class: TypePadTemplate::Response

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

Instance Method Summary collapse

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

#cookiesObject



11
12
13
14
15
16
17
# File 'lib/type_pad_template/response.rb', line 11

def cookies
  @cokies ||= Array(@response.headers_hash["Set-Cookie"]).inject({}) do |hash, cookie|
    key, value = cookie.split(/;/, 2).first.split(/=/, 2)
    hash[key] = value
    hash
  end
end

#docObject



19
20
21
# File 'lib/type_pad_template/response.rb', line 19

def doc
  @doc ||= Nokogiri::HTML.parse(@response.body)
end

#successful?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/type_pad_template/response.rb', line 7

def successful?
  @response.code == 200
end