Sha256: 100e380e268e3bfdf77a7c6acb5faf38a7c2734f74aa59fd3c252a413330eb55
Contents?: true
Size: 901 Bytes
Versions: 3
Compression:
Stored size: 901 Bytes
Contents
require "accept_headers/acceptable" module AcceptHeaders class Encoding include Comparable include Acceptable attr_reader :encoding def initialize(encoding = '*', q: 1.0) self.encoding = encoding self.q = q end def <=>(other) q <=> other.q end def encoding=(value) @encoding = value.strip.downcase end def to_h { encoding: encoding, q: q } end def to_s qvalue = (q == 0 || q == 1) ? q.to_i : q "#{encoding};q=#{qvalue}" end def match(encoding_string) match_data = Negotiator::ENCODING_PATTERN.match(encoding_string) if !match_data false elsif encoding == match_data[:encoding] true elsif match_data[:encoding] == 'identity' true elsif encoding == '*' true else false end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
accept_headers-0.1.0 | lib/accept_headers/encoding.rb |
accept_headers-0.0.9 | lib/accept_headers/encoding.rb |
accept_headers-0.0.8 | lib/accept_headers/encoding.rb |