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 = nil) ⇒ CacheControl

Returns a new instance of CacheControl.



22
23
24
# File 'lib/protocol/http/header/cache_control.rb', line 22

def initialize(value = nil)
	super(value&.downcase)
end

Instance Method Details

#<<(value) ⇒ Object



26
27
28
# File 'lib/protocol/http/header/cache_control.rb', line 26

def << value
	super(value.downcase)
end

#dynamic?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/protocol/http/header/cache_control.rb', line 34

def dynamic?
	self.include?(DYNAMIC)
end

#max_ageObject



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

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)


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

def no_cache?
	self.include?(NO_CACHE)
end

#no_store?Boolean

Returns:

  • (Boolean)


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

def no_store?
	self.include?(NO_STORE)
end

#private?Boolean

Returns:

  • (Boolean)


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

def private?
	self.include?(PRIVATE)
end

#public?Boolean

Returns:

  • (Boolean)


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

def public?
	self.include?(PUBLIC)
end

#static?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/protocol/http/header/cache_control.rb', line 30

def static?
	self.include?(STATIC)
end

#streaming?Boolean

Returns:

  • (Boolean)


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

def streaming?
	self.include?(STREAMING)
end