@@ -803,16 +803,18 @@ def self.accept_charset=(accept_charset)
803803 # With no argument and no block given, returns a new \CGI object with default values:
804804 #
805805 # cgi = CGI.new
806- # puts cgi.pretty_inspect
807- # #<CGI:0x000002b0ea237bc8
808- # @accept_charset=#<Encoding:UTF-8>,
809- # @accept_charset_error_block=nil,
810- # @cookies={},
811- # @max_multipart_length=134217728,
812- # @multipart=false,
813- # @output_cookies=nil,
814- # @output_hidden=nil,
815- # @params={}>
806+ # cgi
807+ # # =>
808+ # #<CGI:0x00000189917aff00
809+ # @accept_charset="UTF-8",
810+ # @accept_charset_error_block=nil,
811+ # @cookies={},
812+ # @max_multipart_length=134217728,
813+ # @multipart=false,
814+ # @options={accept_charset: "UTF-8", max_multipart_length: 134217728},
815+ # @output_cookies=nil,
816+ # @output_hidden=nil,
817+ # @params={}>
816818 #
817819 # With hash argument +options+ given and no block given,
818820 # returns a new \CGI object with the given options.
@@ -852,27 +854,50 @@ def self.accept_charset=(accept_charset)
852854 # CGI.new(max_multipart_length: -> {check_filesystem})
853855 #
854856 # If the option is not given, the default is +134217728+, specifying a maximum size of 128 megabytes.
855- #
856- # <em>Note:</em> This option configures internal behavior only.
857- # There is no public method to retrieve this value after initialization.
857+ #
858+ # <em>Note:</em> This option configures internal behavior only.
859+ # There is no public method to retrieve this value after initialization.
858860 #
859861 # - <tt>tag_maker: _html_version_</tt>:
860- # specifies which version of HTML to use in generating tags.
862+ # specifies a version of HTML;
863+ # this determines which tag-generating instance methods
864+ # (such as +html+, +head+, +body+, etc.) are to be loaded.
861865 #
862866 # Value _html_version_ may be one of:
863867 #
864- # - <tt>'html3'</tt>: {HTML version 3}[https://en.wikipedia .org/wiki/HTML#HTML_3 ].
865- # - <tt>'html4'</tt>: {HTML version 4}[https://en.wikipedia .org/wiki/HTML#HTML_4 ].
866- # - <tt>'html4Tr'</tt>: HTML 4.0 Transitional.
867- # - <tt>'html4Fr'</tt>: HTML 4.0 with Framesets.
868- # - <tt>'html5'</tt>: {HTML version 5}[https://en.wikipedia. org/wiki/HTML#HTML_5 ].
868+ # - <tt>'html3'</tt>: {HTML version 3}[https://www.w3 .org/MarkUp/html3/Contents.html ].
869+ # - <tt>'html4'</tt>: {HTML version 4}[https://www.w3 .org/TR/html4 ].
870+ # - <tt>'html4Tr'</tt>: { HTML 4.0 Transitional}[https://www.w3.org/TR/html4/sgml/loosedtd.html] .
871+ # - <tt>'html4Fr'</tt>: { HTML 4.0 with Framesets}[https://www.w3.org/TR/html4/present/frames.html] .
872+ # - <tt>'html5'</tt>: {HTML version 5}[https://html.spec.whatwg. org/multipage ].
869873 #
870874 # Example:
871875 #
872876 # CGI.new(tag_maker: 'html5')
873877 #
874- # If the option is not given,
875- # no HTML generation methods are loaded.
878+ # If the option is not given (or if an invalid value is given),
879+ # no tag-generating methods are loaded.
880+ #
881+ # Examples:
882+ #
883+ # CGI.new.respond_to?(:html) # => false # Tag-generating methods not loaded.
884+ # CGI.new(tag_maker: 'html3').respond_to?(:html) # => true # Tag-generating methods loaded.
885+ # # Tag 'button' is new in HTML 4.
886+ # CGI.new(tag_maker: 'html3').respond_to?(:button) # => false
887+ # CGI.new(tag_maker: 'html4').respond_to?(:button) # => true
888+ # # Tag 'canvas' is new in HTML 5.
889+ # CGI.new(tag_maker: 'html4').respond_to?(:canvas) # => false
890+ # CGI.new(tag_maker: 'html5').respond_to?(:canvas) # => true
891+ # # Value is case-sensitive.
892+ # CGI.new(tag_maker: 'HTML4').respond_to?(:html) # => false
893+ #
894+ # You can determine exactly which methods have been loaded;
895+ # this example captures the methods loaded by <tt>'html4'</tt>:
896+ #
897+ # methods_loaded = CGI.new('html4').methods - CGI.new.methods
898+ # methods_loaded.size # => 98
899+ # methods_loaded.sort.take(10)
900+ # # => [:a, :abbr, :acronym, :address, :area, :b, :base, :bdo, :big, :blockquote]
876901 #
877902 # With string argument +tag_maker+ given as _tag_maker_ and no block given,
878903 # equivalent to <tt>CGI.new(tag_maker: _tag_maker_)</tt>:
@@ -890,6 +915,28 @@ def self.accept_charset=(accept_charset)
890915 # from the command line or (failing that) from standard input;
891916 # returns a new \CGI object.
892917 #
918+ # Parameters from command line:
919+ #
920+ # $ cat t.rb
921+ # require 'cgi'
922+ # cgi = CGI.new
923+ # p cgi.params
924+ # ruby t.rb foo=0 bar=1 foo=2 bar=3
925+ # {"foo" => ["0", "2"], "bar" => ["1", "3"]}
926+ #
927+ # Parameters from standard input:
928+ #
929+ # cgi = CGI.new
930+ # (offline mode: enter name=value pairs on standard input)
931+ # foo=0
932+ # bar=1
933+ # ^D
934+ # cgi.params
935+ # # => {"foo" => ["0"], "bar" => ["1"]}
936+ #
937+ # The end-of-file character is Ctrl-D on a Unix-like system (as above),
938+ # or Ctrl-Z on Windows.
939+ #
893940 # Otherwise, cookies and other parameters are parsed automatically from the standard CGI locations,
894941 # which vary according to the request method.
895942 #
@@ -911,7 +958,7 @@ def self.accept_charset=(accept_charset)
911958 #
912959 # In this example, the proc simply saves the error:
913960 #
914- # encoding_errors= {}
961+ # encoding_errors = {}
915962 # CGI.new(accept_charset: 'EUC-JP') do |name,value|
916963 # encoding_errors[name] = value
917964 # end
0 commit comments