rbs 3.9.5 → 3.10.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/.clang-format +74 -0
- data/.clangd +2 -0
- data/.github/workflows/c-check.yml +54 -0
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +34 -19
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/.gitignore +4 -0
- data/CHANGELOG.md +49 -0
- data/README.md +38 -1
- data/Rakefile +152 -23
- data/config.yml +190 -62
- data/core/array.rbs +100 -46
- data/core/complex.rbs +32 -21
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +6 -9
- data/core/enumerable.rbs +90 -3
- data/core/enumerator.rbs +18 -1
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +5 -4
- data/core/file.rbs +27 -12
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +209 -22
- data/core/gc.rbs +417 -281
- data/core/hash.rbs +1024 -727
- data/core/integer.rbs +78 -38
- data/core/io/buffer.rbs +18 -7
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +14 -12
- data/core/kernel.rbs +57 -51
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +14 -6
- data/core/module.rbs +88 -17
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +16 -16
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +21 -15
- data/{stdlib/pathname/0 → core}/pathname.rbs +255 -355
- data/core/proc.rbs +15 -8
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +278 -437
- data/core/range.rbs +7 -8
- data/core/rational.rbs +37 -24
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -2
- data/core/regexp.rbs +25 -20
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +488 -359
- data/core/string.rbs +3145 -1231
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +4 -4
- data/core/thread.rbs +92 -29
- data/core/time.rbs +35 -9
- data/core/trace_point.rbs +7 -4
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1016 -0
- data/ext/rbs_extension/ast_translation.h +37 -0
- data/ext/rbs_extension/class_constants.c +155 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
- data/ext/rbs_extension/compat.h +10 -0
- data/ext/rbs_extension/extconf.rb +25 -1
- data/ext/rbs_extension/legacy_location.c +317 -0
- data/ext/rbs_extension/legacy_location.h +45 -0
- data/ext/rbs_extension/main.c +357 -14
- data/ext/rbs_extension/rbs_extension.h +6 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +24 -0
- data/include/rbs/ast.h +687 -0
- data/include/rbs/defines.h +86 -0
- data/include/rbs/lexer.h +199 -0
- data/include/rbs/location.h +59 -0
- data/include/rbs/parser.h +135 -0
- data/include/rbs/string.h +47 -0
- data/include/rbs/util/rbs_allocator.h +59 -0
- data/include/rbs/util/rbs_assert.h +20 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +6 -67
- data/include/rbs/util/rbs_encoding.h +282 -0
- data/include/rbs/util/rbs_unescape.h +24 -0
- data/include/rbs.h +1 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/cli/validate.rb +2 -2
- data/lib/rbs/cli.rb +1 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +1 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
- data/lib/rbs/environment.rb +64 -59
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/errors.rb +1 -1
- data/lib/rbs/parser_aux.rb +5 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +124 -38
- data/lib/rbs/test/type_check.rb +14 -0
- data/lib/rbs/types.rb +3 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +3 -3
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/environment.rbs +57 -6
- data/sig/manifest.yaml +0 -1
- data/sig/parser.rbs +20 -0
- data/sig/resolver/type_name_resolver.rbs +38 -7
- data/sig/types.rbs +4 -1
- data/src/ast.c +1256 -0
- data/src/lexer.c +2956 -0
- data/src/lexer.re +147 -0
- data/src/lexstate.c +205 -0
- data/src/location.c +71 -0
- data/src/parser.c +3507 -0
- data/src/string.c +41 -0
- data/src/util/rbs_allocator.c +152 -0
- data/src/util/rbs_assert.c +19 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +18 -88
- data/src/util/rbs_encoding.c +21308 -0
- data/src/util/rbs_unescape.c +167 -0
- 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 +2 -396
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +153 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +18 -13
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +68 -48
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +9 -4
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/openssl/0/openssl.rbs +331 -228
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/rdoc/0/code_object.rbs +2 -2
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/rdoc.rbs +7 -5
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +5 -2
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +1176 -85
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +11 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +17 -16
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +43 -18
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.h +0 -179
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/lexstate.c +0 -175
- data/ext/rbs_extension/location.c +0 -325
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/constants.c +0 -153
- data/src/ruby_objs.c +0 -799
data/core/math.rbs
CHANGED
|
@@ -410,6 +410,27 @@ module Math
|
|
|
410
410
|
#
|
|
411
411
|
def self.exp: (double x) -> Float
|
|
412
412
|
|
|
413
|
+
# <!--
|
|
414
|
+
# rdoc-file=math.c
|
|
415
|
+
# - Math.expm1(x) -> float
|
|
416
|
+
# -->
|
|
417
|
+
# Returns "exp(x) - 1", `e` raised to the `x` power, minus 1.
|
|
418
|
+
#
|
|
419
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
420
|
+
# * Range: `[-1.0, INFINITY]`.
|
|
421
|
+
#
|
|
422
|
+
# Examples:
|
|
423
|
+
#
|
|
424
|
+
# expm1(-INFINITY) # => 0.0
|
|
425
|
+
# expm1(-1.0) # => -0.6321205588285577 # 1.0/E - 1
|
|
426
|
+
# expm1(0.0) # => 0.0
|
|
427
|
+
# expm1(0.5) # => 0.6487212707001282 # sqrt(E) - 1
|
|
428
|
+
# expm1(1.0) # => 1.718281828459045 # E - 1
|
|
429
|
+
# expm1(2.0) # => 6.38905609893065 # E**2 - 1
|
|
430
|
+
# expm1(INFINITY) # => Infinity
|
|
431
|
+
#
|
|
432
|
+
def self.expm1: (double x) -> Float
|
|
433
|
+
|
|
413
434
|
# <!--
|
|
414
435
|
# rdoc-file=math.c
|
|
415
436
|
# - Math.frexp(x) -> [fraction, exponent]
|
|
@@ -525,9 +546,8 @@ module Math
|
|
|
525
546
|
#
|
|
526
547
|
# [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
|
|
527
548
|
#
|
|
528
|
-
# See [
|
|
529
|
-
# function](https://en.wikipedia.org/wiki/Gamma_function#
|
|
530
|
-
# .
|
|
549
|
+
# See [log gamma
|
|
550
|
+
# function](https://en.wikipedia.org/wiki/Gamma_function#Log-gamma_function).
|
|
531
551
|
#
|
|
532
552
|
# * Domain: `(-INFINITY, INFINITY]`.
|
|
533
553
|
# * Range of first element: `(-INFINITY, INFINITY]`.
|
|
@@ -603,6 +623,25 @@ module Math
|
|
|
603
623
|
#
|
|
604
624
|
def self.log10: (double x) -> Float
|
|
605
625
|
|
|
626
|
+
# <!--
|
|
627
|
+
# rdoc-file=math.c
|
|
628
|
+
# - Math.log1p(x) -> float
|
|
629
|
+
# -->
|
|
630
|
+
# Returns "log(x + 1)", the base E
|
|
631
|
+
# [logarithm](https://en.wikipedia.org/wiki/Logarithm) of (`x` + 1).
|
|
632
|
+
#
|
|
633
|
+
# * Domain: `[-1, INFINITY]`.
|
|
634
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
635
|
+
#
|
|
636
|
+
# Examples:
|
|
637
|
+
#
|
|
638
|
+
# log1p(-1.0) # => -Infinity
|
|
639
|
+
# log1p(0.0) # => 0.0
|
|
640
|
+
# log1p(E - 1) # => 1.0
|
|
641
|
+
# log1p(INFINITY) # => Infinity
|
|
642
|
+
#
|
|
643
|
+
def self.log1p: (double x) -> Float
|
|
644
|
+
|
|
606
645
|
# <!--
|
|
607
646
|
# rdoc-file=math.c
|
|
608
647
|
# - Math.log2(x) -> float
|
data/core/method.rbs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# <!-- rdoc-file=proc.c -->
|
|
2
|
-
# Method objects are created by Object#method, and are associated with a
|
|
2
|
+
# `Method` objects are created by Object#method, and are associated with a
|
|
3
3
|
# particular object (not just with a class). They may be used to invoke the
|
|
4
4
|
# method within the object, and as a block associated with an iterator. They
|
|
5
5
|
# may also be unbound from one object (creating an UnboundMethod) and bound to
|
|
@@ -359,10 +359,18 @@ class Method
|
|
|
359
359
|
|
|
360
360
|
# <!--
|
|
361
361
|
# rdoc-file=proc.c
|
|
362
|
-
# - meth.source_location -> [String, Integer]
|
|
362
|
+
# - meth.source_location -> [String, Integer, Integer, Integer, Integer]
|
|
363
363
|
# -->
|
|
364
|
-
# Returns the
|
|
365
|
-
#
|
|
364
|
+
# Returns the location where the method was defined. The returned Array
|
|
365
|
+
# contains:
|
|
366
|
+
# (1) the Ruby source filename
|
|
367
|
+
# (2) the line number where the definition starts
|
|
368
|
+
# (3) the column number where the definition starts
|
|
369
|
+
# (4) the line number where the definition ends
|
|
370
|
+
# (5) the column number where the definitions ends
|
|
371
|
+
#
|
|
372
|
+
# This method will return `nil` if the method was not defined in Ruby (i.e.
|
|
373
|
+
# native).
|
|
366
374
|
#
|
|
367
375
|
def source_location: () -> [String, Integer]?
|
|
368
376
|
|
|
@@ -370,8 +378,8 @@ class Method
|
|
|
370
378
|
# rdoc-file=proc.c
|
|
371
379
|
# - meth.super_method -> method
|
|
372
380
|
# -->
|
|
373
|
-
# Returns a Method of superclass which would be called when super is used or
|
|
374
|
-
# if there is no method on superclass.
|
|
381
|
+
# Returns a `Method` of superclass which would be called when super is used or
|
|
382
|
+
# nil if there is no method on superclass.
|
|
375
383
|
#
|
|
376
384
|
def super_method: () -> Method?
|
|
377
385
|
|
data/core/module.rbs
CHANGED
|
@@ -135,14 +135,25 @@ class Module < Object
|
|
|
135
135
|
|
|
136
136
|
# <!--
|
|
137
137
|
# rdoc-file=object.c
|
|
138
|
-
# -
|
|
138
|
+
# - self <=> object -> -1, 0, +1, or nil
|
|
139
139
|
# -->
|
|
140
|
-
#
|
|
141
|
-
# `other_module`, they are the same, or if `module` is included by
|
|
142
|
-
# `other_module`.
|
|
140
|
+
# Returns:
|
|
143
141
|
#
|
|
144
|
-
#
|
|
145
|
-
# `
|
|
142
|
+
# * `-1`, if `self` includes `object`, if or `self` is a subclass of `object`.
|
|
143
|
+
# * `0`, if `self` and `object` are the same.
|
|
144
|
+
# * `1`, if `object` includes `self`, or if `object` is a subclass of `self`.
|
|
145
|
+
# * `nil`, if none of the above is true.
|
|
146
|
+
#
|
|
147
|
+
# Examples:
|
|
148
|
+
#
|
|
149
|
+
# # Class Array includes module Enumerable.
|
|
150
|
+
# Array <=> Enumerable # => -1
|
|
151
|
+
# Enumerable <=> Enumerable # => 0
|
|
152
|
+
# Enumerable <=> Array # => 1
|
|
153
|
+
# # Class File is a subclass of class IO.
|
|
154
|
+
# File <=> IO # => -1
|
|
155
|
+
# IO <=> File # => 1
|
|
156
|
+
# File <=> File # => 0
|
|
146
157
|
#
|
|
147
158
|
def <=>: (untyped other) -> Integer?
|
|
148
159
|
|
|
@@ -328,6 +339,8 @@ class Module < Object
|
|
|
328
339
|
# replaced with *filename*. If *const* is defined but not as autoload, does
|
|
329
340
|
# nothing.
|
|
330
341
|
#
|
|
342
|
+
# Files that are currently being loaded must not be registered for autoload.
|
|
343
|
+
#
|
|
331
344
|
def autoload: (interned _module, String filename) -> NilClass
|
|
332
345
|
|
|
333
346
|
# <!--
|
|
@@ -487,6 +500,31 @@ class Module < Object
|
|
|
487
500
|
#
|
|
488
501
|
# Added :FOO
|
|
489
502
|
#
|
|
503
|
+
# If we define a class using the `class` keyword, `const_added` runs before
|
|
504
|
+
# `inherited`:
|
|
505
|
+
#
|
|
506
|
+
# module M
|
|
507
|
+
# def self.const_added(const_name)
|
|
508
|
+
# super
|
|
509
|
+
# p :const_added
|
|
510
|
+
# end
|
|
511
|
+
#
|
|
512
|
+
# parent = Class.new do
|
|
513
|
+
# def self.inherited(subclass)
|
|
514
|
+
# super
|
|
515
|
+
# p :inherited
|
|
516
|
+
# end
|
|
517
|
+
# end
|
|
518
|
+
#
|
|
519
|
+
# class Child < parent
|
|
520
|
+
# end
|
|
521
|
+
# end
|
|
522
|
+
#
|
|
523
|
+
# *produces:*
|
|
524
|
+
#
|
|
525
|
+
# :const_added
|
|
526
|
+
# :inherited
|
|
527
|
+
#
|
|
490
528
|
def const_added: (Symbol) -> void
|
|
491
529
|
|
|
492
530
|
# <!--
|
|
@@ -1321,19 +1359,52 @@ class Module < Object
|
|
|
1321
1359
|
# - protected(method_name, method_name, ...) -> array
|
|
1322
1360
|
# - protected(array) -> array
|
|
1323
1361
|
# -->
|
|
1324
|
-
#
|
|
1325
|
-
#
|
|
1326
|
-
#
|
|
1327
|
-
#
|
|
1328
|
-
#
|
|
1329
|
-
#
|
|
1362
|
+
# Sets the visibility of a section or of a list of method names as protected.
|
|
1363
|
+
# Accepts no arguments, a splat of method names (symbols or strings) or an array
|
|
1364
|
+
# of method names. Returns the arguments that it received.
|
|
1365
|
+
#
|
|
1366
|
+
# ## Important difference between protected in other languages
|
|
1367
|
+
#
|
|
1368
|
+
# Protected methods in Ruby are different from other languages such as Java,
|
|
1369
|
+
# where methods are marked as protected to give access to subclasses. In Ruby,
|
|
1370
|
+
# subclasses **already have access to all methods defined in the parent class**,
|
|
1371
|
+
# even private ones.
|
|
1372
|
+
#
|
|
1373
|
+
# Marking a method as protected allows **different objects of the same class**
|
|
1374
|
+
# to call it.
|
|
1375
|
+
#
|
|
1376
|
+
# One use case is for comparison methods, such as `==`, if we want to expose a
|
|
1377
|
+
# method for comparison between objects of the same class without making the
|
|
1378
|
+
# method public to objects of other classes.
|
|
1379
|
+
#
|
|
1380
|
+
# ## Performance considerations
|
|
1381
|
+
#
|
|
1382
|
+
# Protected methods are slower than others because they can't use inline cache.
|
|
1383
|
+
#
|
|
1384
|
+
# ## Example
|
|
1385
|
+
#
|
|
1386
|
+
# class Account
|
|
1387
|
+
# # Mark balance as protected, so that we can compare between accounts
|
|
1388
|
+
# # without making it public.
|
|
1389
|
+
# attr_reader :balance
|
|
1390
|
+
# protected :balance
|
|
1391
|
+
#
|
|
1392
|
+
# def initialize(balance)
|
|
1393
|
+
# @balance = balance
|
|
1394
|
+
# end
|
|
1395
|
+
#
|
|
1396
|
+
# def >(other)
|
|
1397
|
+
# # The invocation to `other.balance` is allowed because `other` is a
|
|
1398
|
+
# # different object of the same class (Account).
|
|
1399
|
+
# balance > other.balance
|
|
1400
|
+
# end
|
|
1401
|
+
# end
|
|
1330
1402
|
#
|
|
1331
|
-
#
|
|
1332
|
-
#
|
|
1333
|
-
# behavior is different from Java's protected method. Usually `private` should
|
|
1334
|
-
# be used.
|
|
1403
|
+
# account1 = Account.new(100)
|
|
1404
|
+
# account2 = Account.new(50)
|
|
1335
1405
|
#
|
|
1336
|
-
#
|
|
1406
|
+
# account1 > account2 # => true (works)
|
|
1407
|
+
# account1.balance # => NoMethodError (fails because balance is not public)
|
|
1337
1408
|
#
|
|
1338
1409
|
# To show a private method on RDoc, use `:doc:` instead of this.
|
|
1339
1410
|
#
|
data/core/nil_class.rbs
CHANGED
|
@@ -112,7 +112,7 @@ class NilClass
|
|
|
112
112
|
def nil?: () -> true
|
|
113
113
|
|
|
114
114
|
# <!--
|
|
115
|
-
# rdoc-file=
|
|
115
|
+
# rdoc-file=nilclass.rb
|
|
116
116
|
# - rationalize(eps = nil) -> (0/1)
|
|
117
117
|
# -->
|
|
118
118
|
# Returns zero as a Rational:
|
|
@@ -134,7 +134,7 @@ class NilClass
|
|
|
134
134
|
def to_a: () -> []
|
|
135
135
|
|
|
136
136
|
# <!--
|
|
137
|
-
# rdoc-file=
|
|
137
|
+
# rdoc-file=nilclass.rb
|
|
138
138
|
# - to_c -> (0+0i)
|
|
139
139
|
# -->
|
|
140
140
|
# Returns zero as a Complex:
|
|
@@ -174,7 +174,7 @@ class NilClass
|
|
|
174
174
|
def to_i: () -> 0
|
|
175
175
|
|
|
176
176
|
# <!--
|
|
177
|
-
# rdoc-file=
|
|
177
|
+
# rdoc-file=nilclass.rb
|
|
178
178
|
# - to_r -> (0/1)
|
|
179
179
|
# -->
|
|
180
180
|
# Returns zero as a Rational:
|
data/core/numeric.rbs
CHANGED
|
@@ -160,7 +160,7 @@ class Numeric
|
|
|
160
160
|
# rdoc-file=numeric.c
|
|
161
161
|
# - self % other -> real_numeric
|
|
162
162
|
# -->
|
|
163
|
-
# Returns `self` modulo `other` as a real
|
|
163
|
+
# Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
|
|
164
164
|
#
|
|
165
165
|
# Of the Core and Standard Library classes, only Rational uses this
|
|
166
166
|
# implementation.
|
|
@@ -212,7 +212,7 @@ class Numeric
|
|
|
212
212
|
# rdoc-file=numeric.c
|
|
213
213
|
# - -self -> numeric
|
|
214
214
|
# -->
|
|
215
|
-
#
|
|
215
|
+
# Returns `self`, negated.
|
|
216
216
|
#
|
|
217
217
|
def -@: () -> Numeric
|
|
218
218
|
|
|
@@ -336,7 +336,7 @@ class Numeric
|
|
|
336
336
|
# - div(other) -> integer
|
|
337
337
|
# -->
|
|
338
338
|
# Returns the quotient `self/other` as an integer (via `floor`), using method
|
|
339
|
-
# `/` in the
|
|
339
|
+
# `/` as defined in the subclass of Numeric. (Numeric itself does not define
|
|
340
340
|
# `/`.)
|
|
341
341
|
#
|
|
342
342
|
# Of the Core and Standard Library classes, Only Float and Rational use this
|
|
@@ -398,8 +398,8 @@ class Numeric
|
|
|
398
398
|
# rdoc-file=numeric.c
|
|
399
399
|
# - fdiv(other) -> float
|
|
400
400
|
# -->
|
|
401
|
-
# Returns the quotient `self/other` as a float, using method `/`
|
|
402
|
-
#
|
|
401
|
+
# Returns the quotient `self/other` as a float, using method `/` as defined in
|
|
402
|
+
# the subclass of Numeric. (Numeric itself does not define `/`.)
|
|
403
403
|
#
|
|
404
404
|
# Of the Core and Standard Library classes, only BigDecimal uses this
|
|
405
405
|
# implementation.
|
|
@@ -488,7 +488,7 @@ class Numeric
|
|
|
488
488
|
alias magnitude abs
|
|
489
489
|
|
|
490
490
|
# <!-- rdoc-file=numeric.c -->
|
|
491
|
-
# Returns `self` modulo `other` as a real
|
|
491
|
+
# Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
|
|
492
492
|
#
|
|
493
493
|
# Of the Core and Standard Library classes, only Rational uses this
|
|
494
494
|
# implementation.
|
|
@@ -530,17 +530,17 @@ class Numeric
|
|
|
530
530
|
# rdoc-file=numeric.c
|
|
531
531
|
# - nonzero? -> self or nil
|
|
532
532
|
# -->
|
|
533
|
-
# Returns
|
|
534
|
-
#
|
|
533
|
+
# Returns `self` if `self` is not a zero value, `nil` otherwise; uses method
|
|
534
|
+
# `zero?` for the evaluation.
|
|
535
535
|
#
|
|
536
|
-
#
|
|
536
|
+
# The returned `self` allows the method to be chained:
|
|
537
537
|
#
|
|
538
|
-
#
|
|
539
|
-
#
|
|
540
|
-
#
|
|
538
|
+
# a = %w[z Bb bB bb BB a aA Aa AA A]
|
|
539
|
+
# a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
|
|
540
|
+
# # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
|
|
541
541
|
#
|
|
542
|
-
#
|
|
543
|
-
#
|
|
542
|
+
# Of the Core and Standard Library classes, Integer, Float, Rational, and
|
|
543
|
+
# Complex use this implementation.
|
|
544
544
|
#
|
|
545
545
|
# Related: #zero?
|
|
546
546
|
#
|
|
@@ -765,8 +765,8 @@ class Numeric
|
|
|
765
765
|
# rdoc-file=numeric.c
|
|
766
766
|
# - to_int -> integer
|
|
767
767
|
# -->
|
|
768
|
-
# Returns `self` as an integer; converts using method `to_i` in the
|
|
769
|
-
#
|
|
768
|
+
# Returns `self` as an integer; converts using method `to_i` in the subclass of
|
|
769
|
+
# Numeric. (Numeric itself does not define `to_i`.)
|
|
770
770
|
#
|
|
771
771
|
# Of the Core and Standard Library classes, only Rational and Complex use this
|
|
772
772
|
# implementation.
|
data/core/object.rbs
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
# * #instance_of?: Returns whether `self` is an instance of the given class.
|
|
41
41
|
# * #instance_variable_defined?: Returns whether the given instance variable
|
|
42
42
|
# is defined in `self`.
|
|
43
|
-
# * #method: Returns the Method object for the given method in `self`.
|
|
43
|
+
# * #method: Returns the `Method` object for the given method in `self`.
|
|
44
44
|
# * #methods: Returns an array of symbol names of public and protected methods
|
|
45
45
|
# in `self`.
|
|
46
46
|
# * #nil?: Returns `false`. (Only `nil` responds `true` to method `nil?`.)
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
# methods in `self`.
|
|
51
51
|
# * #protected_methods: Returns an array of the symbol names of the protected
|
|
52
52
|
# methods in `self`.
|
|
53
|
-
# * #public_method: Returns the Method object for the given public method in
|
|
53
|
+
# * #public_method: Returns the `Method` object for the given public method in
|
|
54
54
|
# `self`.
|
|
55
55
|
# * #public_methods: Returns an array of the symbol names of the public
|
|
56
56
|
# methods in `self`.
|
|
57
57
|
# * #respond_to?: Returns whether `self` responds to the given method.
|
|
58
58
|
# * #singleton_class: Returns the singleton class of `self`.
|
|
59
|
-
# * #singleton_method: Returns the Method object for the given singleton
|
|
59
|
+
# * #singleton_method: Returns the `Method` object for the given singleton
|
|
60
60
|
# method in `self`.
|
|
61
61
|
# * #singleton_methods: Returns an array of the symbol names of the singleton
|
|
62
62
|
# methods in `self`.
|
data/core/object_space.rbs
CHANGED
|
@@ -29,6 +29,7 @@ module ObjectSpace
|
|
|
29
29
|
# - _id2ref(p1)
|
|
30
30
|
# -->
|
|
31
31
|
#
|
|
32
|
+
%a{deprecated}
|
|
32
33
|
def self._id2ref: (Integer id) -> untyped
|
|
33
34
|
|
|
34
35
|
# <!--
|
|
@@ -136,28 +137,33 @@ module ObjectSpace
|
|
|
136
137
|
# Calls the block once for each living, nonimmediate object in this Ruby
|
|
137
138
|
# process. If *module* is specified, calls the block for only those classes or
|
|
138
139
|
# modules that match (or are a subclass of) *module*. Returns the number of
|
|
139
|
-
# objects found. Immediate objects (`Fixnum`s, `Symbol`s `true`,
|
|
140
|
-
# `nil`) are never returned.
|
|
141
|
-
# numbers we defined and several constants defined in the Math module.
|
|
140
|
+
# objects found. Immediate objects (such as `Fixnum`s, static `Symbol`s `true`,
|
|
141
|
+
# `false` and `nil`) are never returned.
|
|
142
142
|
#
|
|
143
143
|
# If no block is given, an enumerator is returned instead.
|
|
144
144
|
#
|
|
145
|
-
#
|
|
146
|
-
#
|
|
147
|
-
#
|
|
148
|
-
# count = ObjectSpace.each_object(Numeric) {|x| p x }
|
|
145
|
+
# Job = Class.new
|
|
146
|
+
# jobs = [Job.new, Job.new]
|
|
147
|
+
# count = ObjectSpace.each_object(Job) {|x| p x }
|
|
149
148
|
# puts "Total count: #{count}"
|
|
150
149
|
#
|
|
151
150
|
# *produces:*
|
|
152
151
|
#
|
|
153
|
-
#
|
|
154
|
-
#
|
|
155
|
-
#
|
|
156
|
-
#
|
|
157
|
-
#
|
|
158
|
-
#
|
|
159
|
-
#
|
|
160
|
-
#
|
|
152
|
+
# #<Job:0x000000011d6cbbf0>
|
|
153
|
+
# #<Job:0x000000011d6cbc68>
|
|
154
|
+
# Total count: 2
|
|
155
|
+
#
|
|
156
|
+
# Due to a current Ractor implementation issue, this method does not yield
|
|
157
|
+
# Ractor-unshareable objects when the process is in multi-Ractor mode.
|
|
158
|
+
# Multi-ractor mode is enabled when `Ractor.new` has been called for the first
|
|
159
|
+
# time. See https://bugs.ruby-lang.org/issues/19387 for more information.
|
|
160
|
+
#
|
|
161
|
+
# a = 12345678987654321 # shareable
|
|
162
|
+
# b = [].freeze # shareable
|
|
163
|
+
# c = {} # not shareable
|
|
164
|
+
# ObjectSpace.each_object {|x| x } # yields a, b, and c
|
|
165
|
+
# Ractor.new {} # enter multi-Ractor mode
|
|
166
|
+
# ObjectSpace.each_object {|x| x } # does not yield c
|
|
161
167
|
#
|
|
162
168
|
def self.each_object: (?Module `module`) -> Enumerator[untyped, Integer]
|
|
163
169
|
| (?Module `module`) { (untyped obj) -> void } -> Integer
|