CGI.new(tag_maker) { block }CGI.new(options_hash = {}) { block } Class Public methods Create a new CGI instance. tag_maker This is the same as using the options_hash form with the value { :tag_maker => tag_maker } Note that it is recommended to use the options_hash form, since it also allows you specify the charset you will accept. options_hash A Hash that recognizes two options: :accept_charset specifies encoding of received query string. If omitted, @@accept_charset
parse(query) Class Public methods Parse an HTTP query string into a hash of key=>value pairs. params = CGI::parse("query_string") # {"name1" => ["value1", "value2", ...], # "name2" => ["value1", "value2", ...], ... }
pretty(string, shift = " ") Class Public methods Prettify (indent) an HTML string. string is the HTML string to indent. shift is the indentation unit to use; it defaults to two spaces. print CGI::pretty("<HTML><BODY></BODY></HTML>") # <HTML> # <BODY> # </BODY> # </HTML> print CGI::pretty("<HTML><BODY></BODY></HTML>", "\t") # <HTML> # <BODY> # </BODY> # <
rfc1123_date(time) Class Public methods Format a Time object as a String using the format specified by RFC 1123. CGI::rfc1123_date(Time.now) # Sat, 01 Jan 2000 00:00:00 GMT
unescape(string,encoding=@@accept_charset) Class Public methods URL-decode a string with encoding(optional). string = CGI::unescape("%27Stop%21%27+said+Fred") # => "'Stop!' said Fred"
unescapeElement(string, *elements) Class Public methods Undo escaping such as that done by ::escapeElement print CGI::unescapeElement( CGI::escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG") # "<BR><A HREF="url"></A>" print CGI::unescapeElement( CGI::escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"]) # "<BR><A HREF="url"></A>"
unescapeHTML(string) Class Public methods Unescape a string that has been HTML-escaped CGI::unescapeHTML("Usage: foo "bar" <baz>") # => "Usage: foo \"bar\" <baz>"
unescape_element(str) Class Public methods Synonym for ::unescapeElement
unescape_html(str) Class Public methods Synonym for ::unescapeHTML
header(options='text/html') Instance Public methods This method is an alias for http_header, when HTML5 tag maker is inactive. NOTE: use http_header to create HTTP header blocks, this alias is only provided for backwards compatibility. Using header with the HTML5 tag maker will create a <header> element. http_header
Page 113 of 11844