Class: Sinatra::Request::MimeTypeEntry
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/sinatra/base.rb |
Class Method Summary
- .new(entry) ⇒ MimeTypeEntry constructor
Instance Attribute Summary
- #params readonly
Instance Method Summary
Constructor Details
.new(entry) ⇒ MimeTypeEntry
# File 'lib/sinatra/base.rb', line 140
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 = params.to_h end
Instance Attribute Details
#params (readonly)
[ GitHub ]# File 'lib/sinatra/base.rb', line 138
attr_reader :params
Instance Method Details
#accepts?(entry) ⇒ Boolean
# File 'lib/sinatra/base.rb', line 151
def accepts?(entry) File.fnmatch(entry, self) && matches_params?(entry.params) end
#matches_params?(params) ⇒ Boolean
#to_str
[ GitHub ]# File 'lib/sinatra/base.rb', line 155
def to_str @type end