class Sinatra::Request::AcceptEntry
def <=>(other)
def <=>(other) other.priority <=> self.priority end
def [](param)
def [](param) @params[param] end
def initialize(entry)
def initialize(entry) params = entry.scan(HEADER_PARAM).map do |s| key, value = s.strip.split('=', 2) value = value[1..-2].gsub(/\\(.)/, '\1') if value.start_with?('"') [key, value] end @type = entry[/[^;]+/].delete(' ') @params = Hash[params] @q = @params.delete('q') { "1.0" }.to_f end
def priority
def priority # We sort in descending order; better matches should be higher. [ @q, -@type.count('*'), @params.size ] end
def to_str
def to_str @type end