Class: Scrapes::Cookies
- Inherits:
-
Hash
- Object
- Hash
- Scrapes::Cookies
- Defined in:
- lib/scrapes/cookies.rb
Overview
Make it easy to access HTTP cookies
Instance Method Summary collapse
-
#from_header(header) ⇒ Object
Parse HTTP cookie headers.
-
#to_header ⇒ Object
Convert the current set of cookies into HTTP headers.
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_header ⇒ Object
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 |