class Sinatra::Request::MimeTypeEntry
Attributes
params[R]
Public Class Methods
new(entry)
click to toggle source
# File lib/sinatra/base.rb, line 127 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 @type = entry[/[^;]+/].delete(' ') @params = Hash[params] end
Public Instance Methods
accepts?(entry)
click to toggle source
# File lib/sinatra/base.rb, line 138 def accepts?(entry) File.fnmatch(entry, self) && matches_params?(entry.params) end
matches_params?(params)
click to toggle source
# File lib/sinatra/base.rb, line 146 def matches_params?(params) return true if @params.empty? params.all? { |k,v| !@params.has_key?(k) || @params[k] == v } end
to_str()
click to toggle source
# File lib/sinatra/base.rb, line 142 def to_str @type end