123456789_123456789_123456789_123456789_123456789_

Class: Mime::Type::AcceptItem

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: actionpack/lib/action_dispatch/http/mime_type.rb

Overview

A simple helper class used in parsing the accept header.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(index, name, q = nil) ⇒ AcceptItem

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 94

def initialize(index, name, q = nil)
  @index = index
  @name = name
  q ||= 0.0 if @name == "*/*" # Default wildcard match to end of list.
  @q = ((q || 1.0).to_f * 100).to_i
end

Instance Attribute Details

#index (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 91

attr_accessor :index, :name, :q

#name (rw) Also known as: #to_s

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 91

attr_accessor :index, :name, :q

#q (rw)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 91

attr_accessor :index, :name, :q

#to_s (readonly)

Alias for #name.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 92

alias :to_s :name

Instance Method Details

#<=>(item)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 101

def <=>(item)
  result = item.q <=> @q
  result = @index <=> item.index if result == 0
  result
end