rbs 4.0.0.dev.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 +18 -11
- data/.github/workflows/comments.yml +5 -3
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/ruby.yml +27 -34
- data/.github/workflows/rust.yml +95 -0
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +323 -0
- data/README.md +1 -1
- data/Rakefile +43 -33
- data/Steepfile +1 -0
- data/config.yml +426 -24
- data/core/array.rbs +307 -227
- 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 +55 -34
- data/core/complex.rbs +104 -78
- data/core/dir.rbs +61 -49
- data/core/encoding.rbs +12 -15
- data/core/enumerable.rbs +179 -87
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +65 -2
- data/core/errno.rbs +11 -2
- data/core/errors.rbs +58 -29
- data/core/exception.rbs +13 -13
- data/core/fiber.rbs +74 -54
- data/core/file.rbs +280 -177
- data/core/file_test.rbs +3 -3
- data/core/float.rbs +257 -92
- data/core/gc.rbs +425 -281
- data/core/hash.rbs +1045 -739
- data/core/integer.rbs +135 -137
- data/core/io/buffer.rbs +53 -42
- data/core/io/wait.rbs +13 -35
- data/core/io.rbs +192 -144
- data/core/kernel.rbs +216 -155
- data/core/marshal.rbs +4 -4
- data/core/match_data.rbs +15 -13
- data/core/math.rbs +107 -66
- data/core/method.rbs +69 -33
- data/core/module.rbs +244 -106
- data/core/nil_class.rbs +7 -6
- data/core/numeric.rbs +74 -63
- data/core/object.rbs +9 -11
- data/core/object_space.rbs +30 -23
- data/core/pathname.rbs +1322 -0
- data/core/proc.rbs +95 -58
- data/core/process.rbs +222 -202
- data/core/ractor.rbs +371 -515
- data/core/random.rbs +21 -3
- data/core/range.rbs +159 -57
- data/core/rational.rbs +60 -89
- data/core/rbs/unnamed/argf.rbs +60 -53
- data/core/rbs/unnamed/env_class.rbs +19 -14
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +11 -118
- data/core/regexp.rbs +258 -214
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +38 -34
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +4 -71
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +16 -82
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +490 -360
- data/core/signal.rbs +26 -16
- data/core/string.rbs +3234 -1285
- data/core/struct.rbs +27 -26
- data/core/symbol.rbs +41 -34
- data/core/thread.rbs +135 -67
- data/core/time.rbs +81 -50
- data/core/trace_point.rbs +41 -35
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +24 -16
- data/core/warning.rbs +7 -7
- data/docs/aliases.md +79 -0
- data/docs/collection.md +3 -3
- data/docs/config.md +171 -0
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +576 -0
- data/docs/sigs.md +3 -3
- 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 +544 -116
- data/ext/rbs_extension/ast_translation.h +3 -0
- data/ext/rbs_extension/class_constants.c +16 -2
- data/ext/rbs_extension/class_constants.h +8 -0
- data/ext/rbs_extension/extconf.rb +5 -1
- data/ext/rbs_extension/legacy_location.c +33 -56
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +44 -35
- data/include/rbs/ast.h +448 -173
- data/include/rbs/defines.h +27 -0
- data/include/rbs/lexer.h +30 -11
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +6 -6
- data/include/rbs/string.h +0 -2
- data/include/rbs/util/rbs_allocator.h +34 -13
- data/include/rbs/util/rbs_assert.h +12 -1
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs/util/rbs_encoding.h +2 -0
- data/include/rbs/util/rbs_unescape.h +2 -1
- 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 +293 -3
- data/lib/rbs/ast/ruby/comment_block.rb +24 -0
- data/lib/rbs/ast/ruby/declarations.rb +198 -3
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
- data/lib/rbs/ast/ruby/members.rb +532 -22
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +20 -15
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +38 -106
- data/lib/rbs/cli.rb +52 -19
- data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
- data/lib/rbs/definition_builder/method_builder.rb +20 -0
- data/lib/rbs/definition_builder.rb +147 -25
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment.rb +227 -74
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +27 -18
- data/lib/rbs/inline_parser.rb +342 -6
- data/lib/rbs/location_aux.rb +1 -1
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/parser_aux.rb +20 -7
- 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 +8 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +116 -38
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +19 -2
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +88 -78
- 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 +1 -2
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +4 -3
- 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/ast/ruby/annotations.rbs +315 -4
- data/sig/ast/ruby/comment_block.rbs +8 -0
- data/sig/ast/ruby/declarations.rbs +102 -4
- data/sig/ast/ruby/members.rbs +108 -2
- 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 -1
- data/sig/definition_builder.rbs +2 -0
- data/sig/environment.rbs +70 -12
- data/sig/errors.rbs +13 -14
- data/sig/inline_parser.rbs +39 -2
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -1
- data/sig/method_builder.rbs +3 -1
- data/sig/parser.rbs +31 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/resolver/type_name_resolver.rbs +35 -7
- data/sig/source.rbs +3 -3
- data/sig/type_param.rbs +13 -8
- 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 +410 -153
- data/src/lexer.c +1392 -1313
- data/src/lexer.re +3 -0
- data/src/lexstate.c +58 -37
- data/src/location.c +8 -48
- data/src/parser.c +977 -516
- data/src/string.c +0 -48
- data/src/util/rbs_allocator.c +89 -71
- data/src/util/rbs_assert.c +1 -1
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +10 -14
- data/src/util/rbs_encoding.c +4 -8
- data/src/util/rbs_unescape.c +56 -20
- data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +7 -4
- data/stdlib/date/0/date.rbs +92 -79
- data/stdlib/date/0/date_time.rbs +25 -24
- data/stdlib/delegate/0/delegator.rbs +10 -7
- 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 +748 -347
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +158 -139
- data/stdlib/forwardable/0/forwardable.rbs +13 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +217 -136
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +162 -134
- data/stdlib/objspace/0/objspace.rbs +17 -34
- data/stdlib/open-uri/0/open-uri.rbs +48 -8
- data/stdlib/open3/0/open3.rbs +469 -10
- data/stdlib/openssl/0/openssl.rbs +475 -357
- data/stdlib/optparse/0/optparse.rbs +26 -17
- data/stdlib/pathname/0/pathname.rbs +11 -1381
- 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 +65 -12
- 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/rdoc.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +22 -19
- 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/singleton/0/singleton.rbs +3 -0
- 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 +23 -10
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +11 -3
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +1177 -85
- data/stdlib/strscan/0/string_scanner.rbs +27 -25
- data/stdlib/tempfile/0/tempfile.rbs +25 -21
- data/stdlib/time/0/time.rbs +8 -6
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +42 -20
- data/stdlib/uri/0/file.rbs +3 -3
- data/stdlib/uri/0/generic.rbs +26 -18
- 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 +12 -12
- 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
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +50 -6
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,20 +722,20 @@ 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
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
729
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
722
730
|
#
|
|
723
731
|
# Examples:
|
|
724
732
|
#
|
|
725
733
|
# $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n"
|
|
726
734
|
# $ `echo oops && exit 99` # => "oops\n"
|
|
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
|
#
|
|
@@ -777,6 +786,8 @@ module Kernel : BasicObject
|
|
|
777
786
|
# If *const* is defined as autoload, the file name to be loaded is replaced with
|
|
778
787
|
# *filename*. If *const* is defined but not as autoload, does nothing.
|
|
779
788
|
#
|
|
789
|
+
# Files that are currently being loaded must not be registered for autoload.
|
|
790
|
+
#
|
|
780
791
|
def self?.autoload: (interned _module, String filename) -> NilClass
|
|
781
792
|
|
|
782
793
|
# <!--
|
|
@@ -984,13 +995,14 @@ module Kernel : BasicObject
|
|
|
984
995
|
# end
|
|
985
996
|
# # => #<RuntimeError: RuntimeError>
|
|
986
997
|
#
|
|
987
|
-
# 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>.
|
|
988
1000
|
#
|
|
989
1001
|
# See [Cause](rdoc-ref:exceptions.md@Cause).
|
|
990
1002
|
#
|
|
991
1003
|
# In the alternate calling sequence, where argument `exception` *not* given,
|
|
992
|
-
# raises a new exception of the class given by
|
|
993
|
-
#
|
|
1004
|
+
# raises a new exception of the class given by <code>$!</code>, or of class
|
|
1005
|
+
# RuntimeError if <code>$!</code> is `nil`:
|
|
994
1006
|
#
|
|
995
1007
|
# begin
|
|
996
1008
|
# raise
|
|
@@ -1002,9 +1014,11 @@ module Kernel : BasicObject
|
|
|
1002
1014
|
# With argument `exception` not given, argument `message` and keyword argument
|
|
1003
1015
|
# `cause` may be given, but argument `backtrace` may not be given.
|
|
1004
1016
|
#
|
|
1017
|
+
# `cause` can not be given as an only argument.
|
|
1018
|
+
#
|
|
1005
1019
|
def self?.fail: () -> bot
|
|
1006
1020
|
| (string message, ?cause: Exception?) -> bot
|
|
1007
|
-
| (_Exception exception, ?_ToS
|
|
1021
|
+
| (_Exception exception, ?string | _ToS message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot
|
|
1008
1022
|
| (_Exception exception, ?cause: Exception?, **untyped) -> bot
|
|
1009
1023
|
|
|
1010
1024
|
# <!--
|
|
@@ -1090,13 +1104,14 @@ module Kernel : BasicObject
|
|
|
1090
1104
|
# end
|
|
1091
1105
|
# # => #<RuntimeError: RuntimeError>
|
|
1092
1106
|
#
|
|
1093
|
-
# 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>.
|
|
1094
1109
|
#
|
|
1095
1110
|
# See [Cause](rdoc-ref:exceptions.md@Cause).
|
|
1096
1111
|
#
|
|
1097
1112
|
# In the alternate calling sequence, where argument `exception` *not* given,
|
|
1098
|
-
# raises a new exception of the class given by
|
|
1099
|
-
#
|
|
1113
|
+
# raises a new exception of the class given by <code>$!</code>, or of class
|
|
1114
|
+
# RuntimeError if <code>$!</code> is `nil`:
|
|
1100
1115
|
#
|
|
1101
1116
|
# begin
|
|
1102
1117
|
# raise
|
|
@@ -1108,6 +1123,8 @@ module Kernel : BasicObject
|
|
|
1108
1123
|
# With argument `exception` not given, argument `message` and keyword argument
|
|
1109
1124
|
# `cause` may be given, but argument `backtrace` may not be given.
|
|
1110
1125
|
#
|
|
1126
|
+
# `cause` can not be given as an only argument.
|
|
1127
|
+
#
|
|
1111
1128
|
alias raise fail
|
|
1112
1129
|
|
|
1113
1130
|
alias self.raise self.fail
|
|
@@ -1116,7 +1133,7 @@ module Kernel : BasicObject
|
|
|
1116
1133
|
# Returns the string resulting from formatting `objects` into `format_string`.
|
|
1117
1134
|
#
|
|
1118
1135
|
# For details on `format_string`, see [Format
|
|
1119
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1136
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1120
1137
|
#
|
|
1121
1138
|
def self?.format: (String format, *untyped args) -> String
|
|
1122
1139
|
|
|
@@ -1127,7 +1144,7 @@ module Kernel : BasicObject
|
|
|
1127
1144
|
# Returns the string resulting from formatting `objects` into `format_string`.
|
|
1128
1145
|
#
|
|
1129
1146
|
# For details on `format_string`, see [Format
|
|
1130
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1147
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1131
1148
|
#
|
|
1132
1149
|
alias sprintf format
|
|
1133
1150
|
|
|
@@ -1139,29 +1156,29 @@ module Kernel : BasicObject
|
|
|
1139
1156
|
# - gets(limit [, getline_args]) -> string or nil
|
|
1140
1157
|
# - gets(sep, limit [, getline_args]) -> string or nil
|
|
1141
1158
|
# -->
|
|
1142
|
-
# Returns (and assigns to
|
|
1143
|
-
# (or
|
|
1144
|
-
# Returns `nil` at end of file. The optional argument
|
|
1145
|
-
# separator. The separator is included with the contents of
|
|
1146
|
-
# separator of `nil` reads the entire contents, and a zero-length
|
|
1147
|
-
# reads the input one paragraph at a time, where paragraphs are
|
|
1148
|
-
# consecutive newlines. If the first argument is an integer, or
|
|
1149
|
-
# argument is given, the returning string would not be longer
|
|
1150
|
-
# value in bytes. If multiple filenames are present in `ARGV`,
|
|
1151
|
-
# 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.
|
|
1152
1169
|
#
|
|
1153
1170
|
# ARGV << "testfile"
|
|
1154
1171
|
# print while gets
|
|
1155
1172
|
#
|
|
1156
|
-
#
|
|
1173
|
+
# <em>produces:</em>
|
|
1157
1174
|
#
|
|
1158
1175
|
# This is line one
|
|
1159
1176
|
# This is line two
|
|
1160
1177
|
# This is line three
|
|
1161
1178
|
# And so on...
|
|
1162
1179
|
#
|
|
1163
|
-
# The style of programming using
|
|
1164
|
-
# 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.
|
|
1165
1182
|
#
|
|
1166
1183
|
def self?.gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
|
|
1167
1184
|
|
|
@@ -1170,8 +1187,9 @@ module Kernel : BasicObject
|
|
|
1170
1187
|
# - global_variables -> array
|
|
1171
1188
|
# -->
|
|
1172
1189
|
# Returns an array of the names of global variables. This includes special
|
|
1173
|
-
# regexp global variables such as
|
|
1174
|
-
# 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.).
|
|
1175
1193
|
#
|
|
1176
1194
|
# global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
|
|
1177
1195
|
#
|
|
@@ -1190,10 +1208,10 @@ module Kernel : BasicObject
|
|
|
1190
1208
|
# the file will be loaded using the relative path from the current directory.
|
|
1191
1209
|
#
|
|
1192
1210
|
# Otherwise, the file will be searched for in the library directories listed in
|
|
1193
|
-
#
|
|
1194
|
-
# load the file relative to that directory. If
|
|
1195
|
-
# the
|
|
1196
|
-
# 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.
|
|
1197
1215
|
#
|
|
1198
1216
|
# If the file doesn't exist when there is an attempt to load it, a LoadError
|
|
1199
1217
|
# will be raised.
|
|
@@ -1218,6 +1236,7 @@ module Kernel : BasicObject
|
|
|
1218
1236
|
# loop do
|
|
1219
1237
|
# print "Input: "
|
|
1220
1238
|
# line = gets
|
|
1239
|
+
# # break if q, Q is entered or EOF signal (Ctrl-D on Unix, Ctrl-Z on windows) is sent
|
|
1221
1240
|
# break if !line or line =~ /^q/i
|
|
1222
1241
|
# # ...
|
|
1223
1242
|
# end
|
|
@@ -1245,9 +1264,6 @@ module Kernel : BasicObject
|
|
|
1245
1264
|
# -->
|
|
1246
1265
|
# Creates an IO object connected to the given file.
|
|
1247
1266
|
#
|
|
1248
|
-
# This method has potential security vulnerabilities if called with untrusted
|
|
1249
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
1250
|
-
#
|
|
1251
1267
|
# With no block given, file stream is returned:
|
|
1252
1268
|
#
|
|
1253
1269
|
# open('t.txt') # => #<File:t.txt>
|
|
@@ -1270,18 +1286,19 @@ module Kernel : BasicObject
|
|
|
1270
1286
|
# rdoc-file=io.c
|
|
1271
1287
|
# - print(*objects) -> nil
|
|
1272
1288
|
# -->
|
|
1273
|
-
# Equivalent to
|
|
1274
|
-
# 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>.
|
|
1275
1291
|
#
|
|
1276
|
-
# Writes the given objects to
|
|
1277
|
-
# 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`.
|
|
1278
1295
|
#
|
|
1279
1296
|
# With argument `objects` given, for each object:
|
|
1280
1297
|
#
|
|
1281
1298
|
# * Converts via its method `to_s` if not a string.
|
|
1282
1299
|
# * Writes to `stdout`.
|
|
1283
1300
|
# * If not the last object, writes the output field separator
|
|
1284
|
-
#
|
|
1301
|
+
# <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code> if it is not `nil`.
|
|
1285
1302
|
#
|
|
1286
1303
|
# With default separators:
|
|
1287
1304
|
#
|
|
@@ -1306,8 +1323,8 @@ module Kernel : BasicObject
|
|
|
1306
1323
|
#
|
|
1307
1324
|
# 0,0.0,0/1,0+0i,zero,zero
|
|
1308
1325
|
#
|
|
1309
|
-
# With no argument given, writes the content of
|
|
1310
|
-
# recent user input):
|
|
1326
|
+
# With no argument given, writes the content of <code>$_</code> (which is
|
|
1327
|
+
# usually the most recent user input):
|
|
1311
1328
|
#
|
|
1312
1329
|
# gets # Sets $_ to the most recent user input.
|
|
1313
1330
|
# print # Prints $_.
|
|
@@ -1324,7 +1341,7 @@ module Kernel : BasicObject
|
|
|
1324
1341
|
# io.write(sprintf(format_string, *objects))
|
|
1325
1342
|
#
|
|
1326
1343
|
# For details on `format_string`, see [Format
|
|
1327
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1344
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1328
1345
|
#
|
|
1329
1346
|
# With the single argument `format_string`, formats `objects` into the string,
|
|
1330
1347
|
# then writes the formatted string to $stdout:
|
|
@@ -1429,7 +1446,7 @@ module Kernel : BasicObject
|
|
|
1429
1446
|
# -->
|
|
1430
1447
|
# prints arguments in pretty form.
|
|
1431
1448
|
#
|
|
1432
|
-
#
|
|
1449
|
+
# <code>#pp</code> returns argument(s).
|
|
1433
1450
|
#
|
|
1434
1451
|
def self?.pp: [T] (T arg0) -> T
|
|
1435
1452
|
| (untyped, untyped, *untyped) -> Array[untyped]
|
|
@@ -1439,19 +1456,20 @@ module Kernel : BasicObject
|
|
|
1439
1456
|
# rdoc-file=random.c
|
|
1440
1457
|
# - rand(max=0) -> number
|
|
1441
1458
|
# -->
|
|
1442
|
-
# If called without an argument, or if
|
|
1443
|
-
# pseudo-random floating point number between 0.0 and 1.0, including
|
|
1444
|
-
# 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.
|
|
1445
1462
|
#
|
|
1446
1463
|
# rand #=> 0.2725926052826416
|
|
1447
1464
|
#
|
|
1448
|
-
# When
|
|
1449
|
-
# 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>.
|
|
1450
1468
|
#
|
|
1451
1469
|
# rand(100) #=> 12
|
|
1452
1470
|
#
|
|
1453
1471
|
# When `max` is a Range, `rand` returns a random number where
|
|
1454
|
-
#
|
|
1472
|
+
# <code>range.member?(number) == true</code>.
|
|
1455
1473
|
#
|
|
1456
1474
|
# Negative or floating point values for `max` are allowed, but may give
|
|
1457
1475
|
# surprising results.
|
|
@@ -1463,7 +1481,9 @@ module Kernel : BasicObject
|
|
|
1463
1481
|
# Kernel.srand may be used to ensure that sequences of random numbers are
|
|
1464
1482
|
# reproducible between different runs of a program.
|
|
1465
1483
|
#
|
|
1466
|
-
#
|
|
1484
|
+
# Related: Random.rand.
|
|
1485
|
+
# rand(100.0) # => 64 (Integer because max.to_i is 100)
|
|
1486
|
+
# Random.rand(100.0) # => 30.315320967824523
|
|
1467
1487
|
#
|
|
1468
1488
|
def self?.rand: (?0) -> Float
|
|
1469
1489
|
| (int arg0) -> Integer
|
|
@@ -1550,7 +1570,7 @@ module Kernel : BasicObject
|
|
|
1550
1570
|
# When RubyGems is required, Kernel#require is replaced with our own which is
|
|
1551
1571
|
# capable of loading gems on demand.
|
|
1552
1572
|
#
|
|
1553
|
-
# When you call
|
|
1573
|
+
# When you call <code>require 'x'</code>, this is what happens:
|
|
1554
1574
|
# * If the file can be loaded from the existing Ruby loadpath, it is.
|
|
1555
1575
|
# * Otherwise, installed gems are searched for a file that matches. If it's
|
|
1556
1576
|
# found in gem 'y', that gem is activated (added to the loadpath).
|
|
@@ -1585,7 +1605,9 @@ module Kernel : BasicObject
|
|
|
1585
1605
|
# IO objects.
|
|
1586
1606
|
#
|
|
1587
1607
|
# Argument `timeout` is a numeric value (such as integer or float) timeout
|
|
1588
|
-
# interval in seconds.
|
|
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.
|
|
1589
1611
|
#
|
|
1590
1612
|
# The method monitors the IO objects given in all three arrays, waiting for some
|
|
1591
1613
|
# to be ready; returns a 3-element array whose elements are:
|
|
@@ -1660,8 +1682,8 @@ module Kernel : BasicObject
|
|
|
1660
1682
|
#
|
|
1661
1683
|
# The writability notified by select(2) doesn't show how many bytes are
|
|
1662
1684
|
# writable. IO#write method blocks until given whole string is written. So,
|
|
1663
|
-
#
|
|
1664
|
-
# 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.
|
|
1665
1687
|
#
|
|
1666
1688
|
# Blocking write (#write) can be emulated using #write_nonblock and IO.select as
|
|
1667
1689
|
# follows: IO::WaitReadable should also be rescued for SSL renegotiation in
|
|
@@ -1729,11 +1751,6 @@ module Kernel : BasicObject
|
|
|
1729
1751
|
def self?.sleep: (?nil) -> bot
|
|
1730
1752
|
| (Time::_Timeout duration) -> Integer
|
|
1731
1753
|
|
|
1732
|
-
%a{deprecated}
|
|
1733
|
-
interface _Divmod
|
|
1734
|
-
def divmod: (Numeric) -> [ Numeric, Numeric ]
|
|
1735
|
-
end
|
|
1736
|
-
|
|
1737
1754
|
# <!--
|
|
1738
1755
|
# rdoc-file=io.c
|
|
1739
1756
|
# - syscall(integer_callno, *arguments) -> integer
|
|
@@ -1773,58 +1790,58 @@ module Kernel : BasicObject
|
|
|
1773
1790
|
# * Each of these tests operates only on the entity at `path0`,
|
|
1774
1791
|
# and returns `true` or `false`;
|
|
1775
1792
|
# for a non-existent entity, returns `false` (does not raise exception):
|
|
1776
|
-
#
|
|
1777
|
-
#
|
|
1778
|
-
# <
|
|
1779
|
-
# <
|
|
1780
|
-
# <
|
|
1781
|
-
# <
|
|
1782
|
-
# <
|
|
1783
|
-
# <
|
|
1784
|
-
# <
|
|
1785
|
-
# <
|
|
1786
|
-
# <
|
|
1787
|
-
# <
|
|
1788
|
-
# <
|
|
1789
|
-
# <
|
|
1790
|
-
# <
|
|
1791
|
-
# <
|
|
1792
|
-
# <
|
|
1793
|
-
# <
|
|
1794
|
-
# <
|
|
1795
|
-
# <
|
|
1796
|
-
# <
|
|
1797
|
-
# <
|
|
1798
|
-
# <
|
|
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.
|
|
1799
1816
|
# * This test operates only on the entity at `path0`,
|
|
1800
|
-
# and returns an integer size or
|
|
1801
|
-
#
|
|
1802
|
-
#
|
|
1803
|
-
# <
|
|
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.
|
|
1804
1821
|
# * Each of these tests operates only on the entity at `path0`,
|
|
1805
1822
|
# and returns a Time object;
|
|
1806
1823
|
# raises an exception if the entity does not exist:
|
|
1807
|
-
#
|
|
1808
|
-
#
|
|
1809
|
-
# <
|
|
1810
|
-
# <
|
|
1811
|
-
# <
|
|
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.
|
|
1812
1829
|
# * Each of these tests operates on the modification time (`mtime`)
|
|
1813
1830
|
# of each of the entities at `path0` and `path1`,
|
|
1814
1831
|
# and returns a `true` or `false`;
|
|
1815
1832
|
# returns `false` if either entity does not exist:
|
|
1816
|
-
#
|
|
1817
|
-
#
|
|
1818
|
-
# <
|
|
1819
|
-
# <
|
|
1820
|
-
# <
|
|
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`.
|
|
1821
1838
|
# * This test operates on the content of each of the entities at `path0` and
|
|
1822
1839
|
# `path1`,
|
|
1823
1840
|
# and returns a `true` or `false`;
|
|
1824
1841
|
# returns `false` if either entity does not exist:
|
|
1825
|
-
#
|
|
1826
|
-
#
|
|
1827
|
-
# <
|
|
1842
|
+
# Character |Test
|
|
1843
|
+
# ----------------|---------------------------------------------
|
|
1844
|
+
# <code>'-'</code>|Whether the entities exist and are identical.
|
|
1828
1845
|
#
|
|
1829
1846
|
def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
|
|
1830
1847
|
|
|
@@ -1843,14 +1860,14 @@ module Kernel : BasicObject
|
|
|
1843
1860
|
# rdoc-file=warning.rb
|
|
1844
1861
|
# - warn(*msgs, uplevel: nil, category: nil) -> nil
|
|
1845
1862
|
# -->
|
|
1846
|
-
# If warnings have been disabled (for example with the
|
|
1847
|
-
# 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
|
|
1848
1865
|
# newline character to the string if the string does not end in a newline, and
|
|
1849
1866
|
# calls Warning.warn with the string.
|
|
1850
1867
|
#
|
|
1851
1868
|
# warn("warning 1", "warning 2")
|
|
1852
1869
|
#
|
|
1853
|
-
#
|
|
1870
|
+
# <em>produces:</em>
|
|
1854
1871
|
#
|
|
1855
1872
|
# warning 1
|
|
1856
1873
|
# warning 2
|
|
@@ -1870,12 +1887,13 @@ module Kernel : BasicObject
|
|
|
1870
1887
|
#
|
|
1871
1888
|
# bar
|
|
1872
1889
|
#
|
|
1873
|
-
#
|
|
1890
|
+
# <em>produces:</em>
|
|
1874
1891
|
#
|
|
1875
1892
|
# baz.rb:6: warning: invalid call to foo
|
|
1876
1893
|
#
|
|
1877
1894
|
# If `category` keyword argument is given, passes the category to
|
|
1878
|
-
#
|
|
1895
|
+
# <code>Warning.warn</code>. The category given must be one of the following
|
|
1896
|
+
# categories:
|
|
1879
1897
|
#
|
|
1880
1898
|
# :deprecated
|
|
1881
1899
|
# : Used for warning for deprecated functionality that may be removed in the
|
|
@@ -1901,7 +1919,7 @@ module Kernel : BasicObject
|
|
|
1901
1919
|
# * Invoking the executable at `exe_path`.
|
|
1902
1920
|
#
|
|
1903
1921
|
# This method has potential security vulnerabilities if called with untrusted
|
|
1904
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
1922
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1905
1923
|
#
|
|
1906
1924
|
# The new process is created using the [exec system
|
|
1907
1925
|
# call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e
|
|
@@ -1920,7 +1938,7 @@ module Kernel : BasicObject
|
|
|
1920
1938
|
# word or special built-in, or if it contains one or more meta characters.
|
|
1921
1939
|
# * `exe_path` otherwise.
|
|
1922
1940
|
#
|
|
1923
|
-
#
|
|
1941
|
+
# <strong>Argument `command_line`</strong>
|
|
1924
1942
|
#
|
|
1925
1943
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
1926
1944
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -1943,7 +1961,7 @@ module Kernel : BasicObject
|
|
|
1943
1961
|
#
|
|
1944
1962
|
# Raises an exception if the new process could not execute.
|
|
1945
1963
|
#
|
|
1946
|
-
#
|
|
1964
|
+
# <strong>Argument `exe_path`</strong>
|
|
1947
1965
|
#
|
|
1948
1966
|
# Argument `exe_path` is one of the following:
|
|
1949
1967
|
#
|
|
@@ -1977,8 +1995,8 @@ module Kernel : BasicObject
|
|
|
1977
1995
|
#
|
|
1978
1996
|
# Raises an exception if the new process could not execute.
|
|
1979
1997
|
#
|
|
1980
|
-
def self?.exec: (String command, *String args, ?unsetenv_others:
|
|
1981
|
-
| (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
|
|
1982
2000
|
|
|
1983
2001
|
type redirect_fd = Integer | :in | :out | :err | IO | String | [ String ] | [ String, string | int ] | [ String, string | int, int ] | [ :child, int ] | :close
|
|
1984
2002
|
|
|
@@ -1993,7 +2011,7 @@ module Kernel : BasicObject
|
|
|
1993
2011
|
# * Invoking the executable at `exe_path`.
|
|
1994
2012
|
#
|
|
1995
2013
|
# This method has potential security vulnerabilities if called with untrusted
|
|
1996
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2014
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1997
2015
|
#
|
|
1998
2016
|
# Returns the process ID (pid) of the new process, without waiting for it to
|
|
1999
2017
|
# complete.
|
|
@@ -2020,7 +2038,7 @@ module Kernel : BasicObject
|
|
|
2020
2038
|
# word or special built-in, or if it contains one or more meta characters.
|
|
2021
2039
|
# * `exe_path` otherwise.
|
|
2022
2040
|
#
|
|
2023
|
-
#
|
|
2041
|
+
# <strong>Argument `command_line`</strong>
|
|
2024
2042
|
#
|
|
2025
2043
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
2026
2044
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -2049,7 +2067,7 @@ module Kernel : BasicObject
|
|
|
2049
2067
|
#
|
|
2050
2068
|
# Raises an exception if the new process could not execute.
|
|
2051
2069
|
#
|
|
2052
|
-
#
|
|
2070
|
+
# <strong>Argument `exe_path`</strong>
|
|
2053
2071
|
#
|
|
2054
2072
|
# Argument `exe_path` is one of the following:
|
|
2055
2073
|
#
|
|
@@ -2082,8 +2100,8 @@ module Kernel : BasicObject
|
|
|
2082
2100
|
#
|
|
2083
2101
|
# Raises an exception if the new process could not execute.
|
|
2084
2102
|
#
|
|
2085
|
-
def self?.spawn: (String command, *String args, ?unsetenv_others:
|
|
2086
|
-
| (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
|
|
2087
2105
|
|
|
2088
2106
|
# <!--
|
|
2089
2107
|
# rdoc-file=process.c
|
|
@@ -2096,7 +2114,7 @@ module Kernel : BasicObject
|
|
|
2096
2114
|
# * Invoking the executable at `exe_path`.
|
|
2097
2115
|
#
|
|
2098
2116
|
# This method has potential security vulnerabilities if called with untrusted
|
|
2099
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2117
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2100
2118
|
#
|
|
2101
2119
|
# Returns:
|
|
2102
2120
|
#
|
|
@@ -2107,7 +2125,7 @@ module Kernel : BasicObject
|
|
|
2107
2125
|
# Raises an exception (instead of returning `false` or `nil`) if keyword
|
|
2108
2126
|
# argument `exception` is set to `true`.
|
|
2109
2127
|
#
|
|
2110
|
-
# Assigns the command's error status to
|
|
2128
|
+
# Assigns the command's error status to <code>$?</code>.
|
|
2111
2129
|
#
|
|
2112
2130
|
# The new process is created using the [system system
|
|
2113
2131
|
# call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/s
|
|
@@ -2126,7 +2144,7 @@ module Kernel : BasicObject
|
|
|
2126
2144
|
# word or special built-in, or if it contains one or more meta characters.
|
|
2127
2145
|
# * `exe_path` otherwise.
|
|
2128
2146
|
#
|
|
2129
|
-
#
|
|
2147
|
+
# <strong>Argument `command_line`</strong>
|
|
2130
2148
|
#
|
|
2131
2149
|
# String argument `command_line` is a command line to be passed to a shell; it
|
|
2132
2150
|
# must begin with a shell reserved word, begin with a special built-in, or
|
|
@@ -2138,7 +2156,7 @@ module Kernel : BasicObject
|
|
|
2138
2156
|
# system('date > /nop/date.tmp') # => false
|
|
2139
2157
|
# system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
|
|
2140
2158
|
#
|
|
2141
|
-
# Assigns the command's error status to
|
|
2159
|
+
# Assigns the command's error status to <code>$?</code>:
|
|
2142
2160
|
#
|
|
2143
2161
|
# system('exit') # => true # Built-in.
|
|
2144
2162
|
# $? # => #<Process::Status: pid 640610 exit 0>
|
|
@@ -2158,7 +2176,7 @@ module Kernel : BasicObject
|
|
|
2158
2176
|
#
|
|
2159
2177
|
# Raises an exception if the new process could not execute.
|
|
2160
2178
|
#
|
|
2161
|
-
#
|
|
2179
|
+
# <strong>Argument `exe_path`</strong>
|
|
2162
2180
|
#
|
|
2163
2181
|
# Argument `exe_path` is one of the following:
|
|
2164
2182
|
#
|
|
@@ -2175,7 +2193,7 @@ module Kernel : BasicObject
|
|
|
2175
2193
|
#
|
|
2176
2194
|
# Mon Aug 28 11:43:10 AM CDT 2023
|
|
2177
2195
|
#
|
|
2178
|
-
# Assigns the command's error status to
|
|
2196
|
+
# Assigns the command's error status to <code>$?</code>:
|
|
2179
2197
|
#
|
|
2180
2198
|
# system('/usr/bin/date') # => true
|
|
2181
2199
|
# $? # => #<Process::Status: pid 645605 exit 0>
|
|
@@ -2200,8 +2218,51 @@ module Kernel : BasicObject
|
|
|
2200
2218
|
#
|
|
2201
2219
|
# Raises an exception if the new process could not execute.
|
|
2202
2220
|
#
|
|
2203
|
-
def self?.system: (String command, *String args, ?unsetenv_others:
|
|
2204
|
-
| (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
|
|
2205
2266
|
|
|
2206
2267
|
# <!--
|
|
2207
2268
|
# rdoc-file=object.c
|
|
@@ -2248,8 +2309,8 @@ module Kernel : BasicObject
|
|
|
2248
2309
|
# -->
|
|
2249
2310
|
# Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
|
|
2250
2311
|
# but not the objects they reference. #clone copies the frozen value state of
|
|
2251
|
-
# *obj*, unless the
|
|
2252
|
-
# 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.
|
|
2253
2314
|
#
|
|
2254
2315
|
# class Klass
|
|
2255
2316
|
# attr_accessor :str
|