### Home Classes Methods

### In Files

- lib/merb-core/controller/mixins/responder.rb

### Parent

Object

### Methods

- ::new
- #<=>
- #==
- #eql?
- #hash
- #mime
- #super_range
- #synonyms
- #to_s
- #to_sym

### Files

- CHANGELOG
- LICENSE
- README
- TODO

### Class/Module Index

Quicksearch

- Merb
- Merb::AbstractController
- Merb::AcceptType
- Merb::AuthenticationMixin
- Merb::AuthenticationMixin::BasicAuthentication
- Merb::BootLoader
- Merb::BootLoader::AfterAppLoads
- Merb::BootLoader::BackgroundServices
- Merb::BootLoader::BeforeAppLoads
- Merb::BootLoader::BuildFramework
- Merb::BootLoader::ChooseAdapter
- Merb::BootLoader::Cookies
- Merb::BootLoader::Defaults
- Merb::BootLoader::Dependencies
- Merb::BootLoader::DropPidFile
- Merb::BootLoader::LoadClasses
- Merb::BootLoader::Logger
- Merb::BootLoader::MimeTypes
- Merb::BootLoader::MixinSession
- Merb::BootLoader::RackUpApplication
- Merb::BootLoader::ReloadClasses
- Merb::BootLoader::ReloadClasses::TimedExecutor
- Merb::BootLoader::Router
- Merb::BootLoader::SetupSession
- Merb::BootLoader::SetupStubClasses
- Merb::BootLoader::Templates
- Merb::ConditionalGetMixin
- Merb::Config
- Merb::Config::ConfigBlock
- Merb::Const
- Merb::Controller
- Merb::ControllerExceptions
- Merb::ControllerExceptions::Accepted
- Merb::ControllerExceptions::ActionNotFound
- Merb::ControllerExceptions::BadGateway
- Merb::ControllerExceptions::BadRequest
- Merb::ControllerExceptions::Base
- Merb::ControllerExceptions::ClientError
- Merb::ControllerExceptions::Conflict
- Merb::ControllerExceptions::Continue
- Merb::ControllerExceptions::Created
- Merb::ControllerExceptions::ExpectationFailed
- Merb::ControllerExceptions::Forbidden
- Merb::ControllerExceptions::GatewayTimeout
- Merb::ControllerExceptions::Gone
- Merb::ControllerExceptions::HTTPVersionNotSupported
- Merb::ControllerExceptions::Informational
- Merb::ControllerExceptions::InternalServerError
- Merb::ControllerExceptions::LayoutNotFound
- Merb::ControllerExceptions::LengthRequired
- Merb::ControllerExceptions::MethodNotAllowed
- Merb::ControllerExceptions::MovedPermanently
- Merb::ControllerExceptions::MovedTemporarily
- Merb::ControllerExceptions::MultiPartParseError
- Merb::ControllerExceptions::MultipleChoices
- Merb::ControllerExceptions::NoContent
- Merb::ControllerExceptions::NonAuthoritativeInformation
- Merb::ControllerExceptions::NotAcceptable
- Merb::ControllerExceptions::NotFound
- Merb::ControllerExceptions::NotImplemented
- Merb::ControllerExceptions::NotModified
- Merb::ControllerExceptions::OK
- Merb::ControllerExceptions::PartialContent
- Merb::ControllerExceptions::PaymentRequired
- Merb::ControllerExceptions::PreconditionFailed
- Merb::ControllerExceptions::ProxyAuthenticationRequired
- Merb::ControllerExceptions::Redirection
- Merb::ControllerExceptions::RequestEntityTooLarge
- Merb::ControllerExceptions::RequestRangeNotSatisfiable
- Merb::ControllerExceptions::RequestTimeout
- Merb::ControllerExceptions::RequestURITooLarge
- Merb::ControllerExceptions::ResetContent
- Merb::ControllerExceptions::SeeOther
- Merb::ControllerExceptions::ServerError
- Merb::ControllerExceptions::ServiceUnavailable
- Merb::ControllerExceptions::Successful
- Merb::ControllerExceptions::SwitchingProtocols
- Merb::ControllerExceptions::TemplateNotFound
- Merb::ControllerExceptions::TemporaryRedirect
- Merb::ControllerExceptions::Unauthorized
- Merb::ControllerExceptions::UnsupportedMediaType
- Merb::ControllerExceptions::UseProxy
- Merb::ControllerMixin
- Merb::CookieSession
- Merb::CookieSession::CookieOverflow
- Merb::CookieSession::TamperedWithCookie
- Merb::Cookies
- Merb::CookiesMixin
- Merb::CookiesMixin::RequestMixin
- Merb::Counter
- Merb::Dispatcher
- Merb::Dispatcher::DefaultException
- Merb::Dispatcher::DefaultExceptionHelper
- Merb::GlobalHelpers
- Merb::InlineTemplates
- Merb::Logger
- Merb::MemcacheSession
- Merb::MemcacheStore
- Merb::MemorySession
- Merb::MemorySessionStore
- Merb::Parse
- Merb::Plugins
- Merb::Rack
- Merb::Rack::AbstractAdapter
- Merb::Rack::Adapter
- Merb::Rack::Application
- Merb::Rack::ConditionalGet
- Merb::Rack::Console
- Merb::Rack::ContentLength
- Merb::Rack::DeferrableMiddleware
- Merb::Rack::Ebb
- Merb::Rack::EventedMongrel
- Merb::Rack::FastCGI
- Merb::Rack::Handler
- Merb::Rack::Handler::Mongrel
- Merb::Rack::Head
- Merb::Rack::Helpers
- Merb::Rack::Irb
- Merb::Rack::Middleware
- Merb::Rack::Mongrel
- Merb::Rack::PathPrefix
- Merb::Rack::Profiler
- Merb::Rack::Runner
- Merb::Rack::Static
- Merb::Rack::StreamWrapper
- Merb::Rack::SwiftipliedMongrel
- Merb::Rack::Thin
- Merb::Rack::ThinTurbo
- Merb::Rack::Tracer
- Merb::Rack::WEBrick
- Merb::RenderMixin
- Merb::RenderMixin::ClassMethods
- Merb::Request
- Merb::ReservedError
- Merb::Responder
- Merb::ResponderMixin
- Merb::ResponderMixin::ClassMethods
- Merb::ResponderMixin::ContentTypeAlreadySet
- Merb::Router
- Merb::Router::Behavior
- Merb::Router::Behavior::Error
- Merb::Router::Behavior::Proxy
- Merb::Router::CachedProc
- Merb::Router::GenerationError
- Merb::Router::NotCompiledError
- Merb::Router::Resources
- Merb::Router::RouteNotFound
- Merb::Server
- Merb::Session
- Merb::SessionContainer
- Merb::SessionMixin
- Merb::SessionMixin::NoSessionContainer
- Merb::SessionMixin::RequestMixin
- Merb::SessionMixin::RequestMixin::ClassMethods
- Merb::SessionMixin::SessionOverflow
- Merb::SessionStoreContainer
- Merb::System
- Merb::System::PortablePoller
- Merb::Template
- Merb::Template::Erubis
- Merb::Template::Erubis::Mixin
- Merb::Test
- Merb::Test::ControllerHelper
- Merb::Test::Cookie
- Merb::Test::CookieJar
- Merb::Test::ExampleGroup
- Merb::Test::Helpers
- Merb::Test::MakeRequest
- Merb::Test::Matchers
- Merb::Test::MultipartRequestHelper
- Merb::Test::MultipartRequestHelper::FileParam
- Merb::Test::MultipartRequestHelper::Param
- Merb::Test::MultipartRequestHelper::Post
- Merb::Test::RequestHelper
- Merb::Test::RequestHelper::CookieJar
- Merb::Test::RequestHelper::FakeRequest
- Merb::Test::RouteHelper
- Merb::Test::Rspec
- Merb::Test::Rspec::ControllerMatchers
- Merb::Test::Rspec::ControllerMatchers::BeError
- Merb::Test::Rspec::ControllerMatchers::BeRedirect
- Merb::Test::Rspec::ControllerMatchers::Provide
- Merb::Test::Rspec::RouteMatchers
- Merb::Test::Rspec::RouteMatchers::ParameterMatcher
- Merb::Test::Rspec::RouteMatchers::RouteToMatcher
- Merb::Test::ViewHelper
- Merb::Test::WebratHelper
- Merb::Worker
- Erubis
- Erubis::Basic
- Erubis::Basic::Converter
- Erubis::BlockAwareEnhancer
- Erubis::BlockAwareEruby
- Erubis::MEruby
- Spec
- Spec::Matchers
- Spec::Matchers::MatcherDSL
- Spec::Runner
- Spec::Runner::Formatter
- Spec::Runner::Formatter::BaseTextFormatter
- Gem
- Gem::Dependency
- Hpricot
- Hpricot::Elem
- Mongrel
- Mongrel::HttpResponse
- Class
- Exception
- Hash
- Kernel
- MemCache
- Memcached
- Object
- String
- Time

No matching classes.

# Merb::AcceptType

### Attributes

index[R]
media_range[R]
quality[R]
sub_type[R]
type[R]

### Public Class Methods

new(entry,index) click to toggle source

#### Parameters

entry<String> | The accept type pattern
index<Fixnum> | The index used for sorting accept types. A lower value indicates higher priority.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 417
    def initialize(entry,index)
      @index = index

      entry =~ /\s*([^;\s]*)\s*(;\s*q=\s*(.*))?/
      @media_range, quality = $1, $3

      @type, @sub_type = @media_range.split(%{/})
      (quality ||= 0.0) if @media_range == "*/*"
      @quality = quality ? (quality.to_f * 100).to_i : 100
      @quality *= (mime && mime[:default_quality] || 1)
    end

### Public Instance Methods

<=>(entry) click to toggle source

Compares two accept types for sorting purposes.

#### Parameters

entry<AcceptType> | The accept type to compare.

#### Returns

Fixnum | -1, 0 or 1, depending on whether entry has a lower, equal or higher priority than the accept type being compared.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 440
    def <=>(entry)
      if entry.quality == quality
        @index <=> entry.index
      else
        entry.quality <=> @quality
      end
    end

==(entry) click to toggle source

An alias for eql?.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 465
    def ==(entry); eql?(entry); end

eql?(entry) click to toggle source

#### Parameters

entry<AcceptType> | The accept type to compare.

#### Returns

Boolean | True if the accept types are equal, i.e. if the synonyms for this accept type includes the entry media range.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 458
    def eql?(entry)
      synonyms.include?(entry.media_range)
    end

hash() click to toggle source

#### Returns

Fixnum | A hash based on the super range.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 471
    def hash; super_range.hash; end

mime() click to toggle source

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 488
    def mime
      @mime ||= Merb.available_mime_types[Merb::ResponderMixin::MIMES[@media_range]]
    end

super_range() click to toggle source

#### Returns

String | The primary media range for this accept type, i.e. either the first synonym or, if none exist, the media range.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 498
    def super_range
      synonyms.first || @media_range
    end

synonyms() click to toggle source

#### Returns

Array | All Accept header values, such as "text/html", that match this type.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 478
    def synonyms
      return @syns if @syns
      if _mime = mime
        @syns = _mime[:accepts]
      else
        @syns = []
      end
    end

to_s() click to toggle source

#### Returns

String | The accept type as a string, i.e. the media range.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 515
    def to_s
      @media_range
    end

to_sym() click to toggle source

#### Returns

Symbol: The type as a symbol, e.g. :html.

:api: private

    # File lib/merb-core/controller/mixins/responder.rb, line 506
    def to_sym
      Merb.available_mime_types.select{|k,v|
        v[:accepts] == synonyms || v[:accepts][0] == synonyms[0]}.flatten.first
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.