Sha256: 9100aba6debd8edb86a6b74cf9979c83246c2e19e898545b48cb95965d636d2a

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

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
		@path = '/'			# gmosx: KEEP this!
		@domain = @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

# * George Moschovitis <gm@navel.gr>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.20.0 lib/nitro/cookie.rb