module AcceptHeaders::Acceptable
Attributes
q[R]
Public Instance Methods
accept?(other)
click to toggle source
# File lib/accept_headers/acceptable.rb, line 16 def accept?(other) if q == 0.0 false else match(other) end end
match(other)
click to toggle source
# File lib/accept_headers/acceptable.rb, line 39 def match(other) raise NotImplementedError.new("#match is not implemented") end
q=(value)
click to toggle source
# File lib/accept_headers/acceptable.rb, line 24 def q=(value) begin q_float = Float(value) rescue ArgumentError => e raise InvalidQError.new(e.message) end if !q_float.between?(0.0, 1.0) raise InvalidQError.new("q must be between 0 and 1") end if q_float.to_s.match(/^\d\.(\d+)$/) && $1 && $1.size > 3 raise InvalidQError.new("q must be at most 3 decimal places") end @q = q_float end
reject?(other)
click to toggle source
# File lib/accept_headers/acceptable.rb, line 8 def reject?(other) if q != 0.0 false else match(other) end end