rbs 4.0.0.dev.5 → 4.0.1.dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.clang-format +1 -0
- data/.github/workflows/c-check.yml +8 -4
- data/.github/workflows/comments.yml +3 -1
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +10 -0
- data/.github/workflows/rust.yml +95 -0
- data/CHANGELOG.md +323 -0
- data/Rakefile +12 -29
- data/Steepfile +1 -0
- data/config.yml +393 -37
- data/core/array.rbs +218 -188
- data/core/basic_object.rbs +9 -8
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +45 -31
- data/core/complex.rbs +52 -40
- data/core/dir.rbs +57 -45
- data/core/encoding.rbs +5 -5
- data/core/enumerable.rbs +96 -91
- data/core/enumerator.rbs +4 -3
- data/core/errno.rbs +3 -2
- data/core/errors.rbs +31 -29
- data/core/exception.rbs +12 -12
- data/core/fiber.rbs +36 -36
- data/core/file.rbs +186 -113
- data/core/file_test.rbs +2 -2
- data/core/float.rbs +41 -32
- data/core/gc.rbs +78 -70
- data/core/hash.rbs +70 -60
- data/core/integer.rbs +32 -28
- data/core/io/buffer.rbs +36 -36
- data/core/io/wait.rbs +7 -7
- data/core/io.rbs +120 -135
- data/core/kernel.rbs +189 -139
- data/core/marshal.rbs +3 -3
- data/core/match_data.rbs +14 -12
- data/core/math.rbs +69 -67
- data/core/method.rbs +6 -6
- data/core/module.rbs +146 -85
- data/core/nil_class.rbs +4 -3
- data/core/numeric.rbs +35 -32
- data/core/object.rbs +6 -8
- data/core/object_space.rbs +11 -10
- data/core/pathname.rbs +131 -81
- data/core/proc.rbs +65 -33
- data/core/process.rbs +219 -201
- data/core/ractor.rbs +15 -11
- data/core/random.rbs +4 -3
- data/core/range.rbs +52 -47
- data/core/rational.rbs +5 -5
- data/core/rbs/unnamed/argf.rbs +58 -51
- data/core/rbs/unnamed/env_class.rbs +18 -13
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +7 -5
- data/core/regexp.rbs +236 -197
- data/core/ruby.rbs +1 -1
- data/core/ruby_vm.rbs +32 -30
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +1 -1
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +5 -3
- data/core/set.rbs +17 -16
- data/core/signal.rbs +2 -2
- data/core/string.rbs +311 -292
- data/core/struct.rbs +26 -25
- data/core/symbol.rbs +25 -24
- data/core/thread.rbs +40 -34
- data/core/time.rbs +47 -42
- data/core/trace_point.rbs +34 -31
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +10 -10
- data/core/warning.rbs +7 -7
- data/docs/collection.md +1 -1
- data/docs/config.md +171 -0
- data/docs/inline.md +110 -4
- data/docs/syntax.md +13 -12
- data/ext/rbs_extension/ast_translation.c +489 -135
- data/ext/rbs_extension/class_constants.c +8 -0
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/legacy_location.c +28 -51
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +12 -20
- data/include/rbs/ast.h +423 -195
- data/include/rbs/lexer.h +2 -2
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +2 -2
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/ruby/annotations.rb +157 -4
- data/lib/rbs/ast/ruby/members.rb +374 -22
- data/lib/rbs/cli/validate.rb +5 -60
- data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
- data/lib/rbs/definition_builder.rb +60 -27
- data/lib/rbs/errors.rb +0 -11
- data/lib/rbs/inline_parser.rb +1 -1
- data/lib/rbs/parser_aux.rb +20 -7
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +1 -26
- data/lib/rbs/prototype/rbi.rb +1 -20
- data/lib/rbs/test/type_check.rb +3 -0
- data/lib/rbs/types.rb +62 -52
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +0 -1
- data/rbs.gemspec +1 -1
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/sig/ast/ruby/annotations.rbs +191 -4
- data/sig/ast/ruby/members.rbs +21 -1
- data/sig/cli/validate.rbs +1 -6
- data/sig/definition_builder.rbs +2 -0
- data/sig/errors.rbs +0 -8
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +17 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/types.rbs +10 -11
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +339 -161
- data/src/lexstate.c +1 -1
- data/src/location.c +7 -47
- data/src/parser.c +674 -480
- data/src/util/rbs_constant_pool.c +0 -4
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
- data/stdlib/cgi-escape/0/escape.rbs +4 -4
- data/stdlib/coverage/0/coverage.rbs +4 -3
- data/stdlib/date/0/date.rbs +33 -28
- data/stdlib/date/0/date_time.rbs +24 -23
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/erb/0/erb.rbs +64 -53
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +138 -125
- data/stdlib/forwardable/0/forwardable.rbs +10 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +135 -108
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +159 -134
- data/stdlib/objspace/0/objspace.rbs +8 -7
- data/stdlib/open-uri/0/open-uri.rbs +8 -8
- data/stdlib/open3/0/open3.rbs +36 -35
- data/stdlib/openssl/0/openssl.rbs +144 -129
- data/stdlib/optparse/0/optparse.rbs +18 -14
- data/stdlib/pathname/0/pathname.rbs +2 -2
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +61 -8
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
- data/stdlib/ripper/0/ripper.rbs +20 -17
- data/stdlib/securerandom/0/securerandom.rbs +1 -1
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/socket/0/addrinfo.rbs +7 -7
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +10 -9
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +1 -1
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +55 -54
- data/stdlib/strscan/0/string_scanner.rbs +46 -44
- data/stdlib/tempfile/0/tempfile.rbs +24 -20
- data/stdlib/time/0/time.rbs +7 -5
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +26 -18
- data/stdlib/uri/0/file.rbs +2 -2
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +4 -4
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- metadata +23 -5
- data/.github/workflows/valgrind.yml +0 -42
data/core/kernel.rbs
CHANGED
|
@@ -73,15 +73,18 @@
|
|
|
73
73
|
# ### IO
|
|
74
74
|
#
|
|
75
75
|
# * ::pp: Prints the given objects in pretty form.
|
|
76
|
-
# * #gets: Returns and assigns to
|
|
76
|
+
# * #gets: Returns and assigns to <code>$_</code> the next line from the
|
|
77
|
+
# current input.
|
|
77
78
|
# * #open: Creates an IO object connected to the given stream, file, or
|
|
78
79
|
# subprocess.
|
|
79
80
|
# * #p: Prints the given objects' inspect output to the standard output.
|
|
80
81
|
# * #print: Prints the given objects to standard output without a newline.
|
|
81
82
|
# * #printf: Prints the string resulting from applying the given format string
|
|
82
83
|
# to any additional arguments.
|
|
83
|
-
# * #putc: Equivalent to
|
|
84
|
-
#
|
|
84
|
+
# * #putc: Equivalent to <code>$stdout.putc(object)</code> for the given
|
|
85
|
+
# object.
|
|
86
|
+
# * #puts: Equivalent to <code>$stdout.puts(*objects)</code> for the given
|
|
87
|
+
# objects.
|
|
85
88
|
# * #readline: Similar to #gets, but raises an exception at the end of file.
|
|
86
89
|
# * #readlines: Returns an array of the remaining lines from the current
|
|
87
90
|
# input.
|
|
@@ -102,7 +105,7 @@
|
|
|
102
105
|
#
|
|
103
106
|
# ### Subprocesses
|
|
104
107
|
#
|
|
105
|
-
# * [
|
|
108
|
+
# * [`command`](rdoc-ref:Kernel#`): Returns the standard output of running
|
|
106
109
|
# `command` in a subshell.
|
|
107
110
|
# * #exec: Replaces current process with a new process.
|
|
108
111
|
# * #fork: Forks the current process into two processes.
|
|
@@ -150,7 +153,7 @@ module Kernel : BasicObject
|
|
|
150
153
|
# - caller(range) -> array or nil
|
|
151
154
|
# -->
|
|
152
155
|
# Returns the current execution stack---an array containing strings in the form
|
|
153
|
-
#
|
|
156
|
+
# <code>file:line</code> or <code>file:line: in `method'</code>.
|
|
154
157
|
#
|
|
155
158
|
# The optional *start* parameter determines the number of initial stack entries
|
|
156
159
|
# to omit from the top of the stack.
|
|
@@ -217,10 +220,10 @@ module Kernel : BasicObject
|
|
|
217
220
|
#
|
|
218
221
|
# catch(1) { 123 } # => 123
|
|
219
222
|
#
|
|
220
|
-
# If
|
|
221
|
-
# block whose `tag` has the same `object_id` as *tag2*. When found, the
|
|
222
|
-
# stops executing and returns *val* (or `nil` if no second argument was
|
|
223
|
-
# `throw`).
|
|
223
|
+
# If <code>throw(tag2, val)</code> is called, Ruby searches up its stack for a
|
|
224
|
+
# `catch` block whose `tag` has the same `object_id` as *tag2*. When found, the
|
|
225
|
+
# block stops executing and returns *val* (or `nil` if no second argument was
|
|
226
|
+
# given to `throw`).
|
|
224
227
|
#
|
|
225
228
|
# catch(1) { throw(1, 456) } # => 456
|
|
226
229
|
# catch(1) { throw(1) } # => nil
|
|
@@ -231,8 +234,8 @@ module Kernel : BasicObject
|
|
|
231
234
|
# catch(1) {|x| x + 2 } # => 3
|
|
232
235
|
#
|
|
233
236
|
# When no `tag` is given, `catch` yields a new unique object (as from
|
|
234
|
-
#
|
|
235
|
-
# argument to `throw`, and will match the correct `catch` block.
|
|
237
|
+
# <code>Object.new</code>) as the block parameter. This object can then be used
|
|
238
|
+
# as the argument to `throw`, and will match the correct `catch` block.
|
|
236
239
|
#
|
|
237
240
|
# catch do |obj_A|
|
|
238
241
|
# catch do |obj_B|
|
|
@@ -296,7 +299,7 @@ module Kernel : BasicObject
|
|
|
296
299
|
# - block_given? -> true or false
|
|
297
300
|
# -->
|
|
298
301
|
# Returns `true` if `yield` would execute a block in the current context. The
|
|
299
|
-
#
|
|
302
|
+
# <code>iterator?</code> form is mildly deprecated.
|
|
300
303
|
#
|
|
301
304
|
# def try
|
|
302
305
|
# if block_given?
|
|
@@ -422,7 +425,8 @@ module Kernel : BasicObject
|
|
|
422
425
|
# Array({foo: 0, bar: 1}) # => [[:foo, 0], [:bar, 1]]
|
|
423
426
|
# Array(0..4) # => [0, 1, 2, 3, 4]
|
|
424
427
|
#
|
|
425
|
-
# Returns `object` in an array,
|
|
428
|
+
# Returns `object` in an array, <code>[object]</code>, if `object` cannot be
|
|
429
|
+
# converted:
|
|
426
430
|
#
|
|
427
431
|
# Array(:foo) # => [:foo]
|
|
428
432
|
#
|
|
@@ -438,8 +442,8 @@ module Kernel : BasicObject
|
|
|
438
442
|
# Returns a new Complex object if the arguments are valid; otherwise raises an
|
|
439
443
|
# exception if `exception` is `true`; otherwise returns `nil`.
|
|
440
444
|
#
|
|
441
|
-
# With Numeric arguments `real` and `imag`, returns
|
|
442
|
-
# if the arguments are valid.
|
|
445
|
+
# With Numeric arguments `real` and `imag`, returns <code>Complex.rect(real,
|
|
446
|
+
# imag)</code> if the arguments are valid.
|
|
443
447
|
#
|
|
444
448
|
# With string argument `s`, returns a new Complex object if the argument is
|
|
445
449
|
# valid; the string may have:
|
|
@@ -449,7 +453,7 @@ module Kernel : BasicObject
|
|
|
449
453
|
# coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
|
|
450
454
|
#
|
|
451
455
|
# * Sign-separated real and imaginary numeric substrings (with trailing
|
|
452
|
-
# character
|
|
456
|
+
# character <code>'i'</code>):
|
|
453
457
|
#
|
|
454
458
|
# Complex('1+2i') # => (1+2i)
|
|
455
459
|
# Complex('+1+2i') # => (1+2i)
|
|
@@ -457,13 +461,15 @@ module Kernel : BasicObject
|
|
|
457
461
|
# Complex('-1+2i') # => (-1+2i)
|
|
458
462
|
# Complex('-1-2i') # => (-1-2i)
|
|
459
463
|
#
|
|
460
|
-
# * Real-only numeric string (without trailing character
|
|
464
|
+
# * Real-only numeric string (without trailing character
|
|
465
|
+
# <code>'i'</code>):
|
|
461
466
|
#
|
|
462
467
|
# Complex('1') # => (1+0i)
|
|
463
468
|
# Complex('+1') # => (1+0i)
|
|
464
469
|
# Complex('-1') # => (-1+0i)
|
|
465
470
|
#
|
|
466
|
-
# * Imaginary-only numeric string (with trailing character
|
|
471
|
+
# * Imaginary-only numeric string (with trailing character
|
|
472
|
+
# <code>'i'</code>):
|
|
467
473
|
#
|
|
468
474
|
# Complex('1i') # => (0+1i)
|
|
469
475
|
# Complex('+1i') # => (0+1i)
|
|
@@ -490,10 +496,10 @@ module Kernel : BasicObject
|
|
|
490
496
|
# - Float(arg, exception: true) -> float or nil
|
|
491
497
|
# -->
|
|
492
498
|
# Returns *arg* converted to a float. Numeric types are converted directly, and
|
|
493
|
-
# with exception to String and `nil`, the rest are converted using
|
|
494
|
-
# Converting a String with invalid characters will
|
|
495
|
-
# Converting `nil` generates a TypeError. Exceptions
|
|
496
|
-
# passing
|
|
499
|
+
# with exception to String and `nil`, the rest are converted using
|
|
500
|
+
# *arg*<code>.to_f</code>. Converting a String with invalid characters will
|
|
501
|
+
# result in an ArgumentError. Converting `nil` generates a TypeError. Exceptions
|
|
502
|
+
# can be suppressed by passing <code>exception: false</code>.
|
|
497
503
|
#
|
|
498
504
|
# Float(1) #=> 1.0
|
|
499
505
|
# Float("123.456") #=> 123.456
|
|
@@ -516,7 +522,8 @@ module Kernel : BasicObject
|
|
|
516
522
|
# * A hash, returns `object`.
|
|
517
523
|
# * An empty array or `nil`, returns an empty hash.
|
|
518
524
|
#
|
|
519
|
-
# * Otherwise, if
|
|
525
|
+
# * Otherwise, if <code>object.to_hash</code> returns a hash, returns that
|
|
526
|
+
# hash.
|
|
520
527
|
# * Otherwise, returns TypeError.
|
|
521
528
|
#
|
|
522
529
|
# Examples:
|
|
@@ -622,7 +629,7 @@ module Kernel : BasicObject
|
|
|
622
629
|
# - Rational(x, y, exception: true) -> rational or nil
|
|
623
630
|
# - Rational(arg, exception: true) -> rational or nil
|
|
624
631
|
# -->
|
|
625
|
-
# Returns
|
|
632
|
+
# Returns <code>x/y</code> or `arg` as a Rational.
|
|
626
633
|
#
|
|
627
634
|
# Rational(2, 3) #=> (2/3)
|
|
628
635
|
# Rational(5) #=> (5/1)
|
|
@@ -698,7 +705,7 @@ module Kernel : BasicObject
|
|
|
698
705
|
# Returns the canonicalized absolute path of the directory of the file from
|
|
699
706
|
# which this method is called. It means symlinks in the path is resolved. If
|
|
700
707
|
# `__FILE__` is `nil`, it returns `nil`. The return value equals to
|
|
701
|
-
#
|
|
708
|
+
# <code>File.dirname(File.realpath(__FILE__))</code>.
|
|
702
709
|
#
|
|
703
710
|
def self?.__dir__: () -> String?
|
|
704
711
|
|
|
@@ -715,8 +722,8 @@ module Kernel : BasicObject
|
|
|
715
722
|
# rdoc-file=io.c
|
|
716
723
|
# - `command` -> string
|
|
717
724
|
# -->
|
|
718
|
-
# Returns the
|
|
719
|
-
# variable
|
|
725
|
+
# Returns the <code>$stdout</code> output from running `command` in a subshell;
|
|
726
|
+
# sets global variable <code>$?</code> to the process status.
|
|
720
727
|
#
|
|
721
728
|
# This method has potential security vulnerabilities if called with untrusted
|
|
722
729
|
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
@@ -728,7 +735,7 @@ module Kernel : BasicObject
|
|
|
728
735
|
# $ $? # => #<Process::Status: pid 17088 exit 99>
|
|
729
736
|
# $ $?.exitstatus # => 99
|
|
730
737
|
#
|
|
731
|
-
# The built-in syntax
|
|
738
|
+
# The built-in syntax <code>%x{...}</code> uses this method.
|
|
732
739
|
#
|
|
733
740
|
def self?.`: (String arg0) -> String
|
|
734
741
|
|
|
@@ -737,7 +744,8 @@ module Kernel : BasicObject
|
|
|
737
744
|
# - abort
|
|
738
745
|
# - Process.abort(msg = nil)
|
|
739
746
|
# -->
|
|
740
|
-
# Terminates execution immediately, effectively by calling
|
|
747
|
+
# Terminates execution immediately, effectively by calling
|
|
748
|
+
# <code>Kernel.exit(false)</code>.
|
|
741
749
|
#
|
|
742
750
|
# If string argument `msg` is given, it is written to STDERR prior to
|
|
743
751
|
# termination; otherwise, if an exception was raised, prints its message and
|
|
@@ -760,7 +768,7 @@ module Kernel : BasicObject
|
|
|
760
768
|
# do_at_exit("goodbye ")
|
|
761
769
|
# exit
|
|
762
770
|
#
|
|
763
|
-
#
|
|
771
|
+
# <em>produces:</em>
|
|
764
772
|
#
|
|
765
773
|
# goodbye cruel world
|
|
766
774
|
#
|
|
@@ -987,13 +995,14 @@ module Kernel : BasicObject
|
|
|
987
995
|
# end
|
|
988
996
|
# # => #<RuntimeError: RuntimeError>
|
|
989
997
|
#
|
|
990
|
-
# If keyword argument `cause` is not given, the cause is the value of
|
|
998
|
+
# If keyword argument `cause` is not given, the cause is the value of
|
|
999
|
+
# <code>$!</code>.
|
|
991
1000
|
#
|
|
992
1001
|
# See [Cause](rdoc-ref:exceptions.md@Cause).
|
|
993
1002
|
#
|
|
994
1003
|
# In the alternate calling sequence, where argument `exception` *not* given,
|
|
995
|
-
# raises a new exception of the class given by
|
|
996
|
-
#
|
|
1004
|
+
# raises a new exception of the class given by <code>$!</code>, or of class
|
|
1005
|
+
# RuntimeError if <code>$!</code> is `nil`:
|
|
997
1006
|
#
|
|
998
1007
|
# begin
|
|
999
1008
|
# raise
|
|
@@ -1009,7 +1018,7 @@ module Kernel : BasicObject
|
|
|
1009
1018
|
#
|
|
1010
1019
|
def self?.fail: () -> bot
|
|
1011
1020
|
| (string message, ?cause: Exception?) -> bot
|
|
1012
|
-
| (_Exception exception, ?_ToS
|
|
1021
|
+
| (_Exception exception, ?string | _ToS message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot
|
|
1013
1022
|
| (_Exception exception, ?cause: Exception?, **untyped) -> bot
|
|
1014
1023
|
|
|
1015
1024
|
# <!--
|
|
@@ -1095,13 +1104,14 @@ module Kernel : BasicObject
|
|
|
1095
1104
|
# end
|
|
1096
1105
|
# # => #<RuntimeError: RuntimeError>
|
|
1097
1106
|
#
|
|
1098
|
-
# If keyword argument `cause` is not given, the cause is the value of
|
|
1107
|
+
# If keyword argument `cause` is not given, the cause is the value of
|
|
1108
|
+
# <code>$!</code>.
|
|
1099
1109
|
#
|
|
1100
1110
|
# See [Cause](rdoc-ref:exceptions.md@Cause).
|
|
1101
1111
|
#
|
|
1102
1112
|
# In the alternate calling sequence, where argument `exception` *not* given,
|
|
1103
|
-
# raises a new exception of the class given by
|
|
1104
|
-
#
|
|
1113
|
+
# raises a new exception of the class given by <code>$!</code>, or of class
|
|
1114
|
+
# RuntimeError if <code>$!</code> is `nil`:
|
|
1105
1115
|
#
|
|
1106
1116
|
# begin
|
|
1107
1117
|
# raise
|
|
@@ -1146,29 +1156,29 @@ module Kernel : BasicObject
|
|
|
1146
1156
|
# - gets(limit [, getline_args]) -> string or nil
|
|
1147
1157
|
# - gets(sep, limit [, getline_args]) -> string or nil
|
|
1148
1158
|
# -->
|
|
1149
|
-
# Returns (and assigns to
|
|
1150
|
-
# (or
|
|
1151
|
-
# Returns `nil` at end of file. The optional argument
|
|
1152
|
-
# separator. The separator is included with the contents of
|
|
1153
|
-
# separator of `nil` reads the entire contents, and a zero-length
|
|
1154
|
-
# reads the input one paragraph at a time, where paragraphs are
|
|
1155
|
-
# consecutive newlines. If the first argument is an integer, or
|
|
1156
|
-
# argument is given, the returning string would not be longer
|
|
1157
|
-
# value in bytes. If multiple filenames are present in `ARGV`,
|
|
1158
|
-
# read the contents one file at a time.
|
|
1159
|
+
# Returns (and assigns to <code>$_</code>) the next line from the list of files
|
|
1160
|
+
# in `ARGV` (or <code>$*</code>), or from standard input if no files are present
|
|
1161
|
+
# on the command line. Returns `nil` at end of file. The optional argument
|
|
1162
|
+
# specifies the record separator. The separator is included with the contents of
|
|
1163
|
+
# each record. A separator of `nil` reads the entire contents, and a zero-length
|
|
1164
|
+
# separator reads the input one paragraph at a time, where paragraphs are
|
|
1165
|
+
# divided by two consecutive newlines. If the first argument is an integer, or
|
|
1166
|
+
# optional second argument is given, the returning string would not be longer
|
|
1167
|
+
# than the given value in bytes. If multiple filenames are present in `ARGV`,
|
|
1168
|
+
# <code>gets(nil)</code> will read the contents one file at a time.
|
|
1159
1169
|
#
|
|
1160
1170
|
# ARGV << "testfile"
|
|
1161
1171
|
# print while gets
|
|
1162
1172
|
#
|
|
1163
|
-
#
|
|
1173
|
+
# <em>produces:</em>
|
|
1164
1174
|
#
|
|
1165
1175
|
# This is line one
|
|
1166
1176
|
# This is line two
|
|
1167
1177
|
# This is line three
|
|
1168
1178
|
# And so on...
|
|
1169
1179
|
#
|
|
1170
|
-
# The style of programming using
|
|
1171
|
-
# losing favor in the Ruby community.
|
|
1180
|
+
# The style of programming using <code>$_</code> as an implicit parameter is
|
|
1181
|
+
# gradually losing favor in the Ruby community.
|
|
1172
1182
|
#
|
|
1173
1183
|
def self?.gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
|
|
1174
1184
|
|
|
@@ -1177,8 +1187,9 @@ module Kernel : BasicObject
|
|
|
1177
1187
|
# - global_variables -> array
|
|
1178
1188
|
# -->
|
|
1179
1189
|
# Returns an array of the names of global variables. This includes special
|
|
1180
|
-
# regexp global variables such as
|
|
1181
|
-
# numbered regexp global variables (
|
|
1190
|
+
# regexp global variables such as <code>$~</code> and <code>$+</code>, but does
|
|
1191
|
+
# not include the numbered regexp global variables (<code>$1</code>,
|
|
1192
|
+
# <code>$2</code>, etc.).
|
|
1182
1193
|
#
|
|
1183
1194
|
# global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
|
|
1184
1195
|
#
|
|
@@ -1197,10 +1208,10 @@ module Kernel : BasicObject
|
|
|
1197
1208
|
# the file will be loaded using the relative path from the current directory.
|
|
1198
1209
|
#
|
|
1199
1210
|
# Otherwise, the file will be searched for in the library directories listed in
|
|
1200
|
-
#
|
|
1201
|
-
# load the file relative to that directory. If
|
|
1202
|
-
# the
|
|
1203
|
-
# path from the current directory.
|
|
1211
|
+
# <code>$LOAD_PATH</code> (<code>$:</code>). If the file is found in a
|
|
1212
|
+
# directory, it will attempt to load the file relative to that directory. If
|
|
1213
|
+
# the file is not found in any of the directories in <code>$LOAD_PATH</code>,
|
|
1214
|
+
# the file will be loaded using the relative path from the current directory.
|
|
1204
1215
|
#
|
|
1205
1216
|
# If the file doesn't exist when there is an attempt to load it, a LoadError
|
|
1206
1217
|
# will be raised.
|
|
@@ -1253,9 +1264,6 @@ module Kernel : BasicObject
|
|
|
1253
1264
|
# -->
|
|
1254
1265
|
# Creates an IO object connected to the given file.
|
|
1255
1266
|
#
|
|
1256
|
-
# This method has potential security vulnerabilities if called with untrusted
|
|
1257
|
-
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1258
|
-
#
|
|
1259
1267
|
# With no block given, file stream is returned:
|
|
1260
1268
|
#
|
|
1261
1269
|
# open('t.txt') # => #<File:t.txt>
|
|
@@ -1278,18 +1286,19 @@ module Kernel : BasicObject
|
|
|
1278
1286
|
# rdoc-file=io.c
|
|
1279
1287
|
# - print(*objects) -> nil
|
|
1280
1288
|
# -->
|
|
1281
|
-
# Equivalent to
|
|
1282
|
-
# way to write to
|
|
1289
|
+
# Equivalent to <code>$stdout.print(*objects)</code>, this method is the
|
|
1290
|
+
# straightforward way to write to <code>$stdout</code>.
|
|
1283
1291
|
#
|
|
1284
|
-
# Writes the given objects to
|
|
1285
|
-
# record separator
|
|
1292
|
+
# Writes the given objects to <code>$stdout</code>; returns `nil`. Appends the
|
|
1293
|
+
# output record separator <code>$OUTPUT_RECORD_SEPARATOR</code>
|
|
1294
|
+
# <code>$\</code>), if it is not `nil`.
|
|
1286
1295
|
#
|
|
1287
1296
|
# With argument `objects` given, for each object:
|
|
1288
1297
|
#
|
|
1289
1298
|
# * Converts via its method `to_s` if not a string.
|
|
1290
1299
|
# * Writes to `stdout`.
|
|
1291
1300
|
# * If not the last object, writes the output field separator
|
|
1292
|
-
#
|
|
1301
|
+
# <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code> if it is not `nil`.
|
|
1293
1302
|
#
|
|
1294
1303
|
# With default separators:
|
|
1295
1304
|
#
|
|
@@ -1314,8 +1323,8 @@ module Kernel : BasicObject
|
|
|
1314
1323
|
#
|
|
1315
1324
|
# 0,0.0,0/1,0+0i,zero,zero
|
|
1316
1325
|
#
|
|
1317
|
-
# With no argument given, writes the content of
|
|
1318
|
-
# recent user input):
|
|
1326
|
+
# With no argument given, writes the content of <code>$_</code> (which is
|
|
1327
|
+
# usually the most recent user input):
|
|
1319
1328
|
#
|
|
1320
1329
|
# gets # Sets $_ to the most recent user input.
|
|
1321
1330
|
# print # Prints $_.
|
|
@@ -1437,7 +1446,7 @@ module Kernel : BasicObject
|
|
|
1437
1446
|
# -->
|
|
1438
1447
|
# prints arguments in pretty form.
|
|
1439
1448
|
#
|
|
1440
|
-
#
|
|
1449
|
+
# <code>#pp</code> returns argument(s).
|
|
1441
1450
|
#
|
|
1442
1451
|
def self?.pp: [T] (T arg0) -> T
|
|
1443
1452
|
| (untyped, untyped, *untyped) -> Array[untyped]
|
|
@@ -1447,19 +1456,20 @@ module Kernel : BasicObject
|
|
|
1447
1456
|
# rdoc-file=random.c
|
|
1448
1457
|
# - rand(max=0) -> number
|
|
1449
1458
|
# -->
|
|
1450
|
-
# If called without an argument, or if
|
|
1451
|
-
# pseudo-random floating point number between 0.0 and 1.0, including
|
|
1452
|
-
# excluding 1.0.
|
|
1459
|
+
# If called without an argument, or if <code>max.to_i.abs == 0</code>, rand
|
|
1460
|
+
# returns a pseudo-random floating point number between 0.0 and 1.0, including
|
|
1461
|
+
# 0.0 and excluding 1.0.
|
|
1453
1462
|
#
|
|
1454
1463
|
# rand #=> 0.2725926052826416
|
|
1455
1464
|
#
|
|
1456
|
-
# When
|
|
1457
|
-
# integer greater than or equal to 0 and less than
|
|
1465
|
+
# When <code>max.abs</code> is greater than or equal to 1, `rand` returns a
|
|
1466
|
+
# pseudo-random integer greater than or equal to 0 and less than
|
|
1467
|
+
# <code>max.to_i.abs</code>.
|
|
1458
1468
|
#
|
|
1459
1469
|
# rand(100) #=> 12
|
|
1460
1470
|
#
|
|
1461
1471
|
# When `max` is a Range, `rand` returns a random number where
|
|
1462
|
-
#
|
|
1472
|
+
# <code>range.member?(number) == true</code>.
|
|
1463
1473
|
#
|
|
1464
1474
|
# Negative or floating point values for `max` are allowed, but may give
|
|
1465
1475
|
# surprising results.
|
|
@@ -1560,7 +1570,7 @@ module Kernel : BasicObject
|
|
|
1560
1570
|
# When RubyGems is required, Kernel#require is replaced with our own which is
|
|
1561
1571
|
# capable of loading gems on demand.
|
|
1562
1572
|
#
|
|
1563
|
-
# When you call
|
|
1573
|
+
# When you call <code>require 'x'</code>, this is what happens:
|
|
1564
1574
|
# * If the file can be loaded from the existing Ruby loadpath, it is.
|
|
1565
1575
|
# * Otherwise, installed gems are searched for a file that matches. If it's
|
|
1566
1576
|
# found in gem 'y', that gem is activated (added to the loadpath).
|
|
@@ -1595,8 +1605,9 @@ module Kernel : BasicObject
|
|
|
1595
1605
|
# IO objects.
|
|
1596
1606
|
#
|
|
1597
1607
|
# Argument `timeout` is a numeric value (such as integer or float) timeout
|
|
1598
|
-
# interval in seconds. `timeout` can also be `nil` or
|
|
1599
|
-
# and
|
|
1608
|
+
# interval in seconds. `timeout` can also be `nil` or
|
|
1609
|
+
# <code>Float::INFINITY</code>. `nil` and <code>Float::INFINITY</code> means no
|
|
1610
|
+
# timeout.
|
|
1600
1611
|
#
|
|
1601
1612
|
# The method monitors the IO objects given in all three arrays, waiting for some
|
|
1602
1613
|
# to be ready; returns a 3-element array whose elements are:
|
|
@@ -1671,8 +1682,8 @@ module Kernel : BasicObject
|
|
|
1671
1682
|
#
|
|
1672
1683
|
# The writability notified by select(2) doesn't show how many bytes are
|
|
1673
1684
|
# writable. IO#write method blocks until given whole string is written. So,
|
|
1674
|
-
#
|
|
1675
|
-
# IO.select. IO#write_nonblock is required to avoid the blocking.
|
|
1685
|
+
# <code>IO#write(two or more bytes)</code> can block after writability is
|
|
1686
|
+
# notified by IO.select. IO#write_nonblock is required to avoid the blocking.
|
|
1676
1687
|
#
|
|
1677
1688
|
# Blocking write (#write) can be emulated using #write_nonblock and IO.select as
|
|
1678
1689
|
# follows: IO::WaitReadable should also be rescued for SSL renegotiation in
|
|
@@ -1740,11 +1751,6 @@ module Kernel : BasicObject
|
|
|
1740
1751
|
def self?.sleep: (?nil) -> bot
|
|
1741
1752
|
| (Time::_Timeout duration) -> Integer
|
|
1742
1753
|
|
|
1743
|
-
%a{deprecated}
|
|
1744
|
-
interface _Divmod
|
|
1745
|
-
def divmod: (Numeric) -> [ Numeric, Numeric ]
|
|
1746
|
-
end
|
|
1747
|
-
|
|
1748
1754
|
# <!--
|
|
1749
1755
|
# rdoc-file=io.c
|
|
1750
1756
|
# - syscall(integer_callno, *arguments) -> integer
|
|
@@ -1784,58 +1790,58 @@ module Kernel : BasicObject
|
|
|
1784
1790
|
# * Each of these tests operates only on the entity at `path0`,
|
|
1785
1791
|
# and returns `true` or `false`;
|
|
1786
1792
|
# for a non-existent entity, returns `false` (does not raise exception):
|
|
1787
|
-
#
|
|
1788
|
-
#
|
|
1789
|
-
#
|
|
1790
|
-
#
|
|
1791
|
-
#
|
|
1792
|
-
#
|
|
1793
|
-
#
|
|
1794
|
-
#
|
|
1795
|
-
#
|
|
1796
|
-
#
|
|
1797
|
-
#
|
|
1798
|
-
#
|
|
1799
|
-
#
|
|
1800
|
-
#
|
|
1801
|
-
#
|
|
1802
|
-
#
|
|
1803
|
-
#
|
|
1804
|
-
#
|
|
1805
|
-
#
|
|
1806
|
-
#
|
|
1807
|
-
#
|
|
1808
|
-
#
|
|
1809
|
-
#
|
|
1793
|
+
# Character |Test
|
|
1794
|
+
# ----------------|-----------------------------------------------------------------------------
|
|
1795
|
+
# <code>'b'</code>|Whether the entity is a block device.
|
|
1796
|
+
# <code>'c'</code>|Whether the entity is a character device.
|
|
1797
|
+
# <code>'d'</code>|Whether the entity is a directory.
|
|
1798
|
+
# <code>'e'</code>|Whether the entity is an existing entity.
|
|
1799
|
+
# <code>'f'</code>|Whether the entity is an existing regular file.
|
|
1800
|
+
# <code>'g'</code>|Whether the entity's setgid bit is set.
|
|
1801
|
+
# <code>'G'</code>|Whether the entity's group ownership is equal to the caller's.
|
|
1802
|
+
# <code>'k'</code>|Whether the entity's sticky bit is set.
|
|
1803
|
+
# <code>'l'</code>|Whether the entity is a symbolic link.
|
|
1804
|
+
# <code>'o'</code>|Whether the entity is owned by the caller's effective uid.
|
|
1805
|
+
# <code>'O'</code>|Like <code>'o'</code>, but uses the real uid (not the effective uid).
|
|
1806
|
+
# <code>'p'</code>|Whether the entity is a FIFO device (named pipe).
|
|
1807
|
+
# <code>'r'</code>|Whether the entity is readable by the caller's effective uid/gid.
|
|
1808
|
+
# <code>'R'</code>|Like <code>'r'</code>, but uses the real uid/gid (not the effective uid/gid).
|
|
1809
|
+
# <code>'S'</code>|Whether the entity is a socket.
|
|
1810
|
+
# <code>'u'</code>|Whether the entity's setuid bit is set.
|
|
1811
|
+
# <code>'w'</code>|Whether the entity is writable by the caller's effective uid/gid.
|
|
1812
|
+
# <code>'W'</code>|Like <code>'w'</code>, but uses the real uid/gid (not the effective uid/gid).
|
|
1813
|
+
# <code>'x'</code>|Whether the entity is executable by the caller's effective uid/gid.
|
|
1814
|
+
# <code>'X'</code>|Like <code>'x'</code>, but uses the real uid/gid (not the effective uid/git).
|
|
1815
|
+
# <code>'z'</code>|Whether the entity exists and is of length zero.
|
|
1810
1816
|
# * This test operates only on the entity at `path0`,
|
|
1811
|
-
# and returns an integer size or
|
|
1812
|
-
#
|
|
1813
|
-
#
|
|
1814
|
-
#
|
|
1817
|
+
# and returns an integer size or +nil+:
|
|
1818
|
+
# Character |Test
|
|
1819
|
+
# ----------------|--------------------------------------------------------------------------------------------
|
|
1820
|
+
# <code>'s'</code>|Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise.
|
|
1815
1821
|
# * Each of these tests operates only on the entity at `path0`,
|
|
1816
1822
|
# and returns a Time object;
|
|
1817
1823
|
# raises an exception if the entity does not exist:
|
|
1818
|
-
#
|
|
1819
|
-
#
|
|
1820
|
-
#
|
|
1821
|
-
#
|
|
1822
|
-
#
|
|
1824
|
+
# Character |Test
|
|
1825
|
+
# ----------------|--------------------------------------
|
|
1826
|
+
# <code>'A'</code>|Last access time for the entity.
|
|
1827
|
+
# <code>'C'</code>|Last change time for the entity.
|
|
1828
|
+
# <code>'M'</code>|Last modification time for the entity.
|
|
1823
1829
|
# * Each of these tests operates on the modification time (`mtime`)
|
|
1824
1830
|
# of each of the entities at `path0` and `path1`,
|
|
1825
1831
|
# and returns a `true` or `false`;
|
|
1826
1832
|
# returns `false` if either entity does not exist:
|
|
1827
|
-
#
|
|
1828
|
-
#
|
|
1829
|
-
#
|
|
1830
|
-
#
|
|
1831
|
-
#
|
|
1833
|
+
# Character |Test
|
|
1834
|
+
# ----------------|---------------------------------------------------------------
|
|
1835
|
+
# <code>'<'</code>|Whether the `mtime` at `path0` is less than that at `path1`.
|
|
1836
|
+
# <code>'='</code>|Whether the `mtime` at `path0` is equal to that at `path1`.
|
|
1837
|
+
# <code>'>'</code>|Whether the `mtime` at `path0` is greater than that at `path1`.
|
|
1832
1838
|
# * This test operates on the content of each of the entities at `path0` and
|
|
1833
1839
|
# `path1`,
|
|
1834
1840
|
# and returns a `true` or `false`;
|
|
1835
1841
|
# returns `false` if either entity does not exist:
|
|
1836
|
-
#
|
|
1837
|
-
#
|
|
1838
|
-
#
|
|
1842
|
+
# Character |Test
|
|
1843
|
+
# ----------------|---------------------------------------------
|
|
1844
|
+
# <code>'-'</code>|Whether the entities exist and are identical.
|
|
1839
1845
|
#
|
|
1840
1846
|
def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
|
|
1841
1847
|
|
|
@@ -1854,14 +1860,14 @@ module Kernel : BasicObject
|
|
|
1854
1860
|
# rdoc-file=warning.rb
|
|
1855
1861
|
# - warn(*msgs, uplevel: nil, category: nil) -> nil
|
|
1856
1862
|
# -->
|
|
1857
|
-
# If warnings have been disabled (for example with the
|
|
1858
|
-
# nothing. Otherwise, converts each of the messages to strings, appends a
|
|
1863
|
+
# If warnings have been disabled (for example with the <code>-W0</code> flag),
|
|
1864
|
+
# does nothing. Otherwise, converts each of the messages to strings, appends a
|
|
1859
1865
|
# newline character to the string if the string does not end in a newline, and
|
|
1860
1866
|
# calls Warning.warn with the string.
|
|
1861
1867
|
#
|
|
1862
1868
|
# warn("warning 1", "warning 2")
|
|
1863
1869
|
#
|
|
1864
|
-
#
|
|
1870
|
+
# <em>produces:</em>
|
|
1865
1871
|
#
|
|
1866
1872
|
# warning 1
|
|
1867
1873
|
# warning 2
|
|
@@ -1881,12 +1887,13 @@ module Kernel : BasicObject
|
|
|
1881
1887
|
#
|
|
1882
1888
|
# bar
|
|
1883
1889
|
#
|
|
1884
|
-
#
|
|
1890
|
+
# <em>produces:</em>
|
|
1885
1891
|
#
|
|
1886
1892
|
# baz.rb:6: warning: invalid call to foo
|
|
1887
1893
|
#
|
|
1888
1894
|
# If `category` keyword argument is given, passes the category to
|
|
1889
|
-
#
|
|
1895
|
+
# <code>Warning.warn</code>. The category given must be one of the following
|
|
1896
|
+
# categories:
|
|
1890
1897
|
#
|
|
1891
1898
|
# :deprecated
|
|
1892
1899
|
# : Used for warning for deprecated functionality that may be removed in the
|
|
@@ -1931,7 +1938,7 @@ module Kernel : BasicObject
|
|
|
1931
1938
|
# word or special built-in, or if it contains one or more meta characters.
|
|
1932
1939
|
# * `exe_path` otherwise.
|
|
1933
1940
|
#
|
|
1934
|
-
#
|
|
1941
|
+
# <strong>Argument `command_line`</strong>
|
|
1935
1942
|
#
|
|
1936
1943
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
1937
1944
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -1954,7 +1961,7 @@ module Kernel : BasicObject
|
|
|
1954
1961
|
#
|
|
1955
1962
|
# Raises an exception if the new process could not execute.
|
|
1956
1963
|
#
|
|
1957
|
-
#
|
|
1964
|
+
# <strong>Argument `exe_path`</strong>
|
|
1958
1965
|
#
|
|
1959
1966
|
# Argument `exe_path` is one of the following:
|
|
1960
1967
|
#
|
|
@@ -2031,7 +2038,7 @@ module Kernel : BasicObject
|
|
|
2031
2038
|
# word or special built-in, or if it contains one or more meta characters.
|
|
2032
2039
|
# * `exe_path` otherwise.
|
|
2033
2040
|
#
|
|
2034
|
-
#
|
|
2041
|
+
# <strong>Argument `command_line`</strong>
|
|
2035
2042
|
#
|
|
2036
2043
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
2037
2044
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -2060,7 +2067,7 @@ module Kernel : BasicObject
|
|
|
2060
2067
|
#
|
|
2061
2068
|
# Raises an exception if the new process could not execute.
|
|
2062
2069
|
#
|
|
2063
|
-
#
|
|
2070
|
+
# <strong>Argument `exe_path`</strong>
|
|
2064
2071
|
#
|
|
2065
2072
|
# Argument `exe_path` is one of the following:
|
|
2066
2073
|
#
|
|
@@ -2118,7 +2125,7 @@ module Kernel : BasicObject
|
|
|
2118
2125
|
# Raises an exception (instead of returning `false` or `nil`) if keyword
|
|
2119
2126
|
# argument `exception` is set to `true`.
|
|
2120
2127
|
#
|
|
2121
|
-
# Assigns the command's error status to
|
|
2128
|
+
# Assigns the command's error status to <code>$?</code>.
|
|
2122
2129
|
#
|
|
2123
2130
|
# The new process is created using the [system system
|
|
2124
2131
|
# call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/s
|
|
@@ -2137,7 +2144,7 @@ module Kernel : BasicObject
|
|
|
2137
2144
|
# word or special built-in, or if it contains one or more meta characters.
|
|
2138
2145
|
# * `exe_path` otherwise.
|
|
2139
2146
|
#
|
|
2140
|
-
#
|
|
2147
|
+
# <strong>Argument `command_line`</strong>
|
|
2141
2148
|
#
|
|
2142
2149
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
2143
2150
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -2149,7 +2156,7 @@ module Kernel : BasicObject
|
|
|
2149
2156
|
# system('date > /nop/date.tmp') # => false
|
|
2150
2157
|
# system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
|
|
2151
2158
|
#
|
|
2152
|
-
# Assigns the command's error status to
|
|
2159
|
+
# Assigns the command's error status to <code>$?</code>:
|
|
2153
2160
|
#
|
|
2154
2161
|
# system('exit') # => true # Built-in.
|
|
2155
2162
|
# $? # => #<Process::Status: pid 640610 exit 0>
|
|
@@ -2169,7 +2176,7 @@ module Kernel : BasicObject
|
|
|
2169
2176
|
#
|
|
2170
2177
|
# Raises an exception if the new process could not execute.
|
|
2171
2178
|
#
|
|
2172
|
-
#
|
|
2179
|
+
# <strong>Argument `exe_path`</strong>
|
|
2173
2180
|
#
|
|
2174
2181
|
# Argument `exe_path` is one of the following:
|
|
2175
2182
|
#
|
|
@@ -2186,7 +2193,7 @@ module Kernel : BasicObject
|
|
|
2186
2193
|
#
|
|
2187
2194
|
# Mon Aug 28 11:43:10 AM CDT 2023
|
|
2188
2195
|
#
|
|
2189
|
-
# Assigns the command's error status to
|
|
2196
|
+
# Assigns the command's error status to <code>$?</code>:
|
|
2190
2197
|
#
|
|
2191
2198
|
# system('/usr/bin/date') # => true
|
|
2192
2199
|
# $? # => #<Process::Status: pid 645605 exit 0>
|
|
@@ -2214,6 +2221,49 @@ module Kernel : BasicObject
|
|
|
2214
2221
|
def self?.system: (String command, *String args, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: bool, ?chdir: String, ?exception: bool) -> (NilClass | FalseClass | TrueClass)
|
|
2215
2222
|
| (Hash[string, string?] env, String command, *String args, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: bool, ?chdir: String, ?exception: bool) -> (NilClass | FalseClass | TrueClass)
|
|
2216
2223
|
|
|
2224
|
+
# An interface used with `trace_var` (and `untrace_var`) for custom command types.
|
|
2225
|
+
interface _Tracer
|
|
2226
|
+
# Called whenever the global variable that's being traced changes; the argument is the new value.
|
|
2227
|
+
def call: (untyped argument) -> void
|
|
2228
|
+
end
|
|
2229
|
+
|
|
2230
|
+
# <!--
|
|
2231
|
+
# rdoc-file=eval.c
|
|
2232
|
+
# - trace_var(symbol, cmd ) -> nil
|
|
2233
|
+
# - trace_var(symbol) {|val| block } -> nil
|
|
2234
|
+
# -->
|
|
2235
|
+
# Controls tracing of assignments to global variables. The parameter `symbol`
|
|
2236
|
+
# identifies the variable (as either a string name or a symbol identifier).
|
|
2237
|
+
# *cmd* (which may be a string or a `Proc` object) or block is executed whenever
|
|
2238
|
+
# the variable is assigned. The block or `Proc` object receives the variable's
|
|
2239
|
+
# new value as a parameter. Also see #untrace_var.
|
|
2240
|
+
#
|
|
2241
|
+
# trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
|
|
2242
|
+
# $_ = "hello"
|
|
2243
|
+
# $_ = ' there'
|
|
2244
|
+
#
|
|
2245
|
+
# <em>produces:</em>
|
|
2246
|
+
#
|
|
2247
|
+
# $_ is now 'hello'
|
|
2248
|
+
# $_ is now ' there'
|
|
2249
|
+
#
|
|
2250
|
+
def self?.trace_var: (interned name, String | _Tracer cmd) -> nil
|
|
2251
|
+
| (interned name) { (untyped value) -> void } -> nil
|
|
2252
|
+
| (interned name, nil) -> Array[String | _Tracer]?
|
|
2253
|
+
|
|
2254
|
+
# <!--
|
|
2255
|
+
# rdoc-file=eval.c
|
|
2256
|
+
# - untrace_var(symbol [, cmd] ) -> array or nil
|
|
2257
|
+
# -->
|
|
2258
|
+
# Removes tracing for the specified command on the given global variable and
|
|
2259
|
+
# returns `nil`. If no command is specified, removes all tracing for that
|
|
2260
|
+
# variable and returns an array containing the commands actually removed.
|
|
2261
|
+
#
|
|
2262
|
+
def self?.untrace_var: (interned name, ?nil) -> Array[String | _Tracer]
|
|
2263
|
+
| (interned name, String cmd) -> [String]?
|
|
2264
|
+
| [T < _Tracer] (interned name, T cmd) -> [T]?
|
|
2265
|
+
| (interned name, untyped cmd) -> nil
|
|
2266
|
+
|
|
2217
2267
|
# <!--
|
|
2218
2268
|
# rdoc-file=object.c
|
|
2219
2269
|
# - obj !~ other -> true or false
|
|
@@ -2259,8 +2309,8 @@ module Kernel : BasicObject
|
|
|
2259
2309
|
# -->
|
|
2260
2310
|
# Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
|
|
2261
2311
|
# but not the objects they reference. #clone copies the frozen value state of
|
|
2262
|
-
# *obj*, unless the
|
|
2263
|
-
# value. See also the discussion under Object#dup.
|
|
2312
|
+
# *obj*, unless the <code>:freeze</code> keyword argument is given with a false
|
|
2313
|
+
# or true value. See also the discussion under Object#dup.
|
|
2264
2314
|
#
|
|
2265
2315
|
# class Klass
|
|
2266
2316
|
# attr_accessor :str
|