Class: N::Cookie
Overview
Encapsulates a HTTP Cookie.
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#max_age ⇒ Object
Returns the value of attribute max_age.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#secure ⇒ Object
Returns the value of attribute secure.
-
#value ⇒ Object
Returns the value of attribute value.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #expires ⇒ Object
- #expires=(t) ⇒ Object
-
#initialize(name, value) ⇒ Cookie
constructor
A new instance of Cookie.
- #to_s ⇒ Object
Constructor Details
#initialize(name, value) ⇒ Cookie
Returns a new instance of Cookie.
15 16 17 18 19 20 21 |
# File 'lib/nitro/cookie.rb', line 15 def initialize(name, value) @name = name @value = value @version = 0 # Netscape Cookie @domain = @path = @secure = @comment = @max_age = @expires = @comment_url = @discard = @port = nil end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
13 14 15 |
# File 'lib/nitro/cookie.rb', line 13 def comment @comment end |
#domain ⇒ Object
Returns the value of attribute domain.
12 13 14 |
# File 'lib/nitro/cookie.rb', line 12 def domain @domain end |
#max_age ⇒ Object
Returns the value of attribute max_age.
13 14 15 |
# File 'lib/nitro/cookie.rb', line 13 def max_age @max_age end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/nitro/cookie.rb', line 10 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/nitro/cookie.rb', line 12 def path @path end |
#secure ⇒ Object
Returns the value of attribute secure.
12 13 14 |
# File 'lib/nitro/cookie.rb', line 12 def secure @secure end |
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'lib/nitro/cookie.rb', line 11 def value @value end |
#version ⇒ Object
Returns the value of attribute version.
11 12 13 |
# File 'lib/nitro/cookie.rb', line 11 def version @version end |
Instance Method Details
#expires ⇒ Object
27 28 29 |
# File 'lib/nitro/cookie.rb', line 27 def expires @expires && Time.parse(@expires) end |
#expires=(t) ⇒ Object
23 24 25 |
# File 'lib/nitro/cookie.rb', line 23 def expires=(t) @expires = t && (t.is_a?(Time) ? t.httpdate : t.to_s) end |
#to_s ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/nitro/cookie.rb', line 31 def to_s ret = "" ret << @name << "=" << @value ret << "; " << "Version=" << @version.to_s if @version > 0 ret << "; " << "Domain=" << @domain if @domain ret << "; " << "Expires=" << @expires if @expires ret << "; " << "Max-Age=" << @max_age.to_s if @max_age ret << "; " << "Comment=" << @comment if @comment ret << "; " << "Path=" << @path if @path ret << "; " << "Secure" if @secure ret end |