stdlib/optparse/0/optparse.rbs in rbs-3.3.2 vs stdlib/optparse/0/optparse.rbs in rbs-3.4.0.pre.1
- old
+ new
@@ -1,9 +1,9 @@
# <!-- rdoc-file=lib/optparse.rb -->
# ## OptionParser
#
-# ### New to OptionParser?
+# ### New to `OptionParser`?
#
# See the [Tutorial](optparse/tutorial.rdoc).
#
# ### Introduction
#
@@ -104,17 +104,21 @@
# ### Type Coercion
#
# OptionParser supports the ability to coerce command line arguments into
# objects for us.
#
-# OptionParser comes with a few ready-to-use kinds of type coercion. They are:
+# OptionParser comes with a few ready-to-use kinds of type coercion. They are:
#
-# * Date -- Anything accepted by `Date.parse`
-# * DateTime -- Anything accepted by `DateTime.parse`
-# * Time -- Anything accepted by `Time.httpdate` or `Time.parse`
-# * URI -- Anything accepted by `URI.parse`
-# * Shellwords -- Anything accepted by `Shellwords.shellwords`
+# * Date -- Anything accepted by `Date.parse` (need to require
+# `optparse/date`)
+# * DateTime -- Anything accepted by `DateTime.parse` (need to require
+# `optparse/date`)
+# * Time -- Anything accepted by `Time.httpdate` or `Time.parse` (need to
+# require `optparse/time`)
+# * URI -- Anything accepted by `URI.parse` (need to require `optparse/uri`)
+# * Shellwords -- Anything accepted by `Shellwords.shellwords` (need to
+# require `optparse/shellwords`)
# * String -- Any non-empty string
# * Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040)
# * Float -- Any float. (e.g. 10, 3.14, -100E+13)
# * Numeric -- Any integer, float, or rational (1, 3.4, 1/3)
# * DecimalInteger -- Like `Integer`, but no octal format.
@@ -398,11 +402,11 @@
#
def self.accept: (Class t, ?_Pattern pat) ?{ (*untyped) -> untyped } -> void
# <!--
# rdoc-file=lib/optparse.rb
- # - getopts(*args)
+ # - getopts(*args, symbolize_names: false)
# -->
# See #getopts.
#
def self.getopts: (*String options) -> Hash[String, untyped]
| (Array[String] args, *String options) -> Hash[String, untyped]
@@ -596,21 +600,31 @@
#
def environment: (?String env) -> Array[String]?
# <!--
# rdoc-file=lib/optparse.rb
- # - getopts(*args)
+ # - getopts(*args, symbolize_names: false)
# -->
# Wrapper method for getopts.rb.
#
# params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option")
# # params["a"] = true # -a
# # params["b"] = "1" # -b1
# # params["foo"] = "1" # --foo
# # params["bar"] = "x" # --bar x
# # params["zot"] = "z" # --zot Z
#
+ # Option `symbolize_names` (boolean) specifies whether returned Hash keys should
+ # be Symbols; defaults to `false` (use Strings).
+ #
+ # params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option", symbolize_names: true)
+ # # params[:a] = true # -a
+ # # params[:b] = "1" # -b1
+ # # params[:foo] = "1" # --foo
+ # # params[:bar] = "x" # --bar x
+ # # params[:zot] = "z" # --zot Z
+ #
def getopts: (*String options) -> Hash[String, untyped]
| (Array[String] args, *String options) -> Hash[String, untyped]
# <!--
# rdoc-file=lib/optparse.rb
@@ -1097,10 +1111,10 @@
public
# <!--
# rdoc-file=lib/optparse.rb
- # - getopts(*args)
+ # - getopts(*args, symbolize_names: false)
# -->
# Substitution of getopts is possible as follows. Also see OptionParser#getopts.
#
# def getopts(*args)
# ($OPT = ARGV.getopts(*args)).each do |opt, val|