Module CGI::QueryExtension
In: cgi.rb

Mixin module. It provides the follow functionality groups:

  1. Access to CGI environment variables as methods. See documentation to the CGI class for a list of these variables.
  2. Access to cookies, including the cookies attribute.
  3. Access to parameters, including the params attribute, and overloading
    to perform parameter value lookup by key.
  4. The initialize_query method, for initialising the above mechanisms, handling multipart forms, and allowing the class to be used in "offline" mode.

Methods

[]   has_key?   include?   key?   keys   multipart?   params=   raw_cookie   raw_cookie2  

External Aliases

path -> local_path

Attributes

cookies  [RW]  Get the cookies as a hash of cookie-name=>Cookie pairs.
params  [R]  Get the parameters as a hash of name=>values pairs, where values is an Array.

Public Instance methods

Get the value for the parameter with a given key.

If the parameter has multiple values, only the first will be retrieved; use params() to get the array of values.

[Source]

      # File cgi.rb, line 1159
1159:     def [](key)
1160:       params = @params[key]
1161:       value = params[0]
1162:       if @multipart
1163:         if value
1164:           return value
1165:         elsif defined? StringIO
1166:           StringIO.new("")
1167:         else
1168:           Tempfile.new("CGI")
1169:         end
1170:       else
1171:         str = if value then value.dup else "" end
1172:         str.extend(Value)
1173:         str.set_params(params)
1174:         str
1175:       end
1176:     end

Returns true if a given parameter key exists in the query.

[Source]

      # File cgi.rb, line 1184
1184:     def has_key?(*args)
1185:       @params.has_key?(*args)
1186:     end
include?(*args)

Alias for has_key?

key?(*args)

Alias for has_key?

Return all parameter keys as an array.

[Source]

      # File cgi.rb, line 1179
1179:     def keys(*args)
1180:       @params.keys(*args)
1181:     end

[Source]

      # File cgi.rb, line 1128
1128:     def multipart?
1129:       @multipart
1130:     end

Set all the parameters.

[Source]

     # File cgi.rb, line 962
962:     def params=(hash)
963:       @params.clear
964:       @params.update(hash)
965:     end

Get the raw cookies as a string.

[Source]

     # File cgi.rb, line 945
945:     def raw_cookie
946:       env_table["HTTP_COOKIE"]
947:     end

Get the raw RFC2965 cookies as a string.

[Source]

     # File cgi.rb, line 950
950:     def raw_cookie2
951:       env_table["HTTP_COOKIE2"]
952:     end

Search

Google

Ruby API Docs

Links