lib/wants/mimeparse.rb
def best_match(supported, header)
    parsed_header = header.split(",").map { |r| parse_media_range(r) }

    weighted_matches = supported.map do |mime_type|
      [fitness_and_quality_parsed(mime_type, parsed_header), mime_type]
    end

    weighted_matches.sort!

    weighted_matches.last[0][1].zero? ? nil : weighted_matches.last[1]
  end
def best_match(supported, header)
    parsed_header = header.split(",").map { |r| parse_media_range(r) }

    weighted_matches = supported.map do |mime_type|
      [fitness_and_quality_parsed(mime_type, parsed_header), mime_type]
    end

    weighted_matches.sort!

    weighted_matches.last[0][1].zero? ? nil : weighted_matches.last[1]
  end
Takes a list of supported mime-types and finds the best match
  for all the media-ranges listed in header. The value of header
  must be a string that conforms to the format of the HTTP Accept:
  header. The value of supported is an Enumerable of mime-types

     irb> best_match(["application/xbel+xml", "text/xml"], "text/*;q=0.5,*/*; q=0.1")
     => "text/xml"