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
-
#name ⇒ Object
Returns the value of attribute name.
-
#order ⇒ Object
Returns the value of attribute order.
-
#q ⇒ Object
Returns the value of attribute q.
Instance Method Summary collapse
- #<=>(item) ⇒ Object
- #==(item) ⇒ Object
-
#initialize(order, name, q = nil) ⇒ AcceptItem
constructor
A new instance of AcceptItem.
- #to_s ⇒ Object
Constructor Details
#initialize(order, name, q = nil) ⇒ AcceptItem
Returns a new instance of AcceptItem.
60 61 62 63 64 65 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 60 def initialize(order, name, q=nil) @order = order @name = name.strip q ||= 0.0 if @name == Mime::ALL # default wildcard match to end of list @q = ((q || 1.0).to_f * 100).to_i end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
58 59 60 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 58 def name @name end |
#order ⇒ Object
Returns the value of attribute order
58 59 60 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 58 def order @order end |
#q ⇒ Object
Returns the value of attribute q
58 59 60 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 58 def q @q end |
Instance Method Details
#<=>(item) ⇒ Object
71 72 73 74 75 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 71 def <=>(item) result = item.q <=> q result = order <=> item.order if result == 0 result end |
#==(item) ⇒ Object
77 78 79 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 77 def ==(item) name == (item.respond_to?(:name) ? item.name : item) end |
#to_s ⇒ Object
67 68 69 |
# File 'actionpack/lib/action_dispatch/http/mime_type.rb', line 67 def to_s @name end |