module Sprockets::HTTPUtils
def find_q_matches(q_values, available, &matcher)
Experimental RBS support (using type sampling data from the type_fusion
project).
def find_q_matches: (Array[Array, String, Float] q_values, (Array[] | Array[Hash, filename, String, type, String]) available, ) -> Array[Hash, filename, String, type, String]
This signature was generated using 28 samples from 4 applications.
Adapted from Rack::Utils#q_values.
Internal: Find all qvalue matches from an Array of available options.
def find_q_matches(q_values, available, &matcher) matcher ||= lambda { |a, b| a == b } matches = [] case q_values when Array when String q_values = parse_q_values(q_values) when NilClass q_values = [] else raise TypeError, "unknown q_values type: #{q_values.class}" end i = 0 q_values.each do |accepted, quality| if match = available.find { |option| matcher.call(option, accepted) } i += 1 matches << [-quality, i, match] end end matches.sort! matches.map! { |_, _, match| match } matches end