Class: Hyde::Cookie
- Inherits:
-
Object
- Object
- Hyde::Cookie
- Defined in:
- lib/hyde/util/cookie.rb
Overview
Utility class for handling cookies
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
-
.from_cookie_string(data) ⇒ Array(Cookie)
Create cookie(s) from a "Cookie: " format.
-
.from_setcookie_string(data) ⇒ Cookie
Create cookie from a "Set-Cookie: " format.
Instance Method Summary collapse
-
#initialize(key, value, params = {}) ⇒ Cookie
constructor
A new instance of Cookie.
-
#to_s ⇒ String
Convert cookie to "Set-Cookie: " string representation.
-
#to_short ⇒ Object
Convert cookie to "Cookie: " string representation (no params).
Constructor Details
#initialize(key, value, params = {}) ⇒ Cookie
Returns a new instance of Cookie.
9 10 11 12 13 |
# File 'lib/hyde/util/cookie.rb', line 9 def initialize(key, value, params = {}) @key = key @value = value @params = params end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
26 27 28 |
# File 'lib/hyde/util/cookie.rb', line 26 def key @key end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
27 28 29 |
# File 'lib/hyde/util/cookie.rb', line 27 def params @params end |
#value ⇒ Object
Returns the value of attribute value.
26 27 28 |
# File 'lib/hyde/util/cookie.rb', line 26 def value @value end |
Class Method Details
Instance Method Details
#to_s ⇒ String
Convert cookie to "Set-Cookie: " string representation.
17 18 19 |
# File 'lib/hyde/util/cookie.rb', line 17 def to_s Hyde::Util.make_value(to_short, @params) end |
#to_short ⇒ Object
Convert cookie to "Cookie: " string representation (no params)
22 23 24 |
# File 'lib/hyde/util/cookie.rb', line 22 def to_short "#{key.to_s.strip}=#{value.to_s.strip}" end |