Class: Mime::Type::AcceptItem

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/http/mime_type.rb

Overview

A simple helper class used in parsing the accept header

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (AcceptItem) initialize(index, name, q = nil)

Returns a new instance of AcceptItem



66
67
68
69
70
71
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 66

def initialize(index, name, q = nil)
  @index = index
  @name = name
  q ||= 0.0 if @name == Mime::ALL.to_s # default wildcard match to end of list
  @q = ((q || 1.0).to_f * 100).to_i
end

Instance Attribute Details

- (Object) index

:nodoc:



63
64
65
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 63

def index
  @index
end

- (Object) name Also known as: to_s

:nodoc:



63
64
65
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 63

def name
  @name
end

- (Object) q

:nodoc:



63
64
65
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 63

def q
  @q
end

Instance Method Details

- (Object) <=>(item)



73
74
75
76
77
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 73

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

- (Object) ==(item)



79
80
81
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 79

def ==(item)
  @name == item.to_s
end