class Sinatra::Request::MimeTypeEntry

Attributes

params[R]

Public Class Methods

new(entry) click to toggle source
    # File lib/sinatra/base.rb
132 def initialize(entry)
133   params = entry.scan(HEADER_PARAM).map! do |s|
134     key, value = s.strip.split('=', 2)
135     value = value[1..-2].gsub(/\\(.)/, '\1') if value.start_with?('"')
136     [key, value]
137   end
138 
139   @type   = entry[/[^;]+/].delete(' ')
140   @params = params.to_h
141 end

Public Instance Methods

accepts?(entry) click to toggle source
    # File lib/sinatra/base.rb
143 def accepts?(entry)
144   File.fnmatch(entry, self) && matches_params?(entry.params)
145 end
matches_params?(params) click to toggle source
    # File lib/sinatra/base.rb
151 def matches_params?(params)
152   return true if @params.empty?
153 
154   params.all? { |k, v| !@params.key?(k) || @params[k] == v }
155 end
to_str() click to toggle source
    # File lib/sinatra/base.rb
147 def to_str
148   @type
149 end