Ruby CGI methods
The following is a list of methods of the CGI class:
Serial number | Method description |
---|---|
1 | CGI::new([ level="query"]) Create a CGI object. query can be the following values:
|
CGI::escape(str)Use URL encoding to escape strings | |
CGI::unescape (str)Decode a string encoded by escape(). | |
CGI::escapeHTML(str)Encode HTML special characters, including: & < >. | |
CGI::unescapeHTML(str)Decode HTML special characters, including: & < >. | |
CGI::escapeElement( str[, element...])Encode HTML in the specified HTML element Special characters. | |
CGI::unescapeElement(str, element[, element...])In the specified HTML element Decode HTML special characters. | |
CGI::parse(query)Parse the query string and return the key=》value containing the hash right. | |
CGI::pretty( string[, leader=" "])Return neat HTML format. If leader is specified, it will be written to the beginning of each line. leader The default value is two spaces. | |
CGI::rfc1123_date(time)Format time according to RFC-1123 (for example, Tue, 2 Jun 2008 00:00:00 GMT). |
Serial number | Method description |
---|---|
1 | c[ name] Returns an array containing the value of the corresponding field named name. |
2 | c.checkbox( name[, value[, check=false]]) c.checkbox( options) Returns the HTML string used to define the checkbox field. The label's attributes can be passed as a parameter with a hash function. |
3 | c.checkbox_group( name, value...) c.checkbox_group( options) > Returns the HTML string used to define the checkbox group. The label's attributes can be passed as a parameter with a hash function. |
4 | c.file_field( name[, size=20[, max]]) c.file_field( options) Return the HTML string defining the file field. |
5 | c.form([ method="post"[, url]]) { ...} c.form( options) Returns the HTML string defining the form. If a code block is specified, it will be output as form content. The label's attributes can be passed as a parameter with a hash function. |
6 | c.cookies Returns the CGI::Cookie object, which contains the key-value pairs in the cookie. |
7 | c.header([ header]) Returns the CGI header information. If the header parameter is a hash value, its key-value pairs are used to create the header information. |
8 | c.hidden( name[, value]) c.hidden( options) Return to define a HTML string for hidden fields. The label's attributes can be passed as a parameter with a hash function. |
9 | c.image_button( url[, name[, alt]]) c.image_button( options) Return the HTML string that defines an image button. The label's attributes can be passed as a parameter with a hash function. |
10 | c.keys Returns an array containing the field names of the form. |
11 | c.key?( name) c.has_key?( name) c.include?( name) Returns true if the form contains the specified field name. |
12 | c.multipart_form([ url[, encode]]) { ...} c.multipart_form( options) { . ..} Returns the HTML string that defines a multimedia form (multipart). The label's attributes can be passed as a parameter with a hash function. |
13 | c.out([ header]) { ...} Generate HTML and output. Use the string generated by the block's output to create the body of the page. |
14 | c.params Returns a hash containing the form field name and value. |
15 | c.params= hash Set using field name and value. |
16 | c.password_field( name[, value[, size=40[, max]]]) c.password_field( options ) Returns an HTML string defining a password field. The label's attributes can be passed as a parameter with a hash function. |
17 | c.popup_menu( name, value...) c.popup_menu( options) c.scrolling_list( name , value...) c.scrolling_list(options) Returns the HTML string that defines a pop-up menu. The label's attributes can be passed as a parameter with a hash function. |
18 | c.radio_button( name[, value[, checked=false]]) c.radio_button( options) Return the HTML string that defines a radio field. The label's attributes can be passed as a parameter with a hash function. |
19 | c.radio_group( name, value...) c.radio_group( options) Return definition An HTML string for a radio button group. The label's attributes can be passed as a parameter with a hash function. |
20 | c.reset( name[, value]) c.reset( options) Return to define a HTML string for the reset button. The label's attributes can be passed as arguments to a hash function |
21 | ##c.text_field( name[, value[, size=40[, max ]]])c.text_field(options) Returns the HTML string that defines a text field. The label's attributes can be passed as a parameter with a hash function. |
c.textarea( name[, cols=70[, rows=10]]) { ...}c. textarea( options) { ...} Returns the HTML string defining a textarea field. If block is specified, the string output by the code block will be used as the content of the textarea. The label's attributes can be passed as a parameter with a hash function. |
Properties | Return values |
---|---|
accept | Acceptable MIME types |
accept_charset | Acceptable character set |
accept_encoding | Acceptable encoding |
accept_language | Acceptable language |
auth_type | Acceptable types |
raw_cookie | Cookie data (raw string) |
content_length | Content length |
content_type | Content type |
From | Client e-mail address |
gateway_interface | CGI version |
Path | |
Translated path | |
Query string | |
Previously visited URL | |
Client host address (IP) | |
Client host name | |
Client name | |
Authenticated User | |
Request method (GET, POST, etc.) | |
Parameter name | |
Server name | |
Server port | |
Server protocol | |
Server software | |
User agent |