Class: Protocol::HTTP::Header::CacheControl

Inherits:
Split
  • Object
show all
Defined in:
lib/protocol/http/header/cache_control.rb

Overview

Header value which is split by newline charaters (e.g. cookies).

Constant Summary collapse

PRIVATE =
'private'
PUBLIC =
'public'
NO_CACHE =
'no-cache'
NO_STORE =
'no-store'
MAX_AGE =
'max-age'

Constants inherited from Split

Split::COMMA

Instance Method Summary collapse

Methods inherited from Split

#to_s

Constructor Details

#initialize(value) ⇒ CacheControl

Returns a new instance of CacheControl.



36
37
38
# File 'lib/protocol/http/header/cache_control.rb', line 36

def initialize(value)
	super(value.downcase)
end

Instance Method Details

#<<(value) ⇒ Object



40
41
42
# File 'lib/protocol/http/header/cache_control.rb', line 40

def << value
	super(value.downcase)
end

#max_ageObject



60
61
62
63
64
65
66
# File 'lib/protocol/http/header/cache_control.rb', line 60

def max_age
	if value = self.find{|value| value.start_with?(MAX_AGE)}
		_, age = value.split('=', 2)
		
		return Integer(age)
	end
end

#no_cache?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/protocol/http/header/cache_control.rb', line 52

def no_cache?
	self.include?(NO_CACHE)
end

#no_store?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/protocol/http/header/cache_control.rb', line 56

def no_store?
	self.include?(NO_STORE)
end

#private?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/protocol/http/header/cache_control.rb', line 44

def private?
	self.include?(PRIVATE)
end

#public?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/protocol/http/header/cache_control.rb', line 48

def public?
	self.include?(PUBLIC)
end