Sha256: f02669163fc0205bb3311839474551d3de38f74d2a1cf3d1154248586eb8b08c

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id: cookie.rb 1 2005-04-11 11:04:30Z gmosx $

module Nitro

# Encapsulates a HTTP Cookie.

class Cookie
	attr_reader :name
	attr_accessor :value, :version
	attr_accessor :domain, :path, :secure
	attr_accessor :comment, :max_age

	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

	def expires=(t)
		@expires = t && (t.is_a?(Time) ? t.httpdate : t.to_s)
	end

	def expires
		@expires && Time.parse(@expires)
	end

	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

end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nitro-0.16.0 lib/nitro/cookie.rb
nitro-0.17.0 lib/nitro/cookie.rb
nitro-0.18.0 lib/nitro/cookie.rb
nitro-0.18.1 lib/nitro/cookie.rb
nitro-0.19.0 lib/nitro/cookie.rb