rbs 3.10.0.pre.2 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/c-check.yml +1 -1
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +7 -8
- data/CHANGELOG.md +60 -0
- data/core/array.rbs +52 -3
- data/core/comparable.rbs +13 -6
- data/core/complex.rbs +40 -25
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +3 -7
- data/core/enumerable.rbs +1 -1
- data/core/enumerator.rbs +43 -1
- data/core/fiber.rbs +26 -17
- data/core/file.rbs +23 -8
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +223 -32
- data/core/gc.rbs +4 -9
- data/core/hash.rbs +9 -10
- data/core/integer.rbs +104 -63
- data/core/io/buffer.rbs +21 -10
- data/core/io.rbs +8 -8
- data/core/kernel.rbs +12 -8
- data/core/method.rbs +49 -19
- data/core/module.rbs +30 -12
- data/core/numeric.rbs +17 -9
- data/core/object_space.rbs +13 -20
- data/core/pathname.rbs +2 -37
- data/core/proc.rbs +15 -16
- data/core/ractor.rbs +156 -145
- data/core/range.rbs +1 -1
- data/core/rational.rbs +56 -34
- data/core/rbs/unnamed/argf.rbs +1 -1
- data/core/regexp.rbs +3 -3
- data/core/ruby.rbs +53 -0
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +88 -66
- data/core/signal.rbs +24 -14
- data/core/string.rbs +304 -166
- data/core/symbol.rbs +13 -7
- data/core/thread.rbs +12 -13
- data/core/trace_point.rbs +7 -4
- data/lib/rbs/collection/config/lockfile_generator.rb +7 -0
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +1 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +11 -1
- data/stdlib/cgi-escape/0/escape.rbs +33 -15
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/json/0/json.rbs +1 -0
- data/stdlib/objspace/0/objspace.rbs +1 -1
- data/stdlib/openssl/0/openssl.rbs +150 -80
- data/stdlib/pathname/0/pathname.rbs +36 -0
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/stringio/0/stringio.rbs +796 -37
- data/stdlib/strscan/0/string_scanner.rbs +1 -1
- data/stdlib/tempfile/0/tempfile.rbs +2 -2
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/uri/0/generic.rbs +1 -1
- metadata +4 -2
data/core/integer.rbs
CHANGED
|
@@ -146,9 +146,9 @@ class Integer < Numeric
|
|
|
146
146
|
|
|
147
147
|
# <!--
|
|
148
148
|
# rdoc-file=numeric.c
|
|
149
|
-
# - self % other ->
|
|
149
|
+
# - self % other -> real_numeric
|
|
150
150
|
# -->
|
|
151
|
-
# Returns `self` modulo `other` as a real
|
|
151
|
+
# Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
|
|
152
152
|
#
|
|
153
153
|
# For integer `n` and real number `r`, these expressions are equivalent:
|
|
154
154
|
#
|
|
@@ -193,13 +193,13 @@ class Integer < Numeric
|
|
|
193
193
|
|
|
194
194
|
# <!--
|
|
195
195
|
# rdoc-file=numeric.c
|
|
196
|
-
# - self *
|
|
196
|
+
# - self * other -> numeric
|
|
197
197
|
# -->
|
|
198
|
-
#
|
|
198
|
+
# Returns the numeric product of `self` and `other`:
|
|
199
199
|
#
|
|
200
200
|
# 4 * 2 # => 8
|
|
201
|
-
# 4 * -2 # => -8
|
|
202
201
|
# -4 * 2 # => -8
|
|
202
|
+
# 4 * -2 # => -8
|
|
203
203
|
# 4 * 2.0 # => 8.0
|
|
204
204
|
# 4 * Rational(1, 3) # => (4/3)
|
|
205
205
|
# 4 * Complex(2, 0) # => (8+0i)
|
|
@@ -211,17 +211,47 @@ class Integer < Numeric
|
|
|
211
211
|
|
|
212
212
|
# <!--
|
|
213
213
|
# rdoc-file=numeric.c
|
|
214
|
-
# - self **
|
|
214
|
+
# - self ** exponent -> numeric
|
|
215
215
|
# -->
|
|
216
|
-
#
|
|
217
|
-
#
|
|
218
|
-
#
|
|
219
|
-
# 2 **
|
|
220
|
-
#
|
|
221
|
-
#
|
|
222
|
-
# 2 ** 3
|
|
223
|
-
# 2 **
|
|
224
|
-
#
|
|
216
|
+
# Returns `self` raised to the power `exponent`:
|
|
217
|
+
#
|
|
218
|
+
# # Result for non-negative Integer exponent is Integer.
|
|
219
|
+
# 2 ** 0 # => 1
|
|
220
|
+
# 2 ** 1 # => 2
|
|
221
|
+
# 2 ** 2 # => 4
|
|
222
|
+
# 2 ** 3 # => 8
|
|
223
|
+
# -2 ** 3 # => -8
|
|
224
|
+
# # Result for negative Integer exponent is Rational, not Float.
|
|
225
|
+
# 2 ** -3 # => (1/8)
|
|
226
|
+
# -2 ** -3 # => (-1/8)
|
|
227
|
+
#
|
|
228
|
+
# # Result for Float exponent is Float.
|
|
229
|
+
# 2 ** 0.0 # => 1.0
|
|
230
|
+
# 2 ** 1.0 # => 2.0
|
|
231
|
+
# 2 ** 2.0 # => 4.0
|
|
232
|
+
# 2 ** 3.0 # => 8.0
|
|
233
|
+
# -2 ** 3.0 # => -8.0
|
|
234
|
+
# 2 ** -3.0 # => 0.125
|
|
235
|
+
# -2 ** -3.0 # => -0.125
|
|
236
|
+
#
|
|
237
|
+
# # Result for non-negative Complex exponent is Complex with Integer parts.
|
|
238
|
+
# 2 ** Complex(0, 0) # => (1+0i)
|
|
239
|
+
# 2 ** Complex(1, 0) # => (2+0i)
|
|
240
|
+
# 2 ** Complex(2, 0) # => (4+0i)
|
|
241
|
+
# 2 ** Complex(3, 0) # => (8+0i)
|
|
242
|
+
# -2 ** Complex(3, 0) # => (-8+0i)
|
|
243
|
+
# # Result for negative Complex exponent is Complex with Rational parts.
|
|
244
|
+
# 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
|
|
245
|
+
# -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
|
|
246
|
+
#
|
|
247
|
+
# # Result for Rational exponent is Rational.
|
|
248
|
+
# 2 ** Rational(0, 1) # => (1/1)
|
|
249
|
+
# 2 ** Rational(1, 1) # => (2/1)
|
|
250
|
+
# 2 ** Rational(2, 1) # => (4/1)
|
|
251
|
+
# 2 ** Rational(3, 1) # => (8/1)
|
|
252
|
+
# -2 ** Rational(3, 1) # => (-8/1)
|
|
253
|
+
# 2 ** Rational(-3, 1) # => (1/8)
|
|
254
|
+
# -2 ** Rational(-3, 1) # => (-1/8)
|
|
225
255
|
#
|
|
226
256
|
def **: (Integer) -> Numeric
|
|
227
257
|
| (Float) -> Numeric
|
|
@@ -230,16 +260,20 @@ class Integer < Numeric
|
|
|
230
260
|
|
|
231
261
|
# <!--
|
|
232
262
|
# rdoc-file=numeric.c
|
|
233
|
-
# - self +
|
|
263
|
+
# - self + other -> numeric
|
|
234
264
|
# -->
|
|
235
|
-
#
|
|
265
|
+
# Returns the sum of `self` and `other`:
|
|
266
|
+
#
|
|
267
|
+
# 1 + 1 # => 2
|
|
268
|
+
# 1 + -1 # => 0
|
|
269
|
+
# 1 + 0 # => 1
|
|
270
|
+
# 1 + -2 # => -1
|
|
271
|
+
# 1 + Complex(1, 0) # => (2+0i)
|
|
272
|
+
# 1 + Rational(1, 1) # => (2/1)
|
|
273
|
+
#
|
|
274
|
+
# For a computation involving Floats, the result may be inexact (see Float#+):
|
|
236
275
|
#
|
|
237
|
-
#
|
|
238
|
-
# -2 + 2 # => 0
|
|
239
|
-
# -2 + -2 # => -4
|
|
240
|
-
# 2 + 2.0 # => 4.0
|
|
241
|
-
# 2 + Rational(2, 1) # => (4/1)
|
|
242
|
-
# 2 + Complex(2, 0) # => (4+0i)
|
|
276
|
+
# 1 + 3.14 # => 4.140000000000001
|
|
243
277
|
#
|
|
244
278
|
def +: (Integer) -> Integer
|
|
245
279
|
| (Float) -> Float
|
|
@@ -250,9 +284,9 @@ class Integer < Numeric
|
|
|
250
284
|
|
|
251
285
|
# <!--
|
|
252
286
|
# rdoc-file=numeric.c
|
|
253
|
-
# - self -
|
|
287
|
+
# - self - other -> numeric
|
|
254
288
|
# -->
|
|
255
|
-
#
|
|
289
|
+
# Returns the difference of `self` and `other`:
|
|
256
290
|
#
|
|
257
291
|
# 4 - 2 # => 2
|
|
258
292
|
# -4 - 2 # => -6
|
|
@@ -268,28 +302,34 @@ class Integer < Numeric
|
|
|
268
302
|
|
|
269
303
|
# <!--
|
|
270
304
|
# rdoc-file=numeric.rb
|
|
271
|
-
# - -
|
|
305
|
+
# - -self -> integer
|
|
272
306
|
# -->
|
|
273
|
-
# Returns `self`, negated
|
|
307
|
+
# Returns `self`, negated:
|
|
308
|
+
#
|
|
309
|
+
# -1 # => -1
|
|
310
|
+
# -(-1) # => 1
|
|
311
|
+
# -0 # => 0
|
|
274
312
|
#
|
|
275
313
|
def -@: () -> Integer
|
|
276
314
|
|
|
277
315
|
# <!--
|
|
278
316
|
# rdoc-file=numeric.c
|
|
279
|
-
# - self /
|
|
317
|
+
# - self / other -> numeric
|
|
280
318
|
# -->
|
|
281
|
-
#
|
|
319
|
+
# Returns the quotient of `self` and `other`.
|
|
320
|
+
#
|
|
321
|
+
# For integer `other`, truncates the result to an integer:
|
|
282
322
|
#
|
|
283
|
-
#
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
#
|
|
323
|
+
# 4 / 3 # => 1
|
|
324
|
+
# 4 / -3 # => -2
|
|
325
|
+
# -4 / 3 # => -2
|
|
326
|
+
# -4 / -3 # => 1
|
|
287
327
|
#
|
|
288
|
-
#
|
|
328
|
+
# For non-integer `other`, returns a non-integer result:
|
|
289
329
|
#
|
|
290
|
-
#
|
|
291
|
-
#
|
|
292
|
-
#
|
|
330
|
+
# 4 / 3.0 # => 1.3333333333333333
|
|
331
|
+
# 4 / Rational(3, 1) # => (4/3)
|
|
332
|
+
# 4 / Complex(3, 0) # => ((4/3)+0i)
|
|
293
333
|
#
|
|
294
334
|
def /: (Integer) -> Integer
|
|
295
335
|
| (Float) -> Float
|
|
@@ -300,15 +340,14 @@ class Integer < Numeric
|
|
|
300
340
|
# rdoc-file=numeric.c
|
|
301
341
|
# - self < other -> true or false
|
|
302
342
|
# -->
|
|
303
|
-
# Returns
|
|
343
|
+
# Returns whether the value of `self` is less than the value of `other`; `other`
|
|
344
|
+
# must be numeric, but may not be Complex:
|
|
304
345
|
#
|
|
305
|
-
#
|
|
306
|
-
#
|
|
307
|
-
#
|
|
308
|
-
#
|
|
309
|
-
#
|
|
310
|
-
#
|
|
311
|
-
# Raises an exception if the comparison cannot be made.
|
|
346
|
+
# 1 < 0 # => false
|
|
347
|
+
# 1 < 1 # => false
|
|
348
|
+
# 1 < 2 # => true
|
|
349
|
+
# 1 < 0.5 # => false
|
|
350
|
+
# 1 < Rational(1, 2) # => false
|
|
312
351
|
#
|
|
313
352
|
def <: (Numeric) -> bool
|
|
314
353
|
|
|
@@ -331,44 +370,46 @@ class Integer < Numeric
|
|
|
331
370
|
|
|
332
371
|
# <!--
|
|
333
372
|
# rdoc-file=numeric.c
|
|
334
|
-
# - self <=
|
|
373
|
+
# - self <= other -> true or false
|
|
335
374
|
# -->
|
|
336
|
-
# Returns
|
|
337
|
-
# `other
|
|
375
|
+
# Returns whether the value of `self` is less than or equal to the value of
|
|
376
|
+
# `other`; `other` must be numeric, but may not be Complex:
|
|
338
377
|
#
|
|
339
|
-
#
|
|
340
|
-
#
|
|
341
|
-
#
|
|
342
|
-
#
|
|
343
|
-
#
|
|
378
|
+
# 1 <= 0 # => false
|
|
379
|
+
# 1 <= 1 # => true
|
|
380
|
+
# 1 <= 2 # => true
|
|
381
|
+
# 1 <= 0.5 # => false
|
|
382
|
+
# 1 <= Rational(1, 2) # => false
|
|
344
383
|
#
|
|
345
|
-
#
|
|
384
|
+
# Raises an exception if the comparison cannot be made.
|
|
346
385
|
#
|
|
347
386
|
def <=: (Numeric) -> bool
|
|
348
387
|
|
|
349
388
|
# <!--
|
|
350
389
|
# rdoc-file=numeric.c
|
|
351
|
-
# - self <=> other
|
|
390
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
352
391
|
# -->
|
|
392
|
+
# Compares `self` and `other`.
|
|
393
|
+
#
|
|
353
394
|
# Returns:
|
|
354
395
|
#
|
|
355
|
-
# *
|
|
356
|
-
# * 0
|
|
357
|
-
# * 1
|
|
396
|
+
# * `-1`, if `self` is less than `other`.
|
|
397
|
+
# * `0`, if `self` is equal to `other`.
|
|
398
|
+
# * `1`, if `self` is greater then `other`.
|
|
358
399
|
# * `nil`, if `self` and `other` are incomparable.
|
|
359
400
|
#
|
|
360
401
|
# Examples:
|
|
361
402
|
#
|
|
362
403
|
# 1 <=> 2 # => -1
|
|
363
404
|
# 1 <=> 1 # => 0
|
|
364
|
-
# 1 <=> 0 # => 1
|
|
365
|
-
# 1 <=> 'foo' # => nil
|
|
366
|
-
#
|
|
367
405
|
# 1 <=> 1.0 # => 0
|
|
368
406
|
# 1 <=> Rational(1, 1) # => 0
|
|
369
407
|
# 1 <=> Complex(1, 0) # => 0
|
|
408
|
+
# 1 <=> 0 # => 1
|
|
409
|
+
# 1 <=> 'foo' # => nil
|
|
370
410
|
#
|
|
371
|
-
#
|
|
411
|
+
# Class Integer includes module Comparable, each of whose methods uses
|
|
412
|
+
# Integer#<=> for comparison.
|
|
372
413
|
#
|
|
373
414
|
def <=>: (Integer | Rational) -> Integer
|
|
374
415
|
| (untyped) -> Integer?
|
|
@@ -955,7 +996,7 @@ class Integer < Numeric
|
|
|
955
996
|
def magnitude: () -> Integer
|
|
956
997
|
|
|
957
998
|
# <!-- rdoc-file=numeric.c -->
|
|
958
|
-
# Returns `self` modulo `other` as a real
|
|
999
|
+
# Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
|
|
959
1000
|
#
|
|
960
1001
|
# For integer `n` and real number `r`, these expressions are equivalent:
|
|
961
1002
|
#
|
data/core/io/buffer.rbs
CHANGED
|
@@ -64,9 +64,9 @@ class IO
|
|
|
64
64
|
#
|
|
65
65
|
# File.write('test.txt', 'test data')
|
|
66
66
|
# # => 9
|
|
67
|
-
# buffer = IO::Buffer.map(File.open('test.txt'))
|
|
67
|
+
# buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
|
|
68
68
|
# # =>
|
|
69
|
-
# # #<IO::Buffer 0x00007f3f0768c000+9 MAPPED
|
|
69
|
+
# # #<IO::Buffer 0x00007f3f0768c000+9 EXTERNAL MAPPED FILE SHARED READONLY>
|
|
70
70
|
# # ...
|
|
71
71
|
# buffer.get_string(5, 2) # read 2 bytes, starting from offset 5
|
|
72
72
|
# # => "da"
|
|
@@ -113,7 +113,7 @@ class IO
|
|
|
113
113
|
# buffer.get_string(0, 1)
|
|
114
114
|
# # => "t"
|
|
115
115
|
# string
|
|
116
|
-
# # => "
|
|
116
|
+
# # => "test"
|
|
117
117
|
#
|
|
118
118
|
# buffer.resize(100)
|
|
119
119
|
# # in `resize': Cannot resize external buffer! (IO::Buffer::AccessError)
|
|
@@ -131,18 +131,25 @@ class IO
|
|
|
131
131
|
# - IO::Buffer.map(file, [size, [offset, [flags]]]) -> io_buffer
|
|
132
132
|
# -->
|
|
133
133
|
# Create an IO::Buffer for reading from `file` by memory-mapping the file.
|
|
134
|
-
# `
|
|
134
|
+
# `file` should be a `File` instance, opened for reading or reading and writing.
|
|
135
|
+
#
|
|
136
|
+
# Optional `size` and `offset` of mapping can be specified. Trying to map an
|
|
137
|
+
# empty file or specify `size` of 0 will raise an error. Valid values for
|
|
138
|
+
# `offset` are system-dependent.
|
|
135
139
|
#
|
|
136
|
-
#
|
|
140
|
+
# By default, the buffer is writable and expects the file to be writable. It is
|
|
141
|
+
# also shared, so several processes can use the same mapping.
|
|
137
142
|
#
|
|
138
|
-
#
|
|
139
|
-
#
|
|
140
|
-
# `flags`
|
|
143
|
+
# You can pass IO::Buffer::READONLY in `flags` argument to make a read-only
|
|
144
|
+
# buffer; this allows to work with files opened only for reading. Specifying
|
|
145
|
+
# IO::Buffer::PRIVATE in `flags` creates a private mapping, which will not
|
|
146
|
+
# impact other processes or the underlying file. It also allows updating a
|
|
147
|
+
# buffer created from a read-only file.
|
|
141
148
|
#
|
|
142
149
|
# File.write('test.txt', 'test')
|
|
143
150
|
#
|
|
144
151
|
# buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
|
|
145
|
-
# # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY>
|
|
152
|
+
# # => #<IO::Buffer 0x00000001014a0000+4 EXTERNAL MAPPED FILE SHARED READONLY>
|
|
146
153
|
#
|
|
147
154
|
# buffer.readonly? # => true
|
|
148
155
|
#
|
|
@@ -150,7 +157,7 @@ class IO
|
|
|
150
157
|
# # => "test"
|
|
151
158
|
#
|
|
152
159
|
# buffer.set_string('b', 0)
|
|
153
|
-
# #
|
|
160
|
+
# # 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
|
|
154
161
|
#
|
|
155
162
|
# # create read/write mapping: length 4 bytes, offset 0, flags 0
|
|
156
163
|
# buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0)
|
|
@@ -382,6 +389,10 @@ class IO
|
|
|
382
389
|
# * `:U64`: unsigned integer, 8 bytes, big-endian
|
|
383
390
|
# * `:s64`: signed integer, 8 bytes, little-endian
|
|
384
391
|
# * `:S64`: signed integer, 8 bytes, big-endian
|
|
392
|
+
# * `:u128`: unsigned integer, 16 bytes, little-endian
|
|
393
|
+
# * `:U128`: unsigned integer, 16 bytes, big-endian
|
|
394
|
+
# * `:s128`: signed integer, 16 bytes, little-endian
|
|
395
|
+
# * `:S128`: signed integer, 16 bytes, big-endian
|
|
385
396
|
# * `:f32`: float, 4 bytes, little-endian
|
|
386
397
|
# * `:F32`: float, 4 bytes, big-endian
|
|
387
398
|
# * `:f64`: double, 8 bytes, little-endian
|
data/core/io.rbs
CHANGED
|
@@ -1373,7 +1373,7 @@ class IO < Object
|
|
|
1373
1373
|
# Formats and writes `objects` to the stream.
|
|
1374
1374
|
#
|
|
1375
1375
|
# For details on `format_string`, see [Format
|
|
1376
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1376
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1377
1377
|
#
|
|
1378
1378
|
def printf: (String format_string, *untyped objects) -> nil
|
|
1379
1379
|
|
|
@@ -2276,7 +2276,7 @@ class IO < Object
|
|
|
2276
2276
|
#
|
|
2277
2277
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2278
2278
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2279
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2279
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2280
2280
|
#
|
|
2281
2281
|
def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
|
|
2282
2282
|
|
|
@@ -2289,7 +2289,7 @@ class IO < Object
|
|
|
2289
2289
|
#
|
|
2290
2290
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2291
2291
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2292
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2292
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2293
2293
|
#
|
|
2294
2294
|
def self.binwrite: (String name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
|
|
2295
2295
|
|
|
@@ -2354,7 +2354,7 @@ class IO < Object
|
|
|
2354
2354
|
# connected to a new stream `io`.
|
|
2355
2355
|
#
|
|
2356
2356
|
# This method has potential security vulnerabilities if called with untrusted
|
|
2357
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2357
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2358
2358
|
#
|
|
2359
2359
|
# If no block is given, returns the new stream, which depending on given `mode`
|
|
2360
2360
|
# may be open for reading, writing, or both. The stream should be explicitly
|
|
@@ -2529,7 +2529,7 @@ class IO < Object
|
|
|
2529
2529
|
#
|
|
2530
2530
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2531
2531
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2532
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2532
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2533
2533
|
#
|
|
2534
2534
|
# The first argument must be a string that is the path to a file.
|
|
2535
2535
|
#
|
|
@@ -2686,7 +2686,7 @@ class IO < Object
|
|
|
2686
2686
|
#
|
|
2687
2687
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2688
2688
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2689
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2689
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2690
2690
|
#
|
|
2691
2691
|
# The first argument must be a string that is the path to a file.
|
|
2692
2692
|
#
|
|
@@ -2729,7 +2729,7 @@ class IO < Object
|
|
|
2729
2729
|
#
|
|
2730
2730
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2731
2731
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2732
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2732
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2733
2733
|
#
|
|
2734
2734
|
# The first argument must be a string that is the path to a file.
|
|
2735
2735
|
#
|
|
@@ -2954,7 +2954,7 @@ class IO < Object
|
|
|
2954
2954
|
#
|
|
2955
2955
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2956
2956
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2957
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2957
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2958
2958
|
#
|
|
2959
2959
|
# The first argument must be a string that is the path to a file.
|
|
2960
2960
|
#
|
data/core/kernel.rbs
CHANGED
|
@@ -718,7 +718,7 @@ module Kernel : BasicObject
|
|
|
718
718
|
# variable `$?` to the process status.
|
|
719
719
|
#
|
|
720
720
|
# This method has potential security vulnerabilities if called with untrusted
|
|
721
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
721
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
722
722
|
#
|
|
723
723
|
# Examples:
|
|
724
724
|
#
|
|
@@ -1004,6 +1004,8 @@ module Kernel : BasicObject
|
|
|
1004
1004
|
# With argument `exception` not given, argument `message` and keyword argument
|
|
1005
1005
|
# `cause` may be given, but argument `backtrace` may not be given.
|
|
1006
1006
|
#
|
|
1007
|
+
# `cause` can not be given as an only argument.
|
|
1008
|
+
#
|
|
1007
1009
|
def self?.fail: () -> bot
|
|
1008
1010
|
| (string message, ?cause: Exception?) -> bot
|
|
1009
1011
|
| (_Exception exception, ?_ToS? message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot
|
|
@@ -1110,6 +1112,8 @@ module Kernel : BasicObject
|
|
|
1110
1112
|
# With argument `exception` not given, argument `message` and keyword argument
|
|
1111
1113
|
# `cause` may be given, but argument `backtrace` may not be given.
|
|
1112
1114
|
#
|
|
1115
|
+
# `cause` can not be given as an only argument.
|
|
1116
|
+
#
|
|
1113
1117
|
alias raise fail
|
|
1114
1118
|
|
|
1115
1119
|
alias self.raise self.fail
|
|
@@ -1118,7 +1122,7 @@ module Kernel : BasicObject
|
|
|
1118
1122
|
# Returns the string resulting from formatting `objects` into `format_string`.
|
|
1119
1123
|
#
|
|
1120
1124
|
# For details on `format_string`, see [Format
|
|
1121
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1125
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1122
1126
|
#
|
|
1123
1127
|
def self?.format: (String format, *untyped args) -> String
|
|
1124
1128
|
|
|
@@ -1129,7 +1133,7 @@ module Kernel : BasicObject
|
|
|
1129
1133
|
# Returns the string resulting from formatting `objects` into `format_string`.
|
|
1130
1134
|
#
|
|
1131
1135
|
# For details on `format_string`, see [Format
|
|
1132
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1136
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1133
1137
|
#
|
|
1134
1138
|
alias sprintf format
|
|
1135
1139
|
|
|
@@ -1249,7 +1253,7 @@ module Kernel : BasicObject
|
|
|
1249
1253
|
# Creates an IO object connected to the given file.
|
|
1250
1254
|
#
|
|
1251
1255
|
# This method has potential security vulnerabilities if called with untrusted
|
|
1252
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
1256
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1253
1257
|
#
|
|
1254
1258
|
# With no block given, file stream is returned:
|
|
1255
1259
|
#
|
|
@@ -1327,7 +1331,7 @@ module Kernel : BasicObject
|
|
|
1327
1331
|
# io.write(sprintf(format_string, *objects))
|
|
1328
1332
|
#
|
|
1329
1333
|
# For details on `format_string`, see [Format
|
|
1330
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1334
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1331
1335
|
#
|
|
1332
1336
|
# With the single argument `format_string`, formats `objects` into the string,
|
|
1333
1337
|
# then writes the formatted string to $stdout:
|
|
@@ -1907,7 +1911,7 @@ module Kernel : BasicObject
|
|
|
1907
1911
|
# * Invoking the executable at `exe_path`.
|
|
1908
1912
|
#
|
|
1909
1913
|
# This method has potential security vulnerabilities if called with untrusted
|
|
1910
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
1914
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1911
1915
|
#
|
|
1912
1916
|
# The new process is created using the [exec system
|
|
1913
1917
|
# call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e
|
|
@@ -1999,7 +2003,7 @@ module Kernel : BasicObject
|
|
|
1999
2003
|
# * Invoking the executable at `exe_path`.
|
|
2000
2004
|
#
|
|
2001
2005
|
# This method has potential security vulnerabilities if called with untrusted
|
|
2002
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2006
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2003
2007
|
#
|
|
2004
2008
|
# Returns the process ID (pid) of the new process, without waiting for it to
|
|
2005
2009
|
# complete.
|
|
@@ -2102,7 +2106,7 @@ module Kernel : BasicObject
|
|
|
2102
2106
|
# * Invoking the executable at `exe_path`.
|
|
2103
2107
|
#
|
|
2104
2108
|
# This method has potential security vulnerabilities if called with untrusted
|
|
2105
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2109
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2106
2110
|
#
|
|
2107
2111
|
# Returns:
|
|
2108
2112
|
#
|
data/core/method.rbs
CHANGED
|
@@ -126,7 +126,9 @@ class Method
|
|
|
126
126
|
|
|
127
127
|
# <!--
|
|
128
128
|
# rdoc-file=proc.c
|
|
129
|
-
# - meth.call(args, ...)
|
|
129
|
+
# - meth.call(args, ...) -> obj
|
|
130
|
+
# - meth[args, ...] -> obj
|
|
131
|
+
# - method === obj -> result_of_method
|
|
130
132
|
# -->
|
|
131
133
|
# Invokes the *meth* with the specified arguments, returning the method's return
|
|
132
134
|
# value.
|
|
@@ -135,23 +137,32 @@ class Method
|
|
|
135
137
|
# m.call(3) #=> 15
|
|
136
138
|
# m.call(20) #=> 32
|
|
137
139
|
#
|
|
140
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
141
|
+
# a case statement.
|
|
142
|
+
#
|
|
143
|
+
# require 'prime'
|
|
144
|
+
#
|
|
145
|
+
# case 1373
|
|
146
|
+
# when Prime.method(:prime?)
|
|
147
|
+
# # ...
|
|
148
|
+
# end
|
|
149
|
+
#
|
|
138
150
|
def call: (?) -> untyped
|
|
139
151
|
|
|
140
152
|
# <!--
|
|
141
153
|
# rdoc-file=proc.c
|
|
142
|
-
# -
|
|
154
|
+
# - self << g -> a_proc
|
|
143
155
|
# -->
|
|
144
|
-
# Returns a proc that is the composition of
|
|
145
|
-
# returned proc takes a variable number of arguments, calls *g* with them then
|
|
146
|
-
# calls this method with the result.
|
|
156
|
+
# Returns a proc that is the composition of the given `g` and this method.
|
|
147
157
|
#
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
158
|
+
# The returned proc takes a variable number of arguments. It first calls `g`
|
|
159
|
+
# with the arguments, then calls `self` with the return value of `g`.
|
|
160
|
+
#
|
|
161
|
+
# def f(ary) = ary << 'in f'
|
|
151
162
|
#
|
|
152
163
|
# f = self.method(:f)
|
|
153
|
-
# g = proc {|
|
|
154
|
-
#
|
|
164
|
+
# g = proc { |ary| ary << 'in proc' }
|
|
165
|
+
# (f << g).call([]) # => ["in proc", "in f"]
|
|
155
166
|
#
|
|
156
167
|
def <<: (Proc::_Callable g) -> Proc
|
|
157
168
|
|
|
@@ -163,23 +174,32 @@ class Method
|
|
|
163
174
|
# m.call(3) #=> 15
|
|
164
175
|
# m.call(20) #=> 32
|
|
165
176
|
#
|
|
177
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
178
|
+
# a case statement.
|
|
179
|
+
#
|
|
180
|
+
# require 'prime'
|
|
181
|
+
#
|
|
182
|
+
# case 1373
|
|
183
|
+
# when Prime.method(:prime?)
|
|
184
|
+
# # ...
|
|
185
|
+
# end
|
|
186
|
+
#
|
|
166
187
|
alias === call
|
|
167
188
|
|
|
168
189
|
# <!--
|
|
169
190
|
# rdoc-file=proc.c
|
|
170
|
-
# -
|
|
191
|
+
# - self >> g -> a_proc
|
|
171
192
|
# -->
|
|
172
|
-
# Returns a proc that is the composition of this method and the given
|
|
173
|
-
# returned proc takes a variable number of arguments, calls this method with
|
|
174
|
-
# them then calls *g* with the result.
|
|
193
|
+
# Returns a proc that is the composition of this method and the given `g`.
|
|
175
194
|
#
|
|
176
|
-
#
|
|
177
|
-
#
|
|
178
|
-
#
|
|
195
|
+
# The returned proc takes a variable number of arguments. It first calls `self`
|
|
196
|
+
# with the arguments, then calls `g` with the return value of `self`.
|
|
197
|
+
#
|
|
198
|
+
# def f(ary) = ary << 'in f'
|
|
179
199
|
#
|
|
180
200
|
# f = self.method(:f)
|
|
181
|
-
# g = proc {|
|
|
182
|
-
#
|
|
201
|
+
# g = proc { |ary| ary << 'in proc' }
|
|
202
|
+
# (f >> g).call([]) # => ["in f", "in proc"]
|
|
183
203
|
#
|
|
184
204
|
def >>: (Proc::_Callable g) -> Proc
|
|
185
205
|
|
|
@@ -191,6 +211,16 @@ class Method
|
|
|
191
211
|
# m.call(3) #=> 15
|
|
192
212
|
# m.call(20) #=> 32
|
|
193
213
|
#
|
|
214
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
215
|
+
# a case statement.
|
|
216
|
+
#
|
|
217
|
+
# require 'prime'
|
|
218
|
+
#
|
|
219
|
+
# case 1373
|
|
220
|
+
# when Prime.method(:prime?)
|
|
221
|
+
# # ...
|
|
222
|
+
# end
|
|
223
|
+
#
|
|
194
224
|
alias [] call
|
|
195
225
|
|
|
196
226
|
# <!--
|
data/core/module.rbs
CHANGED
|
@@ -114,12 +114,15 @@ class Module < Object
|
|
|
114
114
|
|
|
115
115
|
# <!--
|
|
116
116
|
# rdoc-file=object.c
|
|
117
|
-
# -
|
|
117
|
+
# - self < other -> true, false, or nil
|
|
118
118
|
# -->
|
|
119
|
-
# Returns
|
|
120
|
-
#
|
|
121
|
-
#
|
|
122
|
-
#
|
|
119
|
+
# Returns whether `self` is a subclass of `other`, or `nil` if there is no
|
|
120
|
+
# relationship between the two:
|
|
121
|
+
#
|
|
122
|
+
# Float < Numeric # => true
|
|
123
|
+
# Numeric < Float # => false
|
|
124
|
+
# Float < Float # => false
|
|
125
|
+
# Float < Hash # => nil
|
|
123
126
|
#
|
|
124
127
|
def <: (Module other) -> bool?
|
|
125
128
|
|
|
@@ -135,14 +138,29 @@ class Module < Object
|
|
|
135
138
|
|
|
136
139
|
# <!--
|
|
137
140
|
# rdoc-file=object.c
|
|
138
|
-
# -
|
|
141
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
139
142
|
# -->
|
|
140
|
-
#
|
|
141
|
-
#
|
|
142
|
-
#
|
|
143
|
+
# Compares `self` and `other`.
|
|
144
|
+
#
|
|
145
|
+
# Returns:
|
|
146
|
+
#
|
|
147
|
+
# * `-1`, if `self` includes `other`, if or `self` is a subclass of `other`.
|
|
148
|
+
# * `0`, if `self` and `other` are the same.
|
|
149
|
+
# * `1`, if `other` includes `self`, or if `other` is a subclass of `self`.
|
|
150
|
+
# * `nil`, if none of the above is true.
|
|
151
|
+
#
|
|
152
|
+
# Examples:
|
|
143
153
|
#
|
|
144
|
-
#
|
|
145
|
-
#
|
|
154
|
+
# # Class Array includes module Enumerable.
|
|
155
|
+
# Array <=> Enumerable # => -1
|
|
156
|
+
# Enumerable <=> Enumerable # => 0
|
|
157
|
+
# Enumerable <=> Array # => 1
|
|
158
|
+
# # Class File is a subclass of class IO.
|
|
159
|
+
# File <=> IO # => -1
|
|
160
|
+
# File <=> File # => 0
|
|
161
|
+
# IO <=> File # => 1
|
|
162
|
+
# # Class File has no relationship to class String.
|
|
163
|
+
# File <=> String # => nil
|
|
146
164
|
#
|
|
147
165
|
def <=>: (untyped other) -> Integer?
|
|
148
166
|
|
|
@@ -1638,7 +1656,7 @@ class Module < Object
|
|
|
1638
1656
|
# m.name #=> nil
|
|
1639
1657
|
#
|
|
1640
1658
|
# c = Class.new
|
|
1641
|
-
# c.set_temporary_name("MyClass(with description)")
|
|
1659
|
+
# c.set_temporary_name("MyClass(with description)") # => MyClass(with description)
|
|
1642
1660
|
#
|
|
1643
1661
|
# c.new # => #<MyClass(with description):0x0....>
|
|
1644
1662
|
#
|