Class: Scrapes::Cookies

Inherits:
Hash
  • Object
show all
Defined in:
lib/scrapes/cookies.rb

Overview

Make it easy to access HTTP cookies

Instance Method Summary collapse

Instance Method Details

#from_header(header) ⇒ Object

Parse HTTP cookie headers



37
38
39
40
# File 'lib/scrapes/cookies.rb', line 37

def from_header (header)
  k, v = header.sub(/;.*$/, '').split(/\s*=\s*/, 2)
  self[k] = v
end

#to_headerObject

Convert the current set of cookies into HTTP headers.



31
32
33
# File 'lib/scrapes/cookies.rb', line 31

def to_header
  map {|k,v| "#{k}=#{v}"}.join(';')
end