class Sinatra::Request::MimeTypeEntry

Attributes

params[R]

Public Class Methods

new(entry) click to toggle source
    # File lib/sinatra/base.rb
140 def initialize(entry)
141   params = entry.scan(HEADER_PARAM).map! do |s|
142     key, value = s.strip.split('=', 2)
143     value = value[1..-2].gsub(/\\(.)/, '\1') if value.start_with?('"')
144     [key, value]
145   end
146 
147   @type   = entry[/[^;]+/].delete(' ')
148   @params = params.to_h
149 end

Public Instance Methods

accepts?(entry) click to toggle source
    # File lib/sinatra/base.rb
151 def accepts?(entry)
152   File.fnmatch(entry, self) && matches_params?(entry.params)
153 end
matches_params?(params) click to toggle source
    # File lib/sinatra/base.rb
159 def matches_params?(params)
160   return true if @params.empty?
161 
162   params.all? { |k, v| !@params.key?(k) || @params[k] == v }
163 end
to_str() click to toggle source
    # File lib/sinatra/base.rb
155 def to_str
156   @type
157 end