Class: SWS::Cookie

Inherits:
Object
  • Object
show all
Defined in:
lib/sws/cookie.rb

Overview

Represents HTML cookie

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, path = "/") ⇒ Cookie

Creates new Cookie with given key=value pair and optionally path



15
16
17
# File 'lib/sws/cookie.rb', line 15

def initialize ( key, value, path="/" )
	@key,@value,@path = key,value,path
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/sws/cookie.rb', line 8

def key
  @key
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/sws/cookie.rb', line 10

def path
  @path
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/sws/cookie.rb', line 9

def value
  @value
end

Instance Method Details

#to_sObject

Returns cookie representation in HTTP header form



21
22
23
# File 'lib/sws/cookie.rb', line 21

def to_s
	return "Set-Cookie: #{@key}=#{@value}; path=#{@path}"
end