Method: Waves::Accept.parse
- Defined in:
- lib/waves/request/accept.rb
.parse(str) ⇒ Object
RFC 2616 section 14.1.
Returns an array of elements of the form:
- term, params
-
where is term is an array of MIME type components, with the true value as the wildcard (*)
and where params is a hash of parameters (q, level, etc.), where the q param is auto-converted to a float and defaulted to 1.0.
sorted by q value and then specificity, with ties going to HTML-related media-types
TODO parsing must be optimized. This parses Accept,
lang and charset
25 26 27 28 |
# File 'lib/waves/request/accept.rb', line 25 def Accept.parse(str) return self.new if str.nil? self.new( Accept.sort( str.split(',').map { |term| Accept.parse_media_type( term ) } ).uniq ) end |