class Protocol::HTTP::Header::Priority

The ‘priority` header allows clients to express their preference for how resources should be prioritized by the server. It supports directives like `u=` to specify the urgency level of a request, and `i` to indicate whether a response can be delivered incrementally. The urgency levels range from 0 (highest priority) to 7 (lowest priority), while the `i` directive is a boolean flag.
Represents the `priority` header, used to indicate the relative importance of an HTTP request.

def << value

@parameter value [String] the directive to add to the header.

Add a value to the priority header.
def << value
	super(value.downcase)
end

def incremental?

@returns [Boolean] whether the request should be delivered incrementally.

The `i` directive, when present, indicates that the response can be delivered incrementally as data becomes available.

Checks if the response should be delivered incrementally.
def incremental?
	self.include?("i")
end

def initialize(value = nil)

@parameter value [String | Nil] the value of the priority header, if any. The value should be a comma-separated string of directives.

Initialize the priority header with the given value.
def initialize(value = nil)
	super(value&.downcase)
end

def urgency(default = DEFAULT_URGENCY)

@returns [Integer | Nil] the urgency level if specified, or `nil` if not present.

Returns the urgency level if specified. 0 is the highest priority, and 7 is the lowest.
def urgency(default = DEFAULT_URGENCY)
	if value = self.find { |value| value.start_with?("u=") }
		_, level = value.split("=", 2)
		return level.to_i
	end
	
	return default
end