lib/ronin/extensions/uri/query_params.rb in ronin-0.2.4 vs lib/ronin/extensions/uri/query_params.rb in ronin-0.3.0
- old
+ new
@@ -1,9 +1,7 @@
#
-#--
-# Ronin - A Ruby platform designed for information security and data
-# exploration tasks.
+# Ronin - A Ruby platform for exploit development and security research.
#
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,11 +14,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#++
#
require 'cgi'
module URI
@@ -39,22 +36,45 @@
parse_query_params
end
#
- # Sets the query data and updates query_params.
+ # Sets the query string and updates query_params.
#
+ # @param [String] query_str
+ # The new URI query string to use.
+ #
+ # @return [String]
+ # The new URI query string.
+ #
+ # @example
+ # url.query = 'a=1&b=2'
+ # # => "a=1&b=2"
+ #
def query=(query_str)
new_query = super(query_str)
parse_query_params
return new_query
end
#
- # Iterates over every query parameter, passing each to the given
- # _block_.
+ # Iterates over every query parameter.
#
+ # @yield [name, value]
+ # The block to pass each query parameter to.
+ #
+ # @yieldparam [String] name
+ # The name of the query parameter.
+ #
+ # @yieldparam [String] value
+ # The value of the query parameter.
+ #
+ # @example
+ # url.each_query_param do |name,value|
+ # puts "#{name} = #{value}"
+ # end
+ #
def each_query_param(&block)
@query_params.each(&block)
end
protected
@@ -79,10 +99,9 @@
end
end
private
- # :nodoc
def path_query
str = @path
unless @query_params.empty?
str += '?' + @query_params.to_a.map { |name,value|