class WebApp::QueryString
QueryString represents a query component of URI.
Constants
- PctEncoded
Public Class Methods
html_form(arg, sep=';')
click to toggle source
# File webapp/querystring.rb, line 46 def QueryString.html_form(arg, sep=';') case arg when Array QueryString.html_form_array(arg, sep) when Hash QueryString.html_form_hash(arg, sep) else raise ArgumentError, "array or hash expected: #{arg.inspect}" end end
new(escaped)
click to toggle source
# File webapp/querystring.rb, line 34 def initialize(escaped) if /\A(?:[#{QueryChars}]|#{PctEncoded})*\z/o !~ escaped raise ArgumentError, "not properly escaped: #{escaped.inspect}" end @escaped_query_string = escaped end
Public Instance Methods
decode_as_application_x_www_form_urlencoded()
click to toggle source
decode self as application/x-www-form-urlencoded and returns HTMLFormQuery object.
# File webapp/htmlform.rb, line 32 def decode_as_application_x_www_form_urlencoded # xxx: warning if invalid? pairs = [] @escaped_query_string.scan(/([^&;=]*)=([^&;]*)/) {|key, val| key.gsub!(/\+/, ' ') key.gsub!(/%([0-9A-F][0-9A-F])/i) { [$1].pack("H*") } val.gsub!(/\+/, ' ') val.gsub!(/%([0-9A-F][0-9A-F])/i) { [$1].pack("H*") } pairs << [key.freeze, val.freeze] } HTMLFormQuery.new(pairs) end
inspect()
click to toggle source
# File webapp/querystring.rb, line 41 def inspect "#<#{self.class}: #{@escaped_query_string}>" end
Also aliased as: to_s