Class: Mime::Type::AcceptItem
- Defined in:
- lib/action_controller/mime_type.rb
Overview
A simple helper class used in parsing the accept header
Instance Attribute Summary collapse
-
#name ⇒ Object
:nodoc:.
-
#order ⇒ Object
:nodoc:.
-
#q ⇒ Object
:nodoc:.
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.
20 21 22 23 24 25 |
# File 'lib/action_controller/mime_type.rb', line 20 def initialize(order, name, q=nil) @order = order @name = name.strip q ||= 0.0 if @name == "*/*" # default "*/*" to end of list @q = ((q || 1.0).to_f * 100).to_i end |
Instance Attribute Details
#name ⇒ Object
:nodoc:
18 19 20 |
# File 'lib/action_controller/mime_type.rb', line 18 def name @name end |
#order ⇒ Object
:nodoc:
18 19 20 |
# File 'lib/action_controller/mime_type.rb', line 18 def order @order end |
Instance Method Details
#<=>(item) ⇒ Object
31 32 33 34 35 |
# File 'lib/action_controller/mime_type.rb', line 31 def <=>(item) result = item.q <=> q result = order <=> item.order if result == 0 result end |
#==(item) ⇒ Object
37 38 39 |
# File 'lib/action_controller/mime_type.rb', line 37 def ==(item) name == (item.respond_to?(:name) ? item.name : item) end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/action_controller/mime_type.rb', line 27 def to_s @name end |