Class: Sinatra::Request::AcceptEntry

### Home Classes Methods

### In Files

- lib/sinatra/base.rb

### Parent

Object

### Methods

- ::new
- #<=>
- #method_missing
- #priority
- #respond_to?
- #to_s
- #to_str

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Sinatra
- Sinatra::Application
- Sinatra::CommonLogger
- Sinatra::ExtendedRack
- Sinatra::Helpers
- Sinatra::Helpers::Stream
- Sinatra::Helpers::Stream::Application
- Sinatra::Helpers::Stream::Base
- Sinatra::Helpers::Stream::Templates
- Sinatra::Helpers::Stream::Templates::ContentTyped
- Sinatra::Helpers::Stream::Wrapper
- Sinatra::Request
- Sinatra::Request::AcceptEntry
- Sinatra::Response
- Sinatra::ShowExceptions
- Rack
- Rack::Builder

No matching classes.

# Sinatra::Request::AcceptEntry

### Attributes

params[RW]

### Public Class Methods

new(entry) click to toggle source

    # File lib/sinatra/base.rb, line 76
    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 = Hash[params]
      @q      = @params.delete('q') { 1.0 }.to_f
    end

### Public Instance Methods

<=>(other) click to toggle source

    # File lib/sinatra/base.rb, line 89
    def <=>(other)
      other.priority <=> self.priority
    end

method_missing(*args, &block) click to toggle source

    # File lib/sinatra/base.rb, line 110
    def method_missing(*args, &block)
      to_str.send(*args, &block)
    end

priority() click to toggle source

    # File lib/sinatra/base.rb, line 93
    def priority
      # We sort in descending order; better matches should be higher.
      [ @q, -@type.count('*'), @params.size ]
    end

respond_to?(*args) click to toggle source

    # File lib/sinatra/base.rb, line 106
    def respond_to?(*args)
      super or to_str.respond_to?(*args)
    end

to_s(full = false) click to toggle source

    # File lib/sinatra/base.rb, line 102
    def to_s(full = false)
      full ? entry : to_str
    end

to_str() click to toggle source

    # File lib/sinatra/base.rb, line 98
    def to_str
      @type
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.