CGI::QueryExtension (Module)

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.

Classes and Modules

Class CGI::QueryExtension::Value

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 1156
    def [](key)
      params = @params[key]
      value = params[0]
      if @multipart
        if value
          return value
        elsif defined? StringIO
          StringIO.new("")
        else
          Tempfile.new("CGI")
        end
      else
        Value.new(value || "", params)
      end
    end

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

[Source]

# File cgi.rb, line 1178
    def has_key?(*args)
      @params.has_key?(*args)
    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 1173
    def keys(*args)
      @params.keys(*args)
    end

[Source]

# File cgi.rb, line 1124
    def multipart?
      @multipart
    end

Set all the parameters.

[Source]

# File cgi.rb, line 961
    def params=(hash)
      @params.clear
      @params.update(hash)
    end

Get the raw cookies as a string.

[Source]

# File cgi.rb, line 944
    def raw_cookie
      env_table["HTTP_COOKIE"]
    end

Get the raw RFC2965 cookies as a string.

[Source]

# File cgi.rb, line 949
    def raw_cookie2
      env_table["HTTP_COOKIE2"]
    end

[Validate]