Mixin module. It provides the follow functionality groups:
Access to CGI environment variables as methods. See documentation to the CGI class for a list of these variables.
Access to cookies, including the cookies attribute.
Access to parameters, including the params attribute, and overloading
to perform parameter value lookup by key.
The initialize_query method, for initialising the above mechanisms, handling multipart forms, and allowing the class to be used in “offline” mode.
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.
# File cgi.rb, line 1165
def [](key)
params = @params[key]
return '' unless params
value = params[0]
if @multipart
if value
return value
elsif defined? StringIO
StringIO.new("")
else
Tempfile.new("CGI")
end
else
str = if value then value.dup else "" end
str.extend(Value)
str.set_params(params)
str
end
end
Returns true if a given parameter key exists in the query.
# File cgi.rb, line 1191
def has_key?(*args)
@params.has_key?(*args)
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.