def query_values(return_type=Hash)
      empty_accumulator = Array == return_type ? [] : {}
      if return_type != Hash && return_type != Array
        raise ArgumentError, "Invalid return type. Must be Hash or Array."
      end
      return nil if self.query == nil
      split_query = self.query.split("&").map do |pair|
        pair.split("=", 2) if pair && !pair.empty?
      end.compact
      return split_query.inject(empty_accumulator.dup) do |accu, pair|
        # I'd rather use key/value identifiers instead of array lookups,
        # but in this case I really want to maintain the exact pair structure,
        # so it's best to make all changes in-place.
        pair[0] = URI.unencode_component(pair[0])
        if pair[1].respond_to?(:to_str)
          # I loathe the fact that I have to do this. Stupid HTML 4.01.
          # Treating '+' as a space was just an unbelievably bad idea.
          # There was nothing wrong with '%20'!
          # If it ain't broke, don't fix it!
          pair[1] = URI.unencode_component(pair[1].to_str.gsub(/\+/, " "))
        end
        if return_type == Hash
          accu[pair[0]] = pair[1]
        else
          accu << pair
        end
        accu
      end
    end
def query_values(return_type=Hash)
      empty_accumulator = Array == return_type ? [] : {}
      if return_type != Hash && return_type != Array
        raise ArgumentError, "Invalid return type. Must be Hash or Array."
      end
      return nil if self.query == nil
      split_query = self.query.split("&").map do |pair|
        pair.split("=", 2) if pair && !pair.empty?
      end.compact
      return split_query.inject(empty_accumulator.dup) do |accu, pair|
        # I'd rather use key/value identifiers instead of array lookups,
        # but in this case I really want to maintain the exact pair structure,
        # so it's best to make all changes in-place.
        pair[0] = URI.unencode_component(pair[0])
        if pair[1].respond_to?(:to_str)
          # I loathe the fact that I have to do this. Stupid HTML 4.01.
          # Treating '+' as a space was just an unbelievably bad idea.
          # There was nothing wrong with '%20'!
          # If it ain't broke, don't fix it!
          pair[1] = URI.unencode_component(pair[1].to_str.gsub(/\+/, " "))
        end
        if return_type == Hash
          accu[pair[0]] = pair[1]
        else
          accu << pair
        end
        accu
      end
    end
Converts the query component to a Hash value.

 @param [Class] return_type The return type desired. Value must be either
   `Hash` or `Array`.

 @return [Hash, Array, nil] The query string parsed as a Hash or Array
   or nil if the query string is blank.

 @example
   Addressable::URI.parse("?one=1&two=2&three=3").query_values
   #=> {"one" => "1", "two" => "2", "three" => "3"}
   Addressable::URI.parse("?one=two&one=three").query_values(Array)
   #=> [["one", "two"], ["one", "three"]]
   Addressable::URI.parse("?one=two&one=three").query_values(Hash)
   #=> {"one" => "three"}
   Addressable::URI.parse("?").query_values
   #=> {}
   Addressable::URI.parse("").query_values
   #=> nil