rbs 3.10.4 → 4.0.0
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/.github/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +7 -5
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/ruby.yml +16 -26
- data/.github/workflows/rust.yml +95 -0
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +2 -2
- data/.vscode/extensions.json +5 -0
- data/.vscode/settings.json +19 -0
- data/CHANGELOG.md +202 -2
- data/Rakefile +9 -23
- data/Steepfile +2 -0
- data/config.yml +457 -13
- data/core/array.rbs +218 -188
- data/core/basic_object.rbs +9 -8
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +45 -31
- data/core/complex.rbs +66 -55
- data/core/dir.rbs +57 -45
- data/core/encoding.rbs +6 -6
- data/core/enumerable.rbs +105 -91
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +24 -3
- data/core/errno.rbs +3 -2
- data/core/errors.rbs +31 -29
- data/core/exception.rbs +12 -12
- data/core/fiber.rbs +47 -36
- data/core/file.rbs +242 -169
- data/core/file_test.rbs +2 -2
- data/core/float.rbs +42 -68
- data/core/gc.rbs +78 -70
- data/core/hash.rbs +70 -60
- data/core/integer.rbs +32 -75
- data/core/io/buffer.rbs +36 -36
- data/core/io/wait.rbs +7 -7
- data/core/io.rbs +192 -146
- data/core/kernel.rbs +198 -147
- data/core/marshal.rbs +3 -3
- data/core/match_data.rbs +14 -12
- data/core/math.rbs +69 -67
- data/core/method.rbs +6 -8
- data/core/module.rbs +148 -88
- data/core/nil_class.rbs +4 -3
- data/core/numeric.rbs +53 -50
- data/core/object.rbs +6 -8
- data/core/object_space.rbs +11 -10
- data/core/pathname.rbs +131 -81
- data/core/proc.rbs +65 -34
- data/core/process.rbs +221 -201
- data/core/ractor.rbs +15 -11
- data/core/random.rbs +21 -3
- data/core/range.rbs +152 -49
- data/core/rational.rbs +5 -56
- 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 -116
- 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 +318 -298
- data/core/struct.rbs +26 -25
- data/core/symbol.rbs +25 -24
- data/core/thread.rbs +40 -41
- 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 +576 -0
- data/docs/syntax.md +46 -16
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +595 -98
- data/ext/rbs_extension/class_constants.c +30 -0
- data/ext/rbs_extension/class_constants.h +15 -0
- data/ext/rbs_extension/legacy_location.c +30 -53
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +125 -24
- data/include/rbs/ast.h +485 -150
- data/include/rbs/lexer.h +11 -4
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +20 -2
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +409 -0
- data/lib/rbs/ast/ruby/comment_block.rb +245 -0
- data/lib/rbs/ast/ruby/declarations.rb +281 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +723 -0
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +105 -20
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +62 -125
- data/lib/rbs/cli.rb +55 -23
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -4
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/collection.rb +0 -1
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +119 -63
- data/lib/rbs/definition_builder/method_builder.rb +65 -30
- data/lib/rbs/definition_builder.rb +177 -20
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -0
- data/lib/rbs/environment.rb +338 -155
- data/lib/rbs/environment_loader.rb +2 -2
- data/lib/rbs/errors.rb +30 -20
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +542 -0
- data/lib/rbs/location_aux.rb +36 -4
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/namespace.rb +0 -7
- data/lib/rbs/parser_aux.rb +31 -8
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +3 -28
- data/lib/rbs/prototype/rbi.rb +3 -20
- data/lib/rbs/prototype/runtime.rb +10 -2
- data/lib/rbs/resolver/type_name_resolver.rb +0 -8
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +4 -3
- data/lib/rbs/test/type_check.rb +5 -2
- data/lib/rbs/type_name.rb +1 -8
- data/lib/rbs/types.rb +88 -78
- data/lib/rbs/unit_test/convertibles.rb +1 -0
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +12 -1
- data/rbs.gemspec +3 -2
- 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/schema/typeParam.json +17 -1
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/ast/ruby/annotations.rbs +421 -0
- data/sig/ast/ruby/comment_block.rbs +127 -0
- data/sig/ast/ruby/declarations.rbs +158 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +178 -0
- data/sig/buffer.rbs +63 -5
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +12 -8
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -0
- data/sig/definition_builder.rbs +3 -1
- data/sig/environment/class_entry.rbs +50 -0
- data/sig/environment/module_entry.rbs +50 -0
- data/sig/environment.rbs +37 -81
- data/sig/errors.rbs +26 -20
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +124 -0
- data/sig/location.rbs +32 -7
- data/sig/locator.rbs +0 -2
- data/sig/method_builder.rbs +9 -4
- data/sig/namespace.rbs +0 -5
- data/sig/parser.rbs +47 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/resolver/type_name_resolver.rbs +0 -3
- data/sig/source.rbs +48 -0
- data/sig/type_param.rbs +13 -8
- data/sig/typename.rbs +0 -5
- data/sig/types.rbs +6 -7
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +491 -143
- data/src/lexer.c +1552 -1314
- data/src/lexer.re +7 -0
- data/src/lexstate.c +8 -1
- data/src/location.c +8 -48
- data/src/parser.c +1107 -409
- 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/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +64 -53
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +140 -126
- data/stdlib/forwardable/0/forwardable.rbs +10 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +158 -131
- 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 -30
- data/stdlib/open-uri/0/open-uri.rbs +8 -8
- data/stdlib/open3/0/open3.rbs +469 -10
- data/stdlib/openssl/0/openssl.rbs +144 -129
- data/stdlib/optparse/0/optparse.rbs +23 -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 +62 -9
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/ripper/0/ripper.rbs +20 -17
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -20
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/socket/0/addrinfo.rbs +9 -9
- 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 +31 -18
- data/stdlib/uri/0/file.rbs +2 -2
- data/stdlib/uri/0/generic.rbs +9 -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 +6 -6
- 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 +66 -3
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.
|
|
@@ -204,8 +207,9 @@ module Kernel : BasicObject
|
|
|
204
207
|
# Optionally you can pass a range, which will return an array containing the
|
|
205
208
|
# entries within the specified range.
|
|
206
209
|
#
|
|
207
|
-
def self?.caller_locations: (
|
|
208
|
-
| (
|
|
210
|
+
def self?.caller_locations: (Integer start_or_range, ?Integer length) -> ::Array[Thread::Backtrace::Location]?
|
|
211
|
+
| (::Range[Integer] start_or_range) -> ::Array[Thread::Backtrace::Location]?
|
|
212
|
+
| () -> ::Array[Thread::Backtrace::Location]
|
|
209
213
|
|
|
210
214
|
# <!--
|
|
211
215
|
# rdoc-file=vm_eval.c
|
|
@@ -216,10 +220,10 @@ module Kernel : BasicObject
|
|
|
216
220
|
#
|
|
217
221
|
# catch(1) { 123 } # => 123
|
|
218
222
|
#
|
|
219
|
-
# If
|
|
220
|
-
# block whose `tag` has the same `object_id` as *tag2*. When found, the
|
|
221
|
-
# stops executing and returns *val* (or `nil` if no second argument was
|
|
222
|
-
# `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`).
|
|
223
227
|
#
|
|
224
228
|
# catch(1) { throw(1, 456) } # => 456
|
|
225
229
|
# catch(1) { throw(1) } # => nil
|
|
@@ -230,8 +234,8 @@ module Kernel : BasicObject
|
|
|
230
234
|
# catch(1) {|x| x + 2 } # => 3
|
|
231
235
|
#
|
|
232
236
|
# When no `tag` is given, `catch` yields a new unique object (as from
|
|
233
|
-
#
|
|
234
|
-
# 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.
|
|
235
239
|
#
|
|
236
240
|
# catch do |obj_A|
|
|
237
241
|
# catch do |obj_B|
|
|
@@ -295,7 +299,7 @@ module Kernel : BasicObject
|
|
|
295
299
|
# - block_given? -> true or false
|
|
296
300
|
# -->
|
|
297
301
|
# Returns `true` if `yield` would execute a block in the current context. The
|
|
298
|
-
#
|
|
302
|
+
# <code>iterator?</code> form is mildly deprecated.
|
|
299
303
|
#
|
|
300
304
|
# def try
|
|
301
305
|
# if block_given?
|
|
@@ -421,7 +425,8 @@ module Kernel : BasicObject
|
|
|
421
425
|
# Array({foo: 0, bar: 1}) # => [[:foo, 0], [:bar, 1]]
|
|
422
426
|
# Array(0..4) # => [0, 1, 2, 3, 4]
|
|
423
427
|
#
|
|
424
|
-
# Returns `object` in an array,
|
|
428
|
+
# Returns `object` in an array, <code>[object]</code>, if `object` cannot be
|
|
429
|
+
# converted:
|
|
425
430
|
#
|
|
426
431
|
# Array(:foo) # => [:foo]
|
|
427
432
|
#
|
|
@@ -437,8 +442,8 @@ module Kernel : BasicObject
|
|
|
437
442
|
# Returns a new Complex object if the arguments are valid; otherwise raises an
|
|
438
443
|
# exception if `exception` is `true`; otherwise returns `nil`.
|
|
439
444
|
#
|
|
440
|
-
# With Numeric arguments `real` and `imag`, returns
|
|
441
|
-
# 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.
|
|
442
447
|
#
|
|
443
448
|
# With string argument `s`, returns a new Complex object if the argument is
|
|
444
449
|
# valid; the string may have:
|
|
@@ -448,7 +453,7 @@ module Kernel : BasicObject
|
|
|
448
453
|
# coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
|
|
449
454
|
#
|
|
450
455
|
# * Sign-separated real and imaginary numeric substrings (with trailing
|
|
451
|
-
# character
|
|
456
|
+
# character <code>'i'</code>):
|
|
452
457
|
#
|
|
453
458
|
# Complex('1+2i') # => (1+2i)
|
|
454
459
|
# Complex('+1+2i') # => (1+2i)
|
|
@@ -456,13 +461,15 @@ module Kernel : BasicObject
|
|
|
456
461
|
# Complex('-1+2i') # => (-1+2i)
|
|
457
462
|
# Complex('-1-2i') # => (-1-2i)
|
|
458
463
|
#
|
|
459
|
-
# * Real-only numeric string (without trailing character
|
|
464
|
+
# * Real-only numeric string (without trailing character
|
|
465
|
+
# <code>'i'</code>):
|
|
460
466
|
#
|
|
461
467
|
# Complex('1') # => (1+0i)
|
|
462
468
|
# Complex('+1') # => (1+0i)
|
|
463
469
|
# Complex('-1') # => (-1+0i)
|
|
464
470
|
#
|
|
465
|
-
# * Imaginary-only numeric string (with trailing character
|
|
471
|
+
# * Imaginary-only numeric string (with trailing character
|
|
472
|
+
# <code>'i'</code>):
|
|
466
473
|
#
|
|
467
474
|
# Complex('1i') # => (0+1i)
|
|
468
475
|
# Complex('+1i') # => (0+1i)
|
|
@@ -489,10 +496,10 @@ module Kernel : BasicObject
|
|
|
489
496
|
# - Float(arg, exception: true) -> float or nil
|
|
490
497
|
# -->
|
|
491
498
|
# Returns *arg* converted to a float. Numeric types are converted directly, and
|
|
492
|
-
# with exception to String and `nil`, the rest are converted using
|
|
493
|
-
# Converting a String with invalid characters will
|
|
494
|
-
# Converting `nil` generates a TypeError. Exceptions
|
|
495
|
-
# 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>.
|
|
496
503
|
#
|
|
497
504
|
# Float(1) #=> 1.0
|
|
498
505
|
# Float("123.456") #=> 123.456
|
|
@@ -515,7 +522,8 @@ module Kernel : BasicObject
|
|
|
515
522
|
# * A hash, returns `object`.
|
|
516
523
|
# * An empty array or `nil`, returns an empty hash.
|
|
517
524
|
#
|
|
518
|
-
# * Otherwise, if
|
|
525
|
+
# * Otherwise, if <code>object.to_hash</code> returns a hash, returns that
|
|
526
|
+
# hash.
|
|
519
527
|
# * Otherwise, returns TypeError.
|
|
520
528
|
#
|
|
521
529
|
# Examples:
|
|
@@ -621,7 +629,7 @@ module Kernel : BasicObject
|
|
|
621
629
|
# - Rational(x, y, exception: true) -> rational or nil
|
|
622
630
|
# - Rational(arg, exception: true) -> rational or nil
|
|
623
631
|
# -->
|
|
624
|
-
# Returns
|
|
632
|
+
# Returns <code>x/y</code> or `arg` as a Rational.
|
|
625
633
|
#
|
|
626
634
|
# Rational(2, 3) #=> (2/3)
|
|
627
635
|
# Rational(5) #=> (5/1)
|
|
@@ -697,7 +705,7 @@ module Kernel : BasicObject
|
|
|
697
705
|
# Returns the canonicalized absolute path of the directory of the file from
|
|
698
706
|
# which this method is called. It means symlinks in the path is resolved. If
|
|
699
707
|
# `__FILE__` is `nil`, it returns `nil`. The return value equals to
|
|
700
|
-
#
|
|
708
|
+
# <code>File.dirname(File.realpath(__FILE__))</code>.
|
|
701
709
|
#
|
|
702
710
|
def self?.__dir__: () -> String?
|
|
703
711
|
|
|
@@ -714,8 +722,8 @@ module Kernel : BasicObject
|
|
|
714
722
|
# rdoc-file=io.c
|
|
715
723
|
# - `command` -> string
|
|
716
724
|
# -->
|
|
717
|
-
# Returns the
|
|
718
|
-
# variable
|
|
725
|
+
# Returns the <code>$stdout</code> output from running `command` in a subshell;
|
|
726
|
+
# sets global variable <code>$?</code> to the process status.
|
|
719
727
|
#
|
|
720
728
|
# This method has potential security vulnerabilities if called with untrusted
|
|
721
729
|
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
@@ -727,7 +735,7 @@ module Kernel : BasicObject
|
|
|
727
735
|
# $ $? # => #<Process::Status: pid 17088 exit 99>
|
|
728
736
|
# $ $?.exitstatus # => 99
|
|
729
737
|
#
|
|
730
|
-
# The built-in syntax
|
|
738
|
+
# The built-in syntax <code>%x{...}</code> uses this method.
|
|
731
739
|
#
|
|
732
740
|
def self?.`: (String arg0) -> String
|
|
733
741
|
|
|
@@ -736,7 +744,8 @@ module Kernel : BasicObject
|
|
|
736
744
|
# - abort
|
|
737
745
|
# - Process.abort(msg = nil)
|
|
738
746
|
# -->
|
|
739
|
-
# Terminates execution immediately, effectively by calling
|
|
747
|
+
# Terminates execution immediately, effectively by calling
|
|
748
|
+
# <code>Kernel.exit(false)</code>.
|
|
740
749
|
#
|
|
741
750
|
# If string argument `msg` is given, it is written to STDERR prior to
|
|
742
751
|
# termination; otherwise, if an exception was raised, prints its message and
|
|
@@ -759,7 +768,7 @@ module Kernel : BasicObject
|
|
|
759
768
|
# do_at_exit("goodbye ")
|
|
760
769
|
# exit
|
|
761
770
|
#
|
|
762
|
-
#
|
|
771
|
+
# <em>produces:</em>
|
|
763
772
|
#
|
|
764
773
|
# goodbye cruel world
|
|
765
774
|
#
|
|
@@ -986,13 +995,14 @@ module Kernel : BasicObject
|
|
|
986
995
|
# end
|
|
987
996
|
# # => #<RuntimeError: RuntimeError>
|
|
988
997
|
#
|
|
989
|
-
# 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>.
|
|
990
1000
|
#
|
|
991
1001
|
# See [Cause](rdoc-ref:exceptions.md@Cause).
|
|
992
1002
|
#
|
|
993
1003
|
# In the alternate calling sequence, where argument `exception` *not* given,
|
|
994
|
-
# raises a new exception of the class given by
|
|
995
|
-
#
|
|
1004
|
+
# raises a new exception of the class given by <code>$!</code>, or of class
|
|
1005
|
+
# RuntimeError if <code>$!</code> is `nil`:
|
|
996
1006
|
#
|
|
997
1007
|
# begin
|
|
998
1008
|
# raise
|
|
@@ -1008,7 +1018,7 @@ module Kernel : BasicObject
|
|
|
1008
1018
|
#
|
|
1009
1019
|
def self?.fail: () -> bot
|
|
1010
1020
|
| (string message, ?cause: Exception?) -> bot
|
|
1011
|
-
| (_Exception exception, ?_ToS
|
|
1021
|
+
| (_Exception exception, ?string | _ToS message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot
|
|
1012
1022
|
| (_Exception exception, ?cause: Exception?, **untyped) -> bot
|
|
1013
1023
|
|
|
1014
1024
|
# <!--
|
|
@@ -1094,13 +1104,14 @@ module Kernel : BasicObject
|
|
|
1094
1104
|
# end
|
|
1095
1105
|
# # => #<RuntimeError: RuntimeError>
|
|
1096
1106
|
#
|
|
1097
|
-
# 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>.
|
|
1098
1109
|
#
|
|
1099
1110
|
# See [Cause](rdoc-ref:exceptions.md@Cause).
|
|
1100
1111
|
#
|
|
1101
1112
|
# In the alternate calling sequence, where argument `exception` *not* given,
|
|
1102
|
-
# raises a new exception of the class given by
|
|
1103
|
-
#
|
|
1113
|
+
# raises a new exception of the class given by <code>$!</code>, or of class
|
|
1114
|
+
# RuntimeError if <code>$!</code> is `nil`:
|
|
1104
1115
|
#
|
|
1105
1116
|
# begin
|
|
1106
1117
|
# raise
|
|
@@ -1145,29 +1156,29 @@ module Kernel : BasicObject
|
|
|
1145
1156
|
# - gets(limit [, getline_args]) -> string or nil
|
|
1146
1157
|
# - gets(sep, limit [, getline_args]) -> string or nil
|
|
1147
1158
|
# -->
|
|
1148
|
-
# Returns (and assigns to
|
|
1149
|
-
# (or
|
|
1150
|
-
# Returns `nil` at end of file. The optional argument
|
|
1151
|
-
# separator. The separator is included with the contents of
|
|
1152
|
-
# separator of `nil` reads the entire contents, and a zero-length
|
|
1153
|
-
# reads the input one paragraph at a time, where paragraphs are
|
|
1154
|
-
# consecutive newlines. If the first argument is an integer, or
|
|
1155
|
-
# argument is given, the returning string would not be longer
|
|
1156
|
-
# value in bytes. If multiple filenames are present in `ARGV`,
|
|
1157
|
-
# 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.
|
|
1158
1169
|
#
|
|
1159
1170
|
# ARGV << "testfile"
|
|
1160
1171
|
# print while gets
|
|
1161
1172
|
#
|
|
1162
|
-
#
|
|
1173
|
+
# <em>produces:</em>
|
|
1163
1174
|
#
|
|
1164
1175
|
# This is line one
|
|
1165
1176
|
# This is line two
|
|
1166
1177
|
# This is line three
|
|
1167
1178
|
# And so on...
|
|
1168
1179
|
#
|
|
1169
|
-
# The style of programming using
|
|
1170
|
-
# 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.
|
|
1171
1182
|
#
|
|
1172
1183
|
def self?.gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
|
|
1173
1184
|
|
|
@@ -1176,8 +1187,9 @@ module Kernel : BasicObject
|
|
|
1176
1187
|
# - global_variables -> array
|
|
1177
1188
|
# -->
|
|
1178
1189
|
# Returns an array of the names of global variables. This includes special
|
|
1179
|
-
# regexp global variables such as
|
|
1180
|
-
# 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.).
|
|
1181
1193
|
#
|
|
1182
1194
|
# global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
|
|
1183
1195
|
#
|
|
@@ -1196,10 +1208,10 @@ module Kernel : BasicObject
|
|
|
1196
1208
|
# the file will be loaded using the relative path from the current directory.
|
|
1197
1209
|
#
|
|
1198
1210
|
# Otherwise, the file will be searched for in the library directories listed in
|
|
1199
|
-
#
|
|
1200
|
-
# load the file relative to that directory. If
|
|
1201
|
-
# the
|
|
1202
|
-
# 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.
|
|
1203
1215
|
#
|
|
1204
1216
|
# If the file doesn't exist when there is an attempt to load it, a LoadError
|
|
1205
1217
|
# will be raised.
|
|
@@ -1252,9 +1264,6 @@ module Kernel : BasicObject
|
|
|
1252
1264
|
# -->
|
|
1253
1265
|
# Creates an IO object connected to the given file.
|
|
1254
1266
|
#
|
|
1255
|
-
# This method has potential security vulnerabilities if called with untrusted
|
|
1256
|
-
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1257
|
-
#
|
|
1258
1267
|
# With no block given, file stream is returned:
|
|
1259
1268
|
#
|
|
1260
1269
|
# open('t.txt') # => #<File:t.txt>
|
|
@@ -1277,18 +1286,19 @@ module Kernel : BasicObject
|
|
|
1277
1286
|
# rdoc-file=io.c
|
|
1278
1287
|
# - print(*objects) -> nil
|
|
1279
1288
|
# -->
|
|
1280
|
-
# Equivalent to
|
|
1281
|
-
# 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>.
|
|
1282
1291
|
#
|
|
1283
|
-
# Writes the given objects to
|
|
1284
|
-
# 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`.
|
|
1285
1295
|
#
|
|
1286
1296
|
# With argument `objects` given, for each object:
|
|
1287
1297
|
#
|
|
1288
1298
|
# * Converts via its method `to_s` if not a string.
|
|
1289
1299
|
# * Writes to `stdout`.
|
|
1290
1300
|
# * If not the last object, writes the output field separator
|
|
1291
|
-
#
|
|
1301
|
+
# <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code> if it is not `nil`.
|
|
1292
1302
|
#
|
|
1293
1303
|
# With default separators:
|
|
1294
1304
|
#
|
|
@@ -1313,8 +1323,8 @@ module Kernel : BasicObject
|
|
|
1313
1323
|
#
|
|
1314
1324
|
# 0,0.0,0/1,0+0i,zero,zero
|
|
1315
1325
|
#
|
|
1316
|
-
# With no argument given, writes the content of
|
|
1317
|
-
# recent user input):
|
|
1326
|
+
# With no argument given, writes the content of <code>$_</code> (which is
|
|
1327
|
+
# usually the most recent user input):
|
|
1318
1328
|
#
|
|
1319
1329
|
# gets # Sets $_ to the most recent user input.
|
|
1320
1330
|
# print # Prints $_.
|
|
@@ -1436,7 +1446,7 @@ module Kernel : BasicObject
|
|
|
1436
1446
|
# -->
|
|
1437
1447
|
# prints arguments in pretty form.
|
|
1438
1448
|
#
|
|
1439
|
-
#
|
|
1449
|
+
# <code>#pp</code> returns argument(s).
|
|
1440
1450
|
#
|
|
1441
1451
|
def self?.pp: [T] (T arg0) -> T
|
|
1442
1452
|
| (untyped, untyped, *untyped) -> Array[untyped]
|
|
@@ -1446,19 +1456,20 @@ module Kernel : BasicObject
|
|
|
1446
1456
|
# rdoc-file=random.c
|
|
1447
1457
|
# - rand(max=0) -> number
|
|
1448
1458
|
# -->
|
|
1449
|
-
# If called without an argument, or if
|
|
1450
|
-
# pseudo-random floating point number between 0.0 and 1.0, including
|
|
1451
|
-
# 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.
|
|
1452
1462
|
#
|
|
1453
1463
|
# rand #=> 0.2725926052826416
|
|
1454
1464
|
#
|
|
1455
|
-
# When
|
|
1456
|
-
# 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>.
|
|
1457
1468
|
#
|
|
1458
1469
|
# rand(100) #=> 12
|
|
1459
1470
|
#
|
|
1460
1471
|
# When `max` is a Range, `rand` returns a random number where
|
|
1461
|
-
#
|
|
1472
|
+
# <code>range.member?(number) == true</code>.
|
|
1462
1473
|
#
|
|
1463
1474
|
# Negative or floating point values for `max` are allowed, but may give
|
|
1464
1475
|
# surprising results.
|
|
@@ -1559,7 +1570,7 @@ module Kernel : BasicObject
|
|
|
1559
1570
|
# When RubyGems is required, Kernel#require is replaced with our own which is
|
|
1560
1571
|
# capable of loading gems on demand.
|
|
1561
1572
|
#
|
|
1562
|
-
# When you call
|
|
1573
|
+
# When you call <code>require 'x'</code>, this is what happens:
|
|
1563
1574
|
# * If the file can be loaded from the existing Ruby loadpath, it is.
|
|
1564
1575
|
# * Otherwise, installed gems are searched for a file that matches. If it's
|
|
1565
1576
|
# found in gem 'y', that gem is activated (added to the loadpath).
|
|
@@ -1594,8 +1605,9 @@ module Kernel : BasicObject
|
|
|
1594
1605
|
# IO objects.
|
|
1595
1606
|
#
|
|
1596
1607
|
# Argument `timeout` is a numeric value (such as integer or float) timeout
|
|
1597
|
-
# interval in seconds. `timeout` can also be `nil` or
|
|
1598
|
-
# 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.
|
|
1599
1611
|
#
|
|
1600
1612
|
# The method monitors the IO objects given in all three arrays, waiting for some
|
|
1601
1613
|
# to be ready; returns a 3-element array whose elements are:
|
|
@@ -1670,8 +1682,8 @@ module Kernel : BasicObject
|
|
|
1670
1682
|
#
|
|
1671
1683
|
# The writability notified by select(2) doesn't show how many bytes are
|
|
1672
1684
|
# writable. IO#write method blocks until given whole string is written. So,
|
|
1673
|
-
#
|
|
1674
|
-
# 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.
|
|
1675
1687
|
#
|
|
1676
1688
|
# Blocking write (#write) can be emulated using #write_nonblock and IO.select as
|
|
1677
1689
|
# follows: IO::WaitReadable should also be rescued for SSL renegotiation in
|
|
@@ -1739,11 +1751,6 @@ module Kernel : BasicObject
|
|
|
1739
1751
|
def self?.sleep: (?nil) -> bot
|
|
1740
1752
|
| (Time::_Timeout duration) -> Integer
|
|
1741
1753
|
|
|
1742
|
-
%a{deprecated}
|
|
1743
|
-
interface _Divmod
|
|
1744
|
-
def divmod: (Numeric) -> [ Numeric, Numeric ]
|
|
1745
|
-
end
|
|
1746
|
-
|
|
1747
1754
|
# <!--
|
|
1748
1755
|
# rdoc-file=io.c
|
|
1749
1756
|
# - syscall(integer_callno, *arguments) -> integer
|
|
@@ -1783,58 +1790,58 @@ module Kernel : BasicObject
|
|
|
1783
1790
|
# * Each of these tests operates only on the entity at `path0`,
|
|
1784
1791
|
# and returns `true` or `false`;
|
|
1785
1792
|
# for a non-existent entity, returns `false` (does not raise exception):
|
|
1786
|
-
#
|
|
1787
|
-
#
|
|
1788
|
-
#
|
|
1789
|
-
#
|
|
1790
|
-
#
|
|
1791
|
-
#
|
|
1792
|
-
#
|
|
1793
|
-
#
|
|
1794
|
-
#
|
|
1795
|
-
#
|
|
1796
|
-
#
|
|
1797
|
-
#
|
|
1798
|
-
#
|
|
1799
|
-
#
|
|
1800
|
-
#
|
|
1801
|
-
#
|
|
1802
|
-
#
|
|
1803
|
-
#
|
|
1804
|
-
#
|
|
1805
|
-
#
|
|
1806
|
-
#
|
|
1807
|
-
#
|
|
1808
|
-
#
|
|
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.
|
|
1809
1816
|
# * This test operates only on the entity at `path0`,
|
|
1810
|
-
# and returns an integer size or
|
|
1811
|
-
#
|
|
1812
|
-
#
|
|
1813
|
-
#
|
|
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.
|
|
1814
1821
|
# * Each of these tests operates only on the entity at `path0`,
|
|
1815
1822
|
# and returns a Time object;
|
|
1816
1823
|
# raises an exception if the entity does not exist:
|
|
1817
|
-
#
|
|
1818
|
-
#
|
|
1819
|
-
#
|
|
1820
|
-
#
|
|
1821
|
-
#
|
|
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.
|
|
1822
1829
|
# * Each of these tests operates on the modification time (`mtime`)
|
|
1823
1830
|
# of each of the entities at `path0` and `path1`,
|
|
1824
1831
|
# and returns a `true` or `false`;
|
|
1825
1832
|
# returns `false` if either entity does not exist:
|
|
1826
|
-
#
|
|
1827
|
-
#
|
|
1828
|
-
#
|
|
1829
|
-
#
|
|
1830
|
-
#
|
|
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`.
|
|
1831
1838
|
# * This test operates on the content of each of the entities at `path0` and
|
|
1832
1839
|
# `path1`,
|
|
1833
1840
|
# and returns a `true` or `false`;
|
|
1834
1841
|
# returns `false` if either entity does not exist:
|
|
1835
|
-
#
|
|
1836
|
-
#
|
|
1837
|
-
#
|
|
1842
|
+
# Character |Test
|
|
1843
|
+
# ----------------|---------------------------------------------
|
|
1844
|
+
# <code>'-'</code>|Whether the entities exist and are identical.
|
|
1838
1845
|
#
|
|
1839
1846
|
def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
|
|
1840
1847
|
|
|
@@ -1853,14 +1860,14 @@ module Kernel : BasicObject
|
|
|
1853
1860
|
# rdoc-file=warning.rb
|
|
1854
1861
|
# - warn(*msgs, uplevel: nil, category: nil) -> nil
|
|
1855
1862
|
# -->
|
|
1856
|
-
# If warnings have been disabled (for example with the
|
|
1857
|
-
# 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
|
|
1858
1865
|
# newline character to the string if the string does not end in a newline, and
|
|
1859
1866
|
# calls Warning.warn with the string.
|
|
1860
1867
|
#
|
|
1861
1868
|
# warn("warning 1", "warning 2")
|
|
1862
1869
|
#
|
|
1863
|
-
#
|
|
1870
|
+
# <em>produces:</em>
|
|
1864
1871
|
#
|
|
1865
1872
|
# warning 1
|
|
1866
1873
|
# warning 2
|
|
@@ -1880,12 +1887,13 @@ module Kernel : BasicObject
|
|
|
1880
1887
|
#
|
|
1881
1888
|
# bar
|
|
1882
1889
|
#
|
|
1883
|
-
#
|
|
1890
|
+
# <em>produces:</em>
|
|
1884
1891
|
#
|
|
1885
1892
|
# baz.rb:6: warning: invalid call to foo
|
|
1886
1893
|
#
|
|
1887
1894
|
# If `category` keyword argument is given, passes the category to
|
|
1888
|
-
#
|
|
1895
|
+
# <code>Warning.warn</code>. The category given must be one of the following
|
|
1896
|
+
# categories:
|
|
1889
1897
|
#
|
|
1890
1898
|
# :deprecated
|
|
1891
1899
|
# : Used for warning for deprecated functionality that may be removed in the
|
|
@@ -1930,7 +1938,7 @@ module Kernel : BasicObject
|
|
|
1930
1938
|
# word or special built-in, or if it contains one or more meta characters.
|
|
1931
1939
|
# * `exe_path` otherwise.
|
|
1932
1940
|
#
|
|
1933
|
-
#
|
|
1941
|
+
# <strong>Argument `command_line`</strong>
|
|
1934
1942
|
#
|
|
1935
1943
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
1936
1944
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -1953,7 +1961,7 @@ module Kernel : BasicObject
|
|
|
1953
1961
|
#
|
|
1954
1962
|
# Raises an exception if the new process could not execute.
|
|
1955
1963
|
#
|
|
1956
|
-
#
|
|
1964
|
+
# <strong>Argument `exe_path`</strong>
|
|
1957
1965
|
#
|
|
1958
1966
|
# Argument `exe_path` is one of the following:
|
|
1959
1967
|
#
|
|
@@ -1987,8 +1995,8 @@ module Kernel : BasicObject
|
|
|
1987
1995
|
#
|
|
1988
1996
|
# Raises an exception if the new process could not execute.
|
|
1989
1997
|
#
|
|
1990
|
-
def self?.exec: (String command, *String args, ?unsetenv_others:
|
|
1991
|
-
| (Hash[string, string?] env, String command, *String args, ?unsetenv_others:
|
|
1998
|
+
def self?.exec: (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) -> bot
|
|
1999
|
+
| (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) -> bot
|
|
1992
2000
|
|
|
1993
2001
|
type redirect_fd = Integer | :in | :out | :err | IO | String | [ String ] | [ String, string | int ] | [ String, string | int, int ] | [ :child, int ] | :close
|
|
1994
2002
|
|
|
@@ -2030,7 +2038,7 @@ module Kernel : BasicObject
|
|
|
2030
2038
|
# word or special built-in, or if it contains one or more meta characters.
|
|
2031
2039
|
# * `exe_path` otherwise.
|
|
2032
2040
|
#
|
|
2033
|
-
#
|
|
2041
|
+
# <strong>Argument `command_line`</strong>
|
|
2034
2042
|
#
|
|
2035
2043
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
2036
2044
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -2059,7 +2067,7 @@ module Kernel : BasicObject
|
|
|
2059
2067
|
#
|
|
2060
2068
|
# Raises an exception if the new process could not execute.
|
|
2061
2069
|
#
|
|
2062
|
-
#
|
|
2070
|
+
# <strong>Argument `exe_path`</strong>
|
|
2063
2071
|
#
|
|
2064
2072
|
# Argument `exe_path` is one of the following:
|
|
2065
2073
|
#
|
|
@@ -2092,8 +2100,8 @@ module Kernel : BasicObject
|
|
|
2092
2100
|
#
|
|
2093
2101
|
# Raises an exception if the new process could not execute.
|
|
2094
2102
|
#
|
|
2095
|
-
def self?.spawn: (String command, *String args, ?unsetenv_others:
|
|
2096
|
-
| (Hash[string, string?] env, String command, *String args, ?unsetenv_others:
|
|
2103
|
+
def self?.spawn: (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) -> Integer
|
|
2104
|
+
| (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) -> Integer
|
|
2097
2105
|
|
|
2098
2106
|
# <!--
|
|
2099
2107
|
# rdoc-file=process.c
|
|
@@ -2117,7 +2125,7 @@ module Kernel : BasicObject
|
|
|
2117
2125
|
# Raises an exception (instead of returning `false` or `nil`) if keyword
|
|
2118
2126
|
# argument `exception` is set to `true`.
|
|
2119
2127
|
#
|
|
2120
|
-
# Assigns the command's error status to
|
|
2128
|
+
# Assigns the command's error status to <code>$?</code>.
|
|
2121
2129
|
#
|
|
2122
2130
|
# The new process is created using the [system system
|
|
2123
2131
|
# call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/s
|
|
@@ -2136,7 +2144,7 @@ module Kernel : BasicObject
|
|
|
2136
2144
|
# word or special built-in, or if it contains one or more meta characters.
|
|
2137
2145
|
# * `exe_path` otherwise.
|
|
2138
2146
|
#
|
|
2139
|
-
#
|
|
2147
|
+
# <strong>Argument `command_line`</strong>
|
|
2140
2148
|
#
|
|
2141
2149
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
2142
2150
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -2148,7 +2156,7 @@ module Kernel : BasicObject
|
|
|
2148
2156
|
# system('date > /nop/date.tmp') # => false
|
|
2149
2157
|
# system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
|
|
2150
2158
|
#
|
|
2151
|
-
# Assigns the command's error status to
|
|
2159
|
+
# Assigns the command's error status to <code>$?</code>:
|
|
2152
2160
|
#
|
|
2153
2161
|
# system('exit') # => true # Built-in.
|
|
2154
2162
|
# $? # => #<Process::Status: pid 640610 exit 0>
|
|
@@ -2168,7 +2176,7 @@ module Kernel : BasicObject
|
|
|
2168
2176
|
#
|
|
2169
2177
|
# Raises an exception if the new process could not execute.
|
|
2170
2178
|
#
|
|
2171
|
-
#
|
|
2179
|
+
# <strong>Argument `exe_path`</strong>
|
|
2172
2180
|
#
|
|
2173
2181
|
# Argument `exe_path` is one of the following:
|
|
2174
2182
|
#
|
|
@@ -2185,7 +2193,7 @@ module Kernel : BasicObject
|
|
|
2185
2193
|
#
|
|
2186
2194
|
# Mon Aug 28 11:43:10 AM CDT 2023
|
|
2187
2195
|
#
|
|
2188
|
-
# Assigns the command's error status to
|
|
2196
|
+
# Assigns the command's error status to <code>$?</code>:
|
|
2189
2197
|
#
|
|
2190
2198
|
# system('/usr/bin/date') # => true
|
|
2191
2199
|
# $? # => #<Process::Status: pid 645605 exit 0>
|
|
@@ -2210,8 +2218,51 @@ module Kernel : BasicObject
|
|
|
2210
2218
|
#
|
|
2211
2219
|
# Raises an exception if the new process could not execute.
|
|
2212
2220
|
#
|
|
2213
|
-
def self?.system: (String command, *String args, ?unsetenv_others:
|
|
2214
|
-
| (Hash[string, string?] env, String command, *String args, ?unsetenv_others:
|
|
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)
|
|
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)
|
|
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
|
|
2215
2266
|
|
|
2216
2267
|
# <!--
|
|
2217
2268
|
# rdoc-file=object.c
|
|
@@ -2258,8 +2309,8 @@ module Kernel : BasicObject
|
|
|
2258
2309
|
# -->
|
|
2259
2310
|
# Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
|
|
2260
2311
|
# but not the objects they reference. #clone copies the frozen value state of
|
|
2261
|
-
# *obj*, unless the
|
|
2262
|
-
# 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.
|
|
2263
2314
|
#
|
|
2264
2315
|
# class Klass
|
|
2265
2316
|
# attr_accessor :str
|