class Protocol::HTTP::Header::CacheControl

Represents the ‘cache-control` header, which is a list of cache directives.

def << value

@parameter value [String] the directive to add.

Adds a directive to the Cache-Control header. The value will be normalized to lowercase before being added.
def << value
	super(value.downcase)
end

def dynamic?

@returns [Boolean] whether the `dynamic` directive is present.
def dynamic?
	self.include?(DYNAMIC)
end

def find_integer_value(value_name)

@returns [Integer | Nil] the parsed integer value, or `nil` if not found or invalid.
@parameter value_name [String] the directive name to search for (e.g., "max-age").

Finds and parses an integer value from a directive.
def find_integer_value(value_name)
	if value = self.find { |value| value.start_with?(value_name) }
		_, age = value.split("=", 2)
		
		if age =~ /\A[0-9]+\z/
			return Integer(age)
		end
	end
end

def initialize(value = nil)

@parameter value [String | Nil] the raw Cache-Control header value.

Initializes the cache control header with the given value. The value is expected to be a comma-separated string of cache directives.
def initialize(value = nil)
	super(value&.downcase)
end

def max_age

@returns [Integer | Nil] the value of the `max-age` directive in seconds, or `nil` if the directive is not present or invalid.
def max_age
	find_integer_value(MAX_AGE)
end

def must_revalidate?

@returns [Boolean] whether the `must-revalidate` directive is present.
def must_revalidate?
	self.include?(MUST_REVALIDATE)
end

def no_cache?

@returns [Boolean] whether the `no-cache` directive is present.
def no_cache?
	self.include?(NO_CACHE)
end

def no_store?

@returns [Boolean] whether the `no-store` directive is present.
def no_store?
	self.include?(NO_STORE)
end

def private?

@returns [Boolean] whether the `private` directive is present.
def private?
	self.include?(PRIVATE)
end

def proxy_revalidate?

@returns [Boolean] whether the `proxy-revalidate` directive is present.
def proxy_revalidate?
	self.include?(PROXY_REVALIDATE)
end

def public?

@returns [Boolean] whether the `public` directive is present.
def public?
	self.include?(PUBLIC)
end

def s_maxage

@returns [Integer | Nil] the value of the `s-maxage` directive in seconds, or `nil` if the directive is not present or invalid.
def s_maxage
	find_integer_value(S_MAXAGE)
end

def static?

@returns [Boolean] whether the `static` directive is present.
def static?
	self.include?(STATIC)
end

def streaming?

@returns [Boolean] whether the `streaming` directive is present.
def streaming?
	self.include?(STREAMING)
end