Class: HTTPI::Cookie
- Inherits:
-
Object
- Object
- HTTPI::Cookie
- Defined in:
- lib/httpi/cookie.rb
Overview
HTTPI::Cookie
Represents a single delicious cookie.
Examples
= HTTPI::Cookie.new("token=choc-choc-chip; Path=/; HttpOnly")
.name # "token"
.name_and_value # "token=choc-choc-chip"
Class Method Summary collapse
-
.list_from_headers(headers) ⇒ Object
Returns a list of cookies from a Hash of
headers
.
Instance Method Summary collapse
-
#initialize(cookie) ⇒ Cookie
constructor
A new instance of Cookie.
-
#name ⇒ Object
Returns the name of the cookie.
-
#name_and_value ⇒ Object
Returns the name and value of the cookie.
Constructor Details
#initialize(cookie) ⇒ Cookie
20 21 22 |
# File 'lib/httpi/cookie.rb', line 20 def initialize() = end |
Class Method Details
.list_from_headers(headers) ⇒ Object
Returns a list of cookies from a Hash of headers
.
16 17 18 |
# File 'lib/httpi/cookie.rb', line 16 def self.list_from_headers(headers) Array(headers["Set-Cookie"]).map { || new() } end |
Instance Method Details
#name ⇒ Object
Returns the name of the cookie.
25 26 27 |
# File 'lib/httpi/cookie.rb', line 25 def name .split("=").first end |
#name_and_value ⇒ Object
Returns the name and value of the cookie.
30 31 32 |
# File 'lib/httpi/cookie.rb', line 30 def name_and_value .split(";").first end |