class Protocol::HTTP::Header::Accept

The ‘accept-content-type` header represents a list of content-types that the client can accept.

def << (value)

@parameter value [String] the value or values to add, separated by commas.

The input string is split into distinct entries and appended to the array.

Adds one or more comma-separated values to the header.
def << (value)
	self.concat(value.scan(SEPARATOR).map(&:strip))
end

def initialize(value = nil)

@parameter value [String] the value of the header.

Parse the `accept` header value into a list of content types.
def initialize(value = nil)
	if value
		super(value.scan(SEPARATOR).map(&:strip))
	end
end

def media_ranges

@returns [Array(Charset)] the list of content types and their associated parameters.

Parse the `accept` header.
def media_ranges
	self.map do |value|
		self.parse_media_range(value)
	end
end

def parse_media_range(value)

def parse_media_range(value)
	if match = value.match(MEDIA_RANGE)
		type = match[:type]
		subtype = match[:subtype]
		parameters = {}
		
		match[:parameters].scan(PARAMETER) do |key, value, quoted_value|
			if quoted_value
				value = QuotedString.unquote(quoted_value)
			end
			
			parameters[key] = value
		end
		
		return MediaRange.new(type, subtype, parameters)
	else
		raise ParseError, "Invalid media type: #{value.inspect}"
	end
end

def to_s

@returns [String] the serialized representation of the header values.

Serializes the stored values into a comma-separated string.
def to_s
	join(",")
end