# File lib/openid/yadis/accept.rb, line 8
    def self.generate_accept_header(*elements)
      parts = []
      elements.each { |element|
        if element.is_a?(String)
          qs = "1.0"
          mtype = element
        else
          mtype, q = element
          q = q.to_f
          if q > 1 or q <= 0
            raise ArgumentError.new("Invalid preference factor: #{q}")
          end
          qs = sprintf("%0.1f", q)
        end

        parts << [qs, mtype]
      }

      parts.sort!
      chunks = []
      parts.each { |q, mtype|
        if q == '1.0'
          chunks << mtype
        else
          chunks << sprintf("%s; q=%s", mtype, q)
        end
      }

      return chunks.join(', ')
    end