rbs 3.10.2 → 4.0.0.dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/ruby.yml +24 -34
- data/.github/workflows/typecheck.yml +3 -1
- data/.github/workflows/windows.yml +2 -2
- data/.gitignore +0 -4
- data/CHANGELOG.md +0 -107
- data/README.md +1 -38
- data/Rakefile +20 -142
- data/Steepfile +1 -0
- data/config.yml +43 -1
- data/core/array.rbs +46 -96
- data/core/comparable.rbs +6 -13
- data/core/complex.rbs +25 -40
- data/core/dir.rbs +4 -4
- data/core/encoding.rbs +9 -6
- data/core/enumerable.rbs +3 -90
- data/core/enumerator.rbs +1 -43
- data/core/errno.rbs +0 -8
- data/core/errors.rbs +1 -28
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +20 -29
- data/core/file.rbs +19 -49
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +33 -224
- data/core/gc.rbs +281 -417
- data/core/hash.rbs +727 -1023
- data/core/integer.rbs +63 -104
- data/core/io/buffer.rbs +10 -21
- data/core/io/wait.rbs +33 -11
- data/core/io.rbs +12 -14
- data/core/kernel.rbs +51 -61
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +3 -42
- data/core/method.rbs +25 -63
- data/core/module.rbs +23 -101
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +17 -25
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +15 -21
- data/core/proc.rbs +24 -30
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +509 -361
- data/core/range.rbs +8 -7
- data/core/rational.rbs +34 -56
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +2 -4
- data/core/regexp.rbs +20 -25
- data/core/ruby_vm.rbs +4 -6
- data/core/rubygems/errors.rbs +70 -3
- data/core/rubygems/rubygems.rbs +79 -11
- data/core/rubygems/version.rbs +3 -2
- data/core/set.rbs +359 -488
- data/core/signal.rbs +14 -24
- data/core/string.rbs +1236 -3165
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +11 -17
- data/core/thread.rbs +33 -95
- data/core/time.rbs +9 -35
- data/core/trace_point.rbs +4 -7
- data/core/unbound_method.rbs +6 -14
- data/docs/collection.md +2 -2
- data/docs/gem.md +1 -0
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1077 -944
- data/ext/rbs_extension/ast_translation.h +0 -7
- data/ext/rbs_extension/class_constants.c +83 -71
- data/ext/rbs_extension/class_constants.h +7 -4
- data/ext/rbs_extension/extconf.rb +2 -24
- data/ext/rbs_extension/legacy_location.c +172 -173
- data/ext/rbs_extension/legacy_location.h +3 -8
- data/ext/rbs_extension/main.c +289 -239
- data/ext/rbs_extension/rbs_extension.h +0 -3
- data/ext/rbs_extension/rbs_string_bridging.h +0 -4
- data/include/rbs/ast.h +98 -37
- data/include/rbs/defines.h +12 -38
- data/include/rbs/lexer.h +114 -126
- data/include/rbs/location.h +14 -14
- data/include/rbs/parser.h +37 -21
- data/include/rbs/string.h +5 -3
- data/include/rbs/util/rbs_allocator.h +19 -40
- data/include/rbs/util/rbs_assert.h +1 -12
- data/include/rbs/util/rbs_constant_pool.h +3 -3
- data/include/rbs/util/rbs_encoding.h +1 -3
- data/include/rbs/util/rbs_unescape.h +1 -2
- data/lib/rbs/ast/ruby/annotations.rb +119 -0
- data/lib/rbs/ast/ruby/comment_block.rb +221 -0
- data/lib/rbs/ast/ruby/declarations.rb +86 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +213 -0
- data/lib/rbs/buffer.rb +104 -24
- data/lib/rbs/cli/validate.rb +40 -35
- data/lib/rbs/cli.rb +5 -6
- data/lib/rbs/collection/config/lockfile_generator.rb +0 -8
- data/lib/rbs/collection.rb +0 -1
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
- data/lib/rbs/definition_builder/method_builder.rb +45 -30
- data/lib/rbs/definition_builder.rb +44 -9
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -0
- data/lib/rbs/environment.rb +244 -218
- data/lib/rbs/environment_loader.rb +8 -2
- data/lib/rbs/errors.rb +5 -4
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +206 -0
- data/lib/rbs/location_aux.rb +35 -3
- data/lib/rbs/parser_aux.rb +11 -6
- data/lib/rbs/prototype/runtime.rb +2 -2
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +38 -124
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +5 -6
- data/lib/rbs/test/type_check.rb +0 -14
- data/lib/rbs/types.rb +1 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +13 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +1 -0
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/ast/ruby/annotations.rbs +110 -0
- data/sig/ast/ruby/comment_block.rbs +119 -0
- data/sig/ast/ruby/declarations.rbs +60 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +72 -0
- data/sig/buffer.rbs +63 -5
- data/sig/definition.rbs +1 -0
- data/sig/definition_builder.rbs +1 -1
- data/sig/environment/class_entry.rbs +50 -0
- data/sig/environment/module_entry.rbs +50 -0
- data/sig/environment.rbs +28 -133
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +87 -0
- data/sig/location.rbs +32 -7
- data/sig/manifest.yaml +1 -0
- data/sig/method_builder.rbs +7 -4
- data/sig/parser.rbs +16 -20
- data/sig/resolver/type_name_resolver.rbs +7 -38
- data/sig/source.rbs +48 -0
- data/sig/types.rbs +1 -4
- data/src/ast.c +290 -201
- data/src/lexer.c +2813 -2902
- data/src/lexer.re +4 -0
- data/src/lexstate.c +155 -169
- data/src/location.c +40 -40
- data/src/parser.c +2665 -2433
- data/src/string.c +48 -0
- data/src/util/rbs_allocator.c +76 -92
- data/src/util/rbs_assert.c +10 -10
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +15 -13
- data/src/util/rbs_encoding.c +4062 -20097
- data/src/util/rbs_unescape.c +48 -85
- data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
- data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
- data/stdlib/cgi/0/core.rbs +393 -9
- data/stdlib/cgi/0/manifest.yaml +0 -1
- data/stdlib/coverage/0/coverage.rbs +1 -3
- data/stdlib/date/0/date.rbs +59 -67
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +7 -10
- data/stdlib/erb/0/erb.rbs +347 -737
- data/stdlib/fileutils/0/fileutils.rbs +13 -18
- data/stdlib/forwardable/0/forwardable.rbs +0 -3
- data/stdlib/json/0/json.rbs +48 -68
- data/stdlib/net-http/0/net-http.rbs +0 -3
- data/stdlib/objspace/0/objspace.rbs +4 -9
- data/stdlib/open-uri/0/open-uri.rbs +0 -40
- data/stdlib/openssl/0/openssl.rbs +228 -331
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/pathname/0/pathname.rbs +1380 -10
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +68 -25
- data/stdlib/ripper/0/ripper.rbs +2 -5
- data/stdlib/singleton/0/singleton.rbs +0 -3
- data/stdlib/socket/0/socket.rbs +1 -13
- data/stdlib/socket/0/tcp_socket.rbs +2 -10
- data/stdlib/stringio/0/stringio.rbs +85 -1176
- 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 +7 -63
- data/stdlib/tsort/0/cyclic.rbs +0 -3
- data/stdlib/uri/0/common.rbs +2 -11
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +16 -17
- data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
- data/stdlib/zlib/0/zstream.rbs +0 -1
- metadata +39 -12
- data/.clang-format +0 -74
- data/.clangd +0 -2
- data/.github/workflows/c-check.yml +0 -54
- data/core/pathname.rbs +0 -1272
- data/core/ruby.rbs +0 -53
- data/docs/aliases.md +0 -79
- data/docs/encoding.md +0 -56
- data/ext/rbs_extension/compat.h +0 -10
- data/stdlib/cgi-escape/0/escape.rbs +0 -171
data/core/array.rbs
CHANGED
|
@@ -151,8 +151,8 @@
|
|
|
151
151
|
#
|
|
152
152
|
# ## Example Usage
|
|
153
153
|
#
|
|
154
|
-
# In addition to the methods it mixes in through the Enumerable module,
|
|
155
|
-
# Array has proprietary methods for accessing, searching and otherwise
|
|
154
|
+
# In addition to the methods it mixes in through the Enumerable module, the
|
|
155
|
+
# `Array` class has proprietary methods for accessing, searching and otherwise
|
|
156
156
|
# manipulating arrays.
|
|
157
157
|
#
|
|
158
158
|
# Some of the more common ones are illustrated below.
|
|
@@ -200,9 +200,9 @@
|
|
|
200
200
|
#
|
|
201
201
|
# arr.drop(3) #=> [4, 5, 6]
|
|
202
202
|
#
|
|
203
|
-
# ## Obtaining Information about an Array
|
|
203
|
+
# ## Obtaining Information about an `Array`
|
|
204
204
|
#
|
|
205
|
-
#
|
|
205
|
+
# Arrays keep track of their own length at all times. To query an array about
|
|
206
206
|
# the number of elements it contains, use #length, #count or #size.
|
|
207
207
|
#
|
|
208
208
|
# browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE']
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
#
|
|
218
218
|
# browsers.include?('Konqueror') #=> false
|
|
219
219
|
#
|
|
220
|
-
# ## Adding Items to
|
|
220
|
+
# ## Adding Items to Arrays
|
|
221
221
|
#
|
|
222
222
|
# Items can be added to the end of an array by using either #push or #<<
|
|
223
223
|
#
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
# arr.insert(3, 'orange', 'pear', 'grapefruit')
|
|
239
239
|
# #=> [0, 1, 2, "orange", "pear", "grapefruit", "apple", 3, 4, 5, 6]
|
|
240
240
|
#
|
|
241
|
-
# ## Removing Items from an Array
|
|
241
|
+
# ## Removing Items from an `Array`
|
|
242
242
|
#
|
|
243
243
|
# The method #pop removes the last element in an array and returns it:
|
|
244
244
|
#
|
|
@@ -277,12 +277,12 @@
|
|
|
277
277
|
# arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556]
|
|
278
278
|
# arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123]
|
|
279
279
|
#
|
|
280
|
-
# ## Iterating over
|
|
280
|
+
# ## Iterating over Arrays
|
|
281
281
|
#
|
|
282
|
-
# Like all classes that include the Enumerable module,
|
|
282
|
+
# Like all classes that include the Enumerable module, `Array` has an each
|
|
283
283
|
# method, which defines what elements should be iterated over and how. In case
|
|
284
|
-
# of Array#each, all elements in `
|
|
285
|
-
# sequence.
|
|
284
|
+
# of Array's #each, all elements in the `Array` instance are yielded to the
|
|
285
|
+
# supplied block in sequence.
|
|
286
286
|
#
|
|
287
287
|
# Note that this operation leaves the array unchanged.
|
|
288
288
|
#
|
|
@@ -307,7 +307,7 @@
|
|
|
307
307
|
# arr.map! {|a| a**2} #=> [1, 4, 9, 16, 25]
|
|
308
308
|
# arr #=> [1, 4, 9, 16, 25]
|
|
309
309
|
#
|
|
310
|
-
# ## Selecting Items from an Array
|
|
310
|
+
# ## Selecting Items from an `Array`
|
|
311
311
|
#
|
|
312
312
|
# Elements can be selected from an array according to criteria defined in a
|
|
313
313
|
# block. The selection can happen in a destructive or a non-destructive manner.
|
|
@@ -340,13 +340,13 @@
|
|
|
340
340
|
#
|
|
341
341
|
# ## What's Here
|
|
342
342
|
#
|
|
343
|
-
# First, what's elsewhere. Class Array
|
|
343
|
+
# First, what's elsewhere. Class `Array`:
|
|
344
344
|
#
|
|
345
345
|
# * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
|
|
346
346
|
# * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
|
|
347
347
|
# provides dozens of additional methods.
|
|
348
348
|
#
|
|
349
|
-
# Here, class Array provides methods that are useful for:
|
|
349
|
+
# Here, class `Array` provides methods that are useful for:
|
|
350
350
|
#
|
|
351
351
|
# * [Creating an Array](rdoc-ref:Array@Methods+for+Creating+an+Array)
|
|
352
352
|
# * [Querying](rdoc-ref:Array@Methods+for+Querying)
|
|
@@ -359,7 +359,7 @@
|
|
|
359
359
|
# * [Converting](rdoc-ref:Array@Methods+for+Converting)
|
|
360
360
|
# * [And more....](rdoc-ref:Array@Other+Methods)
|
|
361
361
|
#
|
|
362
|
-
# ### Methods for Creating an Array
|
|
362
|
+
# ### Methods for Creating an `Array`
|
|
363
363
|
#
|
|
364
364
|
# * ::[]: Returns a new array populated with given objects.
|
|
365
365
|
# * ::new: Returns a new array.
|
|
@@ -524,7 +524,7 @@
|
|
|
524
524
|
# return-value.
|
|
525
525
|
# * #flatten: Returns an array that is a recursive flattening of `self`.
|
|
526
526
|
# * #inspect (aliased as #to_s): Returns a new String containing the elements.
|
|
527
|
-
# * #join: Returns a
|
|
527
|
+
# * #join: Returns a newsString containing the elements joined by the field
|
|
528
528
|
# separator.
|
|
529
529
|
# * #to_a: Returns `self` or a new array containing all elements.
|
|
530
530
|
# * #to_ary: Returns `self`.
|
|
@@ -840,8 +840,9 @@ class Array[unchecked out Elem] < Object
|
|
|
840
840
|
#
|
|
841
841
|
# If `index` is out of range, returns `nil`.
|
|
842
842
|
#
|
|
843
|
-
# When two Integer arguments `start` and `length` are given, returns a new
|
|
844
|
-
# of size `length` containing successive elements beginning at offset
|
|
843
|
+
# When two Integer arguments `start` and `length` are given, returns a new
|
|
844
|
+
# `Array` of size `length` containing successive elements beginning at offset
|
|
845
|
+
# `start`:
|
|
845
846
|
#
|
|
846
847
|
# a = [:foo, 'bar', 2]
|
|
847
848
|
# a[0, 2] # => [:foo, "bar"]
|
|
@@ -855,7 +856,7 @@ class Array[unchecked out Elem] < Object
|
|
|
855
856
|
# a[1, 3] # => ["bar", 2]
|
|
856
857
|
# a[2, 2] # => [2]
|
|
857
858
|
#
|
|
858
|
-
# If `start == self.size` and `length >= 0`, returns a new empty
|
|
859
|
+
# If `start == self.size` and `length >= 0`, returns a new empty `Array`.
|
|
859
860
|
#
|
|
860
861
|
# If `length` is negative, returns `nil`.
|
|
861
862
|
#
|
|
@@ -866,7 +867,7 @@ class Array[unchecked out Elem] < Object
|
|
|
866
867
|
# a[0..1] # => [:foo, "bar"]
|
|
867
868
|
# a[1..2] # => ["bar", 2]
|
|
868
869
|
#
|
|
869
|
-
# Special case: If `range.start == a.size`, returns a new empty
|
|
870
|
+
# Special case: If `range.start == a.size`, returns a new empty `Array`.
|
|
870
871
|
#
|
|
871
872
|
# If `range.end` is negative, calculates the end index from the end:
|
|
872
873
|
#
|
|
@@ -890,7 +891,7 @@ class Array[unchecked out Elem] < Object
|
|
|
890
891
|
# a[4..-1] # => nil
|
|
891
892
|
#
|
|
892
893
|
# When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns
|
|
893
|
-
# an
|
|
894
|
+
# an `Array` of elements corresponding to the indexes produced by the sequence.
|
|
894
895
|
#
|
|
895
896
|
# a = ['--', 'data1', '--', 'data2', '--', 'data3']
|
|
896
897
|
# a[(1..).step(2)] # => ["data1", "data2", "data3"]
|
|
@@ -975,8 +976,8 @@ class Array[unchecked out Elem] < Object
|
|
|
975
976
|
# a # => [:foo, "bar", "two"]
|
|
976
977
|
#
|
|
977
978
|
# When Integer arguments `start` and `length` are given and `object` is not an
|
|
978
|
-
#
|
|
979
|
-
# `object` at offset `start`:
|
|
979
|
+
# `Array`, removes `length - 1` elements beginning at offset `start`, and
|
|
980
|
+
# assigns `object` at offset `start`:
|
|
980
981
|
#
|
|
981
982
|
# a = [:foo, 'bar', 2]
|
|
982
983
|
# a[0, 2] = 'foo' # => "foo"
|
|
@@ -1009,7 +1010,7 @@ class Array[unchecked out Elem] < Object
|
|
|
1009
1010
|
# a[1, 5] = 'foo' # => "foo"
|
|
1010
1011
|
# a # => [:foo, "foo"]
|
|
1011
1012
|
#
|
|
1012
|
-
# When Range argument `range` is given and `object` is not an
|
|
1013
|
+
# When Range argument `range` is given and `object` is not an `Array`, removes
|
|
1013
1014
|
# `length - 1` elements beginning at offset `start`, and assigns `object` at
|
|
1014
1015
|
# offset `start`:
|
|
1015
1016
|
#
|
|
@@ -1213,7 +1214,7 @@ class Array[unchecked out Elem] < Object
|
|
|
1213
1214
|
# Returns the element from `self` found by a binary search, or `nil` if the
|
|
1214
1215
|
# search found no suitable element.
|
|
1215
1216
|
#
|
|
1216
|
-
# See [Binary Searching](rdoc-ref:
|
|
1217
|
+
# See [Binary Searching](rdoc-ref:bsearch.rdoc).
|
|
1217
1218
|
#
|
|
1218
1219
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1219
1220
|
#
|
|
@@ -1229,7 +1230,7 @@ class Array[unchecked out Elem] < Object
|
|
|
1229
1230
|
# Returns the integer index of the element from `self` found by a binary search,
|
|
1230
1231
|
# or `nil` if the search found no suitable element.
|
|
1231
1232
|
#
|
|
1232
|
-
# See [Binary Searching](rdoc-ref:
|
|
1233
|
+
# See [Binary Searching](rdoc-ref:bsearch.rdoc).
|
|
1233
1234
|
#
|
|
1234
1235
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1235
1236
|
#
|
|
@@ -1273,9 +1274,9 @@ class Array[unchecked out Elem] < Object
|
|
|
1273
1274
|
|
|
1274
1275
|
# <!--
|
|
1275
1276
|
# rdoc-file=array.c
|
|
1276
|
-
# - collect! {|element| ... } ->
|
|
1277
|
+
# - collect! {|element| ... } -> new_array
|
|
1277
1278
|
# - collect! -> new_enumerator
|
|
1278
|
-
# - map! {|element| ... } ->
|
|
1279
|
+
# - map! {|element| ... } -> new_array
|
|
1279
1280
|
# - map! -> new_enumerator
|
|
1280
1281
|
# -->
|
|
1281
1282
|
# With a block given, calls the block with each element of `self` and replaces
|
|
@@ -1563,7 +1564,7 @@ class Array[unchecked out Elem] < Object
|
|
|
1563
1564
|
|
|
1564
1565
|
# <!--
|
|
1565
1566
|
# rdoc-file=array.c
|
|
1566
|
-
# - dig(index, *identifiers) -> object
|
|
1567
|
+
# - array.dig(index, *identifiers) -> object
|
|
1567
1568
|
# -->
|
|
1568
1569
|
# Finds and returns the object in nested object specified by `index` and
|
|
1569
1570
|
# `identifiers`; the nested objects may be instances of various classes. See
|
|
@@ -1692,7 +1693,7 @@ class Array[unchecked out Elem] < Object
|
|
|
1692
1693
|
|
|
1693
1694
|
# <!--
|
|
1694
1695
|
# rdoc-file=array.c
|
|
1695
|
-
# - empty? -> true or false
|
|
1696
|
+
# - array.empty? -> true or false
|
|
1696
1697
|
# -->
|
|
1697
1698
|
# Returns `true` if the count of elements in `self` is zero, `false` otherwise.
|
|
1698
1699
|
#
|
|
@@ -1803,10 +1804,10 @@ class Array[unchecked out Elem] < Object
|
|
|
1803
1804
|
|
|
1804
1805
|
# <!--
|
|
1805
1806
|
# rdoc-file=array.c
|
|
1806
|
-
# - fill(object, start = nil, count = nil) ->
|
|
1807
|
-
# - fill(object, range) ->
|
|
1808
|
-
# - fill(start = nil, count = nil) {|element| ... } ->
|
|
1809
|
-
# - fill(range) {|element| ... } ->
|
|
1807
|
+
# - fill(object, start = nil, count = nil) -> new_array
|
|
1808
|
+
# - fill(object, range) -> new_array
|
|
1809
|
+
# - fill(start = nil, count = nil) {|element| ... } -> new_array
|
|
1810
|
+
# - fill(range) {|element| ... } -> new_array
|
|
1810
1811
|
# -->
|
|
1811
1812
|
# Replaces selected elements in `self`; may add elements to `self`; always
|
|
1812
1813
|
# returns `self` (never a new array).
|
|
@@ -2019,30 +2020,6 @@ class Array[unchecked out Elem] < Object
|
|
|
2019
2020
|
def filter!: () { (Elem item) -> boolish } -> self?
|
|
2020
2021
|
| () -> ::Enumerator[Elem, self?]
|
|
2021
2022
|
|
|
2022
|
-
# <!--
|
|
2023
|
-
# rdoc-file=array.c
|
|
2024
|
-
# - find(if_none_proc = nil) {|element| ... } -> object or nil
|
|
2025
|
-
# - find(if_none_proc = nil) -> enumerator
|
|
2026
|
-
# -->
|
|
2027
|
-
# Returns the first element for which the block returns a truthy value.
|
|
2028
|
-
#
|
|
2029
|
-
# With a block given, calls the block with successive elements of the array;
|
|
2030
|
-
# returns the first element for which the block returns a truthy value:
|
|
2031
|
-
#
|
|
2032
|
-
# [1, 3, 5].find {|element| element > 2} # => 3
|
|
2033
|
-
#
|
|
2034
|
-
# If no such element is found, calls `if_none_proc` and returns its return
|
|
2035
|
-
# value.
|
|
2036
|
-
#
|
|
2037
|
-
# [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1
|
|
2038
|
-
#
|
|
2039
|
-
# With no block given, returns an Enumerator.
|
|
2040
|
-
#
|
|
2041
|
-
def find: () { (Elem) -> boolish } -> Elem?
|
|
2042
|
-
| () -> ::Enumerator[Elem, Elem?]
|
|
2043
|
-
| [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
|
|
2044
|
-
| [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
|
|
2045
|
-
|
|
2046
2023
|
# <!--
|
|
2047
2024
|
# rdoc-file=array.c
|
|
2048
2025
|
# - find_index(object) -> integer or nil
|
|
@@ -2323,7 +2300,7 @@ class Array[unchecked out Elem] < Object
|
|
|
2323
2300
|
|
|
2324
2301
|
# <!--
|
|
2325
2302
|
# rdoc-file=array.c
|
|
2326
|
-
# - join(separator = $,) -> new_string
|
|
2303
|
+
# - array.join(separator = $,) -> new_string
|
|
2327
2304
|
# -->
|
|
2328
2305
|
# Returns the new string formed by joining the converted elements of `self`; for
|
|
2329
2306
|
# each element `element`:
|
|
@@ -2642,7 +2619,7 @@ class Array[unchecked out Elem] < Object
|
|
|
2642
2619
|
# - pack(template, buffer: nil) -> string
|
|
2643
2620
|
# -->
|
|
2644
2621
|
# Formats each element in `self` into a binary string; returns that string. See
|
|
2645
|
-
# [Packed Data](rdoc-ref:
|
|
2622
|
+
# [Packed Data](rdoc-ref:packed_data.rdoc).
|
|
2646
2623
|
#
|
|
2647
2624
|
def pack: (string fmt, ?buffer: String?) -> String
|
|
2648
2625
|
|
|
@@ -3012,31 +2989,6 @@ class Array[unchecked out Elem] < Object
|
|
|
3012
2989
|
def reverse_each: () { (Elem item) -> void } -> self
|
|
3013
2990
|
| () -> ::Enumerator[Elem, self]
|
|
3014
2991
|
|
|
3015
|
-
# <!--
|
|
3016
|
-
# rdoc-file=array.c
|
|
3017
|
-
# - rfind(if_none_proc = nil) {|element| ... } -> object or nil
|
|
3018
|
-
# - rfind(if_none_proc = nil) -> enumerator
|
|
3019
|
-
# -->
|
|
3020
|
-
# Returns the last element for which the block returns a truthy value.
|
|
3021
|
-
#
|
|
3022
|
-
# With a block given, calls the block with successive elements of the array in
|
|
3023
|
-
# reverse order; returns the first element for which the block returns a truthy
|
|
3024
|
-
# value:
|
|
3025
|
-
#
|
|
3026
|
-
# [1, 2, 3, 4, 5, 6].rfind {|element| element < 5} # => 4
|
|
3027
|
-
#
|
|
3028
|
-
# If no such element is found, calls `if_none_proc` and returns its return
|
|
3029
|
-
# value.
|
|
3030
|
-
#
|
|
3031
|
-
# [1, 2, 3, 4].rfind(proc {0}) {|element| element < -2} # => 0
|
|
3032
|
-
#
|
|
3033
|
-
# With no block given, returns an Enumerator.
|
|
3034
|
-
#
|
|
3035
|
-
def rfind: () { (Elem) -> boolish } -> Elem?
|
|
3036
|
-
| () -> ::Enumerator[Elem, Elem?]
|
|
3037
|
-
| [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
|
|
3038
|
-
| [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
|
|
3039
|
-
|
|
3040
2992
|
# <!--
|
|
3041
2993
|
# rdoc-file=array.c
|
|
3042
2994
|
# - rindex(object) -> integer or nil
|
|
@@ -3163,7 +3115,7 @@ class Array[unchecked out Elem] < Object
|
|
|
3163
3115
|
#
|
|
3164
3116
|
# The order of the result array is unrelated to the order of `self`.
|
|
3165
3117
|
#
|
|
3166
|
-
# Returns a new empty
|
|
3118
|
+
# Returns a new empty `Array` if `self` is empty:
|
|
3167
3119
|
#
|
|
3168
3120
|
# [].sample(4) # => []
|
|
3169
3121
|
#
|
|
@@ -3368,8 +3320,9 @@ class Array[unchecked out Elem] < Object
|
|
|
3368
3320
|
#
|
|
3369
3321
|
# If `index` is out of range, returns `nil`.
|
|
3370
3322
|
#
|
|
3371
|
-
# When two Integer arguments `start` and `length` are given, returns a new
|
|
3372
|
-
# of size `length` containing successive elements beginning at offset
|
|
3323
|
+
# When two Integer arguments `start` and `length` are given, returns a new
|
|
3324
|
+
# `Array` of size `length` containing successive elements beginning at offset
|
|
3325
|
+
# `start`:
|
|
3373
3326
|
#
|
|
3374
3327
|
# a = [:foo, 'bar', 2]
|
|
3375
3328
|
# a[0, 2] # => [:foo, "bar"]
|
|
@@ -3383,7 +3336,7 @@ class Array[unchecked out Elem] < Object
|
|
|
3383
3336
|
# a[1, 3] # => ["bar", 2]
|
|
3384
3337
|
# a[2, 2] # => [2]
|
|
3385
3338
|
#
|
|
3386
|
-
# If `start == self.size` and `length >= 0`, returns a new empty
|
|
3339
|
+
# If `start == self.size` and `length >= 0`, returns a new empty `Array`.
|
|
3387
3340
|
#
|
|
3388
3341
|
# If `length` is negative, returns `nil`.
|
|
3389
3342
|
#
|
|
@@ -3394,7 +3347,7 @@ class Array[unchecked out Elem] < Object
|
|
|
3394
3347
|
# a[0..1] # => [:foo, "bar"]
|
|
3395
3348
|
# a[1..2] # => ["bar", 2]
|
|
3396
3349
|
#
|
|
3397
|
-
# Special case: If `range.start == a.size`, returns a new empty
|
|
3350
|
+
# Special case: If `range.start == a.size`, returns a new empty `Array`.
|
|
3398
3351
|
#
|
|
3399
3352
|
# If `range.end` is negative, calculates the end index from the end:
|
|
3400
3353
|
#
|
|
@@ -3418,7 +3371,7 @@ class Array[unchecked out Elem] < Object
|
|
|
3418
3371
|
# a[4..-1] # => nil
|
|
3419
3372
|
#
|
|
3420
3373
|
# When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns
|
|
3421
|
-
# an
|
|
3374
|
+
# an `Array` of elements corresponding to the indexes produced by the sequence.
|
|
3422
3375
|
#
|
|
3423
3376
|
# a = ['--', 'data1', '--', 'data2', '--', 'data3']
|
|
3424
3377
|
# a[(1..).step(2)] # => ["data1", "data2", "data3"]
|
|
@@ -3565,9 +3518,6 @@ class Array[unchecked out Elem] < Object
|
|
|
3565
3518
|
# When the block returns zero, the order for `a` and `b` is indeterminate, and
|
|
3566
3519
|
# may be unstable.
|
|
3567
3520
|
#
|
|
3568
|
-
# See an example in Numeric#nonzero? for the idiom to sort more complex
|
|
3569
|
-
# structure.
|
|
3570
|
-
#
|
|
3571
3521
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3572
3522
|
#
|
|
3573
3523
|
def sort: () -> ::Array[Elem]
|
|
@@ -3697,7 +3647,7 @@ class Array[unchecked out Elem] < Object
|
|
|
3697
3647
|
# rdoc-file=array.c
|
|
3698
3648
|
# - to_a -> self or new_array
|
|
3699
3649
|
# -->
|
|
3700
|
-
# When `self` is an instance of Array
|
|
3650
|
+
# When `self` is an instance of `Array`, returns `self`.
|
|
3701
3651
|
#
|
|
3702
3652
|
# Otherwise, returns a new array containing the elements of `self`:
|
|
3703
3653
|
#
|
|
@@ -3713,7 +3663,7 @@ class Array[unchecked out Elem] < Object
|
|
|
3713
3663
|
|
|
3714
3664
|
# <!--
|
|
3715
3665
|
# rdoc-file=array.c
|
|
3716
|
-
# - to_ary -> self
|
|
3666
|
+
# - array.to_ary -> self
|
|
3717
3667
|
# -->
|
|
3718
3668
|
# Returns `self`.
|
|
3719
3669
|
#
|
|
@@ -4058,7 +4008,7 @@ class Array[unchecked out Elem] < Object
|
|
|
4058
4008
|
# [:c3, :b3, :a3]]
|
|
4059
4009
|
#
|
|
4060
4010
|
# For an **object** in **other_arrays** that is not actually an array, forms the
|
|
4061
|
-
# "other array" as `object.to_ary`, if defined, or as `object.each.to_a`
|
|
4011
|
+
# the "other array" as `object.to_ary`, if defined, or as `object.each.to_a`
|
|
4062
4012
|
# otherwise.
|
|
4063
4013
|
#
|
|
4064
4014
|
# Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
|
data/core/comparable.rbs
CHANGED
|
@@ -55,26 +55,19 @@
|
|
|
55
55
|
module Comparable : _WithSpaceshipOperator
|
|
56
56
|
# <!--
|
|
57
57
|
# rdoc-file=compar.c
|
|
58
|
-
# -
|
|
58
|
+
# - obj < other -> true or false
|
|
59
59
|
# -->
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
# 'foo' < 'foo' # => false
|
|
64
|
-
# 'foo' < 'food' # => true
|
|
60
|
+
# Compares two objects based on the receiver's `<=>` method, returning true if
|
|
61
|
+
# it returns a value less than 0.
|
|
65
62
|
#
|
|
66
63
|
def <: (untyped other) -> bool
|
|
67
64
|
|
|
68
65
|
# <!--
|
|
69
66
|
# rdoc-file=compar.c
|
|
70
|
-
# -
|
|
67
|
+
# - obj <= other -> true or false
|
|
71
68
|
# -->
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
# 'foo' <= 'foo' # => true
|
|
76
|
-
# 'foo' <= 'food' # => true
|
|
77
|
-
# 'food' <= 'foo' # => false
|
|
69
|
+
# Compares two objects based on the receiver's `<=>` method, returning true if
|
|
70
|
+
# it returns a value less than or equal to 0.
|
|
78
71
|
#
|
|
79
72
|
def <=: (untyped other) -> bool
|
|
80
73
|
|
data/core/complex.rbs
CHANGED
|
@@ -184,24 +184,23 @@ class Complex < Numeric
|
|
|
184
184
|
|
|
185
185
|
# <!--
|
|
186
186
|
# rdoc-file=complex.c
|
|
187
|
-
# -
|
|
187
|
+
# - complex * numeric -> new_complex
|
|
188
188
|
# -->
|
|
189
|
-
# Returns the
|
|
189
|
+
# Returns the product of `self` and `numeric`:
|
|
190
190
|
#
|
|
191
|
-
# Complex.rect(9, 8) * 4 # => (36+32i)
|
|
192
|
-
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
|
|
193
191
|
# Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i)
|
|
194
192
|
# Complex.rect(900) * Complex.rect(1) # => (900+0i)
|
|
195
193
|
# Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i)
|
|
196
|
-
# Complex.rect(9, 8) *
|
|
194
|
+
# Complex.rect(9, 8) * 4 # => (36+32i)
|
|
195
|
+
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
|
|
197
196
|
#
|
|
198
197
|
def *: (Numeric) -> Complex
|
|
199
198
|
|
|
200
199
|
# <!--
|
|
201
200
|
# rdoc-file=complex.c
|
|
202
|
-
# -
|
|
201
|
+
# - complex ** numeric -> new_complex
|
|
203
202
|
# -->
|
|
204
|
-
# Returns `self` raised to
|
|
203
|
+
# Returns `self` raised to power `numeric`:
|
|
205
204
|
#
|
|
206
205
|
# Complex.rect(0, 1) ** 2 # => (-1+0i)
|
|
207
206
|
# Complex.rect(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
|
|
@@ -210,25 +209,15 @@ class Complex < Numeric
|
|
|
210
209
|
|
|
211
210
|
# <!--
|
|
212
211
|
# rdoc-file=complex.c
|
|
213
|
-
# -
|
|
212
|
+
# - complex + numeric -> new_complex
|
|
214
213
|
# -->
|
|
215
|
-
# Returns the sum of `self` and `
|
|
216
|
-
#
|
|
217
|
-
# Complex(1, 2) + 0 # => (1+2i)
|
|
218
|
-
# Complex(1, 2) + 1 # => (2+2i)
|
|
219
|
-
# Complex(1, 2) + -1 # => (0+2i)
|
|
220
|
-
#
|
|
221
|
-
# Complex(1, 2) + 1.0 # => (2.0+2i)
|
|
214
|
+
# Returns the sum of `self` and `numeric`:
|
|
222
215
|
#
|
|
223
|
-
# Complex(
|
|
224
|
-
# Complex(
|
|
225
|
-
#
|
|
226
|
-
# Complex(
|
|
227
|
-
# Complex(
|
|
228
|
-
#
|
|
229
|
-
# For a computation involving Floats, the result may be inexact (see Float#+):
|
|
230
|
-
#
|
|
231
|
-
# Complex(1, 2) + 3.14 # => (4.140000000000001+2i)
|
|
216
|
+
# Complex.rect(2, 3) + Complex.rect(2, 3) # => (4+6i)
|
|
217
|
+
# Complex.rect(900) + Complex.rect(1) # => (901+0i)
|
|
218
|
+
# Complex.rect(-2, 9) + Complex.rect(-9, 2) # => (-11+11i)
|
|
219
|
+
# Complex.rect(9, 8) + 4 # => (13+8i)
|
|
220
|
+
# Complex.rect(20, 9) + 9.8 # => (29.8+9i)
|
|
232
221
|
#
|
|
233
222
|
def +: (Numeric) -> Complex
|
|
234
223
|
|
|
@@ -236,9 +225,9 @@ class Complex < Numeric
|
|
|
236
225
|
|
|
237
226
|
# <!--
|
|
238
227
|
# rdoc-file=complex.c
|
|
239
|
-
# -
|
|
228
|
+
# - complex - numeric -> new_complex
|
|
240
229
|
# -->
|
|
241
|
-
# Returns the difference of `self` and `
|
|
230
|
+
# Returns the difference of `self` and `numeric`:
|
|
242
231
|
#
|
|
243
232
|
# Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
|
|
244
233
|
# Complex.rect(900) - Complex.rect(1) # => (899+0i)
|
|
@@ -250,9 +239,9 @@ class Complex < Numeric
|
|
|
250
239
|
|
|
251
240
|
# <!--
|
|
252
241
|
# rdoc-file=complex.c
|
|
253
|
-
# - -
|
|
242
|
+
# - -complex -> new_complex
|
|
254
243
|
# -->
|
|
255
|
-
# Returns `self`,
|
|
244
|
+
# Returns the negation of `self`, which is the negation of each of its parts:
|
|
256
245
|
#
|
|
257
246
|
# -Complex.rect(1, 2) # => (-1-2i)
|
|
258
247
|
# -Complex.rect(-1, -2) # => (1+2i)
|
|
@@ -261,9 +250,9 @@ class Complex < Numeric
|
|
|
261
250
|
|
|
262
251
|
# <!--
|
|
263
252
|
# rdoc-file=complex.c
|
|
264
|
-
# -
|
|
253
|
+
# - complex / numeric -> new_complex
|
|
265
254
|
# -->
|
|
266
|
-
# Returns the quotient of `self` and `
|
|
255
|
+
# Returns the quotient of `self` and `numeric`:
|
|
267
256
|
#
|
|
268
257
|
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
|
|
269
258
|
# Complex.rect(900) / Complex.rect(1) # => (900+0i)
|
|
@@ -279,16 +268,15 @@ class Complex < Numeric
|
|
|
279
268
|
|
|
280
269
|
# <!--
|
|
281
270
|
# rdoc-file=complex.c
|
|
282
|
-
# -
|
|
271
|
+
# - complex <=> object -> -1, 0, 1, or nil
|
|
283
272
|
# -->
|
|
284
|
-
# Compares `self` and `other`.
|
|
285
|
-
#
|
|
286
273
|
# Returns:
|
|
287
274
|
#
|
|
288
|
-
# * `self.real <=>
|
|
275
|
+
# * `self.real <=> object.real` if both of the following are true:
|
|
289
276
|
#
|
|
290
277
|
# * `self.imag == 0`.
|
|
291
|
-
# * `
|
|
278
|
+
# * `object.imag == 0`. # Always true if object is numeric but not
|
|
279
|
+
# complex.
|
|
292
280
|
#
|
|
293
281
|
# * `nil` otherwise.
|
|
294
282
|
#
|
|
@@ -301,9 +289,6 @@ class Complex < Numeric
|
|
|
301
289
|
# Complex.rect(1) <=> Complex.rect(1, 1) # => nil # object.imag not zero.
|
|
302
290
|
# Complex.rect(1) <=> 'Foo' # => nil # object.imag not defined.
|
|
303
291
|
#
|
|
304
|
-
# Class Complex includes module Comparable, each of whose methods uses
|
|
305
|
-
# Complex#<=> for comparison.
|
|
306
|
-
#
|
|
307
292
|
def <=>: (untyped) -> Integer?
|
|
308
293
|
|
|
309
294
|
# <!--
|
|
@@ -609,9 +594,9 @@ class Complex < Numeric
|
|
|
609
594
|
|
|
610
595
|
# <!--
|
|
611
596
|
# rdoc-file=complex.c
|
|
612
|
-
# -
|
|
597
|
+
# - complex / numeric -> new_complex
|
|
613
598
|
# -->
|
|
614
|
-
# Returns the quotient of `self` and `
|
|
599
|
+
# Returns the quotient of `self` and `numeric`:
|
|
615
600
|
#
|
|
616
601
|
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
|
|
617
602
|
# Complex.rect(900) / Complex.rect(1) # => (900+0i)
|
data/core/dir.rbs
CHANGED
|
@@ -171,7 +171,7 @@ class Dir
|
|
|
171
171
|
# system's encoding is used:
|
|
172
172
|
#
|
|
173
173
|
# Dir.new('.').read.encoding # => #<Encoding:UTF-8>
|
|
174
|
-
# Dir.new('.', encoding:
|
|
174
|
+
# Dir.new('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
|
|
175
175
|
#
|
|
176
176
|
def initialize: (path dir, ?encoding: encoding?) -> void
|
|
177
177
|
|
|
@@ -477,8 +477,8 @@ class Dir
|
|
|
477
477
|
|
|
478
478
|
# <!--
|
|
479
479
|
# rdoc-file=dir.rb
|
|
480
|
-
# - Dir.glob(patterns, flags: 0, base: nil, sort: true) -> array
|
|
481
|
-
# - Dir.glob(patterns, flags: 0, base: nil, sort: true) {|entry_name| ... } -> nil
|
|
480
|
+
# - Dir.glob(*patterns, flags: 0, base: nil, sort: true) -> array
|
|
481
|
+
# - Dir.glob(*patterns, flags: 0, base: nil, sort: true) {|entry_name| ... } -> nil
|
|
482
482
|
# -->
|
|
483
483
|
# Forms an array *entry_names* of the entry names selected by the arguments.
|
|
484
484
|
#
|
|
@@ -704,7 +704,7 @@ class Dir
|
|
|
704
704
|
# system's encoding is used:
|
|
705
705
|
#
|
|
706
706
|
# Dir.open('.').read.encoding # => #<Encoding:UTF-8>
|
|
707
|
-
# Dir.open('.', encoding:
|
|
707
|
+
# Dir.open('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
|
|
708
708
|
#
|
|
709
709
|
def self.open: (path dirname, ?encoding: encoding?) -> instance
|
|
710
710
|
| [U] (path dirname, ?encoding: encoding?) { (instance) -> U } -> U
|
data/core/encoding.rbs
CHANGED
|
@@ -281,7 +281,7 @@ class Encoding
|
|
|
281
281
|
def inspect: () -> String
|
|
282
282
|
|
|
283
283
|
# <!-- rdoc-file=encoding.c -->
|
|
284
|
-
#
|
|
284
|
+
# Returns the name of the encoding.
|
|
285
285
|
#
|
|
286
286
|
# Encoding::UTF_8.name #=> "UTF-8"
|
|
287
287
|
#
|
|
@@ -297,8 +297,12 @@ class Encoding
|
|
|
297
297
|
#
|
|
298
298
|
def names: () -> Array[String]
|
|
299
299
|
|
|
300
|
-
# <!--
|
|
301
|
-
#
|
|
300
|
+
# <!--
|
|
301
|
+
# rdoc-file=encoding.c
|
|
302
|
+
# - enc.name -> string
|
|
303
|
+
# - enc.to_s -> string
|
|
304
|
+
# -->
|
|
305
|
+
# Returns the name of the encoding.
|
|
302
306
|
#
|
|
303
307
|
# Encoding::UTF_8.name #=> "UTF-8"
|
|
304
308
|
#
|
|
@@ -919,9 +923,8 @@ class Encoding::Converter < Object
|
|
|
919
923
|
# p ec.primitive_convert(src, dst, nil, 1) #=> :destination_buffer_full
|
|
920
924
|
# p ec.last_error #=> nil
|
|
921
925
|
#
|
|
922
|
-
def last_error: () ->
|
|
923
|
-
|
|
924
|
-
| nil )
|
|
926
|
+
def last_error: () -> Encoding::InvalidByteSequenceError?
|
|
927
|
+
| () -> Encoding::UndefinedConversionError?
|
|
925
928
|
|
|
926
929
|
# <!--
|
|
927
930
|
# rdoc-file=transcode.c
|