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

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

Constant Summary collapse

PRIVATE =
'private'
PUBLIC =
'public'
NO_CACHE =
'no-cache'
NO_STORE =
'no-store'
MAX_AGE =
'max-age'
STATIC =
'static'
DYNAMIC =
'dynamic'
STREAMING =
'streaming'

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.


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

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

Instance Method Details

#<<(value) ⇒ Object


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

def << value
	super(value.downcase)
end

#dynamic?Boolean

Returns:

  • (Boolean)

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

def dynamic?
	self.include?(DYNAMIC)
end

#max_ageObject


75
76
77
78
79
80
81
# File 'lib/protocol/http/header/cache_control.rb', line 75

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)

67
68
69
# File 'lib/protocol/http/header/cache_control.rb', line 67

def no_cache?
	self.include?(NO_CACHE)
end

#no_store?Boolean

Returns:

  • (Boolean)

71
72
73
# File 'lib/protocol/http/header/cache_control.rb', line 71

def no_store?
	self.include?(NO_STORE)
end

#private?Boolean

Returns:

  • (Boolean)

59
60
61
# File 'lib/protocol/http/header/cache_control.rb', line 59

def private?
	self.include?(PRIVATE)
end

#public?Boolean

Returns:

  • (Boolean)

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

def public?
	self.include?(PUBLIC)
end

#static?Boolean

Returns:

  • (Boolean)

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

def static?
	self.include?(STATIC)
end

#streaming?Boolean

Returns:

  • (Boolean)

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

def streaming?
	self.include?(STREAMING)
end