Class: CookieMonster::Cookie

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Cookie

Returns a new instance of Cookie.



45
46
47
48
49
50
51
52
53
54
# File 'lib/cookiemonster.rb', line 45

def initialize(args)
  @name = args[:name]
  @value = args[:value]
  @path = args[:path]
  @domain = args[:domain]
  @expires = args[:expires] ? parse_expiry(args[:expires]) : nil
  @http_only = args.has_key?(:httponly) ? true : false
  @secure = args.has_key?(:secure) ? true : false
  @session = expires.nil?
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



35
36
37
# File 'lib/cookiemonster.rb', line 35

def domain
  @domain
end

#expiresObject (readonly)

Returns the value of attribute expires.



36
37
38
# File 'lib/cookiemonster.rb', line 36

def expires
  @expires
end

#http_onlyObject (readonly) Also known as: http_only?

Returns the value of attribute http_only.



37
38
39
# File 'lib/cookiemonster.rb', line 37

def http_only
  @http_only
end

#nameObject (readonly)

Returns the value of attribute name.



32
33
34
# File 'lib/cookiemonster.rb', line 32

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



34
35
36
# File 'lib/cookiemonster.rb', line 34

def path
  @path
end

#secureObject (readonly) Also known as: secure?

Returns the value of attribute secure.



38
39
40
# File 'lib/cookiemonster.rb', line 38

def secure
  @secure
end

#sessionObject (readonly) Also known as: session?

Returns the value of attribute session.



39
40
41
# File 'lib/cookiemonster.rb', line 39

def session
  @session
end

#valueObject (readonly)

Returns the value of attribute value.



33
34
35
# File 'lib/cookiemonster.rb', line 33

def value
  @value
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/cookiemonster.rb', line 56

def expired?
  return false unless expires
  Time.now > expires
end