Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
CGI::QueryExtension#[]
[](key)
lib/cgi/core.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/cgi/core.rb, line 714
def [](key)
params = @params[key]
return '' unless params
value = params[0]
if @multipart
if value
return value
elsif defined? StringIO
StringIO.new("".b)
else
Tempfile.new("CGI",encoding: Encoding::ASCII_8BIT)
end
else
str = if value then value.dup else "" end
str
end
end
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.