class Rack::Accept::Charset
Represents an HTTP Accept-Charset header according to the HTTP 1.1 specification, and provides several convenience methods for determining acceptable character sets.
Public Instance Methods
Source
# File lib/rack/accept/charset.rb 27 def matches(charset) 28 values.select {|v| 29 v == charset || v == '*' 30 }.sort {|a, b| 31 # "*" gets least precedence, any others should be equal. 32 a == '*' ? 1 : (b == '*' ? -1 : 0) 33 } 34 end
Returns an array of character sets from this header that match the given charset
, ordered by precedence.
Source
# File lib/rack/accept/charset.rb 11 def name 12 'Accept-Charset' 13 end
The name of this header.
Source
# File lib/rack/accept/charset.rb 16 def qvalue(charset) 17 m = matches(charset) 18 if m.empty? 19 charset == 'iso-8859-1' ? 1 : 0 20 else 21 normalize_qvalue(@qvalues[m.first]) 22 end 23 end
Determines the quality factor (qvalue) of the given charset
.