Class: Mime::Type::AcceptItem
- 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
-
#index ⇒ Object
Returns the value of attribute index.
-
#name ⇒ Object
(also: #to_s)
Returns the value of attribute name.
-
#q ⇒ Object
Returns the value of attribute q.
Instance Method Summary collapse
- #<=>(item) ⇒ Object
- #==(item) ⇒ Object
-
#initialize(index, name, q = nil) ⇒ AcceptItem
constructor
A new instance of AcceptItem.
Constructor Details
#initialize(index, name, q = nil) ⇒ AcceptItem
Returns a new instance of AcceptItem.
65 66 67 68 69 70 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 65 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
#index ⇒ Object
Returns the value of attribute index
62 63 64 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 62 def index @index end |
#name ⇒ Object Also known as: to_s
Returns the value of attribute name
62 63 64 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 62 def name @name end |
#q ⇒ Object
Returns the value of attribute q
62 63 64 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 62 def q @q end |
Instance Method Details
#<=>(item) ⇒ Object
72 73 74 75 76 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 72 def <=>(item) result = item.q <=> @q result = @index <=> item.index if result == 0 result end |
#==(item) ⇒ Object
78 79 80 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 78 def ==(item) @name == item.to_s end |