class Ocular::Inputs::HTTP::Input::Request::AcceptEntry

Attributes

entry[R]
params[RW]

Public Class Methods

new(entry) click to toggle source
# File lib/ocular/inputs/http_input.rb, line 163
def initialize(entry)
    params = entry.scan(HEADER_PARAM).map! do |s|
        key, value = s.strip.split('=', 2)
        value = value[1..-2].gsub(/\\(.)/, '\1') if value.start_with?('"')
        [key, value]
    end

    @entry  = entry
    @type   = entry[/[^;]+/].delete(' ')
    @params = Hash[params]
    @q      = @params.delete('q') { 1.0 }.to_f
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/ocular/inputs/http_input.rb, line 176
def <=>(other)
    other.priority <=> self.priority
end
method_missing(*args, &block) click to toggle source
# File lib/ocular/inputs/http_input.rb, line 197
def method_missing(*args, &block)
    to_str.send(*args, &block)
end
priority() click to toggle source
# File lib/ocular/inputs/http_input.rb, line 180
def priority
    # We sort in descending order; better matches should be higher.
    [ @q, -@type.count('*'), @params.size ]
end
respond_to?(*args) click to toggle source
Calls superclass method
# File lib/ocular/inputs/http_input.rb, line 193
def respond_to?(*args)
    super or to_str.respond_to?(*args)
end
to_s(full = false) click to toggle source
# File lib/ocular/inputs/http_input.rb, line 189
def to_s(full = false)
    full ? entry : to_str
end
to_str() click to toggle source
# File lib/ocular/inputs/http_input.rb, line 185
def to_str
    @type
end