Class: Sinatra::Request::AcceptEntry
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/sinatra/base.rb |
Class Method Summary
- .new(entry) ⇒ AcceptEntry constructor
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new(entry) ⇒ AcceptEntry
# File 'lib/sinatra/base.rb', line 98
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 = params.to_h @q = @params.delete('q') { 1.0 }.to_f end
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block)
[ GitHub ]# File 'lib/sinatra/base.rb', line 132
def method_missing(*args, &block) to_str.send(*args, &block) end
Instance Attribute Details
#entry (readonly)
[ GitHub ]# File 'lib/sinatra/base.rb', line 96
attr_reader :entry
#params (rw)
[ GitHub ]# File 'lib/sinatra/base.rb', line 95
attr_accessor :params
Instance Method Details
#<=>(other)
[ GitHub ]#priority
[ GitHub ]# File 'lib/sinatra/base.rb', line 115
def priority # We sort in descending order; better matches should be higher. [@q, -@type.count('*'), @params.size] end
#respond_to?(*args) ⇒ Boolean
# File 'lib/sinatra/base.rb', line 128
def respond_to?(*args) super || to_str.respond_to?(*args) end
#to_s(full = false)
[ GitHub ]#to_str
[ GitHub ]# File 'lib/sinatra/base.rb', line 120
def to_str @type end