rbs 3.5.3 → 3.6.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/dependabot.yml +5 -1
- data/.github/workflows/ruby.yml +2 -18
- data/.github/workflows/windows.yml +26 -0
- data/CHANGELOG.md +0 -18
- data/core/array.rbs +10 -10
- data/core/basic_object.rbs +3 -3
- data/core/enumerable.rbs +6 -0
- data/core/enumerator.rbs +7 -0
- data/core/fiber.rbs +1 -1
- data/core/global_variables.rbs +2 -2
- data/core/kernel.rbs +67 -38
- data/core/method.rbs +98 -7
- data/core/module.rbs +2 -2
- data/core/proc.rbs +184 -23
- data/core/ractor.rbs +1 -1
- data/core/range.rbs +30 -0
- data/core/refinement.rbs +16 -26
- data/core/symbol.rbs +34 -26
- data/core/thread.rbs +2 -2
- data/core/trace_point.rbs +12 -12
- data/core/unbound_method.rbs +1 -1
- data/docs/syntax.md +21 -9
- data/ext/rbs_extension/parser.c +119 -51
- data/ext/rbs_extension/ruby_objs.c +2 -1
- data/ext/rbs_extension/ruby_objs.h +1 -1
- data/lib/rbs/ast/declarations.rb +36 -0
- data/lib/rbs/ast/type_param.rb +71 -15
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/cli/validate.rb +41 -7
- data/lib/rbs/cli.rb +3 -3
- data/lib/rbs/definition.rb +2 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +30 -4
- data/lib/rbs/definition_builder.rb +21 -6
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/errors.rb +7 -2
- data/lib/rbs/file_finder.rb +9 -12
- data/lib/rbs/locator.rb +8 -5
- data/lib/rbs/prototype/rbi.rb +2 -1
- data/lib/rbs/prototype/runtime.rb +3 -2
- data/lib/rbs/sorter.rb +9 -6
- data/lib/rbs/test/type_check.rb +6 -0
- data/lib/rbs/types.rb +11 -0
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/vendorer.rb +3 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -0
- data/sig/declarations.rbs +6 -0
- data/sig/definition.rbs +1 -1
- data/sig/definition_builder.rbs +3 -1
- data/sig/errors.rbs +3 -2
- data/sig/file_finder.rbs +24 -2
- data/sig/method_types.rbs +1 -1
- data/sig/sorter.rbs +1 -1
- data/sig/type_param.rbs +41 -9
- data/sig/types.rbs +12 -0
- data/sig/visitor.rbs +47 -0
- data/stdlib/csv/0/csv.rbs +27 -0
- data/stdlib/net-http/0/net-http.rbs +1 -1
- data/stdlib/zlib/0/gzip_reader.rbs +5 -1
- metadata +5 -2
data/core/method.rbs
CHANGED
@@ -22,9 +22,100 @@
|
|
22
22
|
# %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
|
23
23
|
# #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
|
24
24
|
#
|
25
|
-
class Method
|
25
|
+
class Method
|
26
|
+
# The return type from `#parameters` methods (such as those defined on `Method`, `Proc`, and `UnboundMethod`).
|
26
27
|
type param_types = Array[[:req | :opt | :rest | :keyreq | :key | :keyrest | :block, Symbol] | [:rest | :keyrest | :nokey]]
|
27
28
|
|
29
|
+
# <!--
|
30
|
+
# rdoc-file=proc.c
|
31
|
+
# - meth.eql?(other_meth) -> true or false
|
32
|
+
# - meth == other_meth -> true or false
|
33
|
+
# -->
|
34
|
+
# Two method objects are equal if they are bound to the same object and refer to
|
35
|
+
# the same method definition and the classes defining the methods are the same
|
36
|
+
# class or module.
|
37
|
+
#
|
38
|
+
def ==: (untyped other) -> bool
|
39
|
+
|
40
|
+
# <!-- rdoc-file=proc.c -->
|
41
|
+
# Two method objects are equal if they are bound to the same object and refer to
|
42
|
+
# the same method definition and the classes defining the methods are the same
|
43
|
+
# class or module.
|
44
|
+
#
|
45
|
+
alias eql? ==
|
46
|
+
|
47
|
+
# <!--
|
48
|
+
# rdoc-file=proc.c
|
49
|
+
# - meth.hash -> integer
|
50
|
+
# -->
|
51
|
+
# Returns a hash value corresponding to the method object.
|
52
|
+
#
|
53
|
+
# See also Object#hash.
|
54
|
+
#
|
55
|
+
def hash: () -> Integer
|
56
|
+
|
57
|
+
def dup: () -> instance
|
58
|
+
|
59
|
+
# <!--
|
60
|
+
# rdoc-file=proc.c
|
61
|
+
# - meth.to_s -> string
|
62
|
+
# - meth.inspect -> string
|
63
|
+
# -->
|
64
|
+
# Returns a human-readable description of the underlying method.
|
65
|
+
#
|
66
|
+
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
67
|
+
# (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map()>"
|
68
|
+
#
|
69
|
+
# In the latter case, the method description includes the "owner" of the
|
70
|
+
# original method (`Enumerable` module, which is included into `Range`).
|
71
|
+
#
|
72
|
+
# `inspect` also provides, when possible, method argument names (call sequence)
|
73
|
+
# and source location.
|
74
|
+
#
|
75
|
+
# require 'net/http'
|
76
|
+
# Net::HTTP.method(:get).inspect
|
77
|
+
# #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
|
78
|
+
#
|
79
|
+
# `...` in argument definition means argument is optional (has some default
|
80
|
+
# value).
|
81
|
+
#
|
82
|
+
# For methods defined in C (language core and extensions), location and argument
|
83
|
+
# names can't be extracted, and only generic information is provided in form of
|
84
|
+
# `*` (any number of arguments) or `_` (some positional argument).
|
85
|
+
#
|
86
|
+
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
87
|
+
# "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
|
88
|
+
#
|
89
|
+
def inspect: () -> String
|
90
|
+
|
91
|
+
# <!-- rdoc-file=proc.c -->
|
92
|
+
# Returns a human-readable description of the underlying method.
|
93
|
+
#
|
94
|
+
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
95
|
+
# (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map()>"
|
96
|
+
#
|
97
|
+
# In the latter case, the method description includes the "owner" of the
|
98
|
+
# original method (`Enumerable` module, which is included into `Range`).
|
99
|
+
#
|
100
|
+
# `inspect` also provides, when possible, method argument names (call sequence)
|
101
|
+
# and source location.
|
102
|
+
#
|
103
|
+
# require 'net/http'
|
104
|
+
# Net::HTTP.method(:get).inspect
|
105
|
+
# #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
|
106
|
+
#
|
107
|
+
# `...` in argument definition means argument is optional (has some default
|
108
|
+
# value).
|
109
|
+
#
|
110
|
+
# For methods defined in C (language core and extensions), location and argument
|
111
|
+
# names can't be extracted, and only generic information is provided in form of
|
112
|
+
# `*` (any number of arguments) or `_` (some positional argument).
|
113
|
+
#
|
114
|
+
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
115
|
+
# "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
|
116
|
+
#
|
117
|
+
alias to_s inspect
|
118
|
+
|
28
119
|
# <!--
|
29
120
|
# rdoc-file=proc.c
|
30
121
|
# - meth.to_proc -> proc
|
@@ -44,7 +135,7 @@ class Method < Object
|
|
44
135
|
# m.call(3) #=> 15
|
45
136
|
# m.call(20) #=> 32
|
46
137
|
#
|
47
|
-
def call: (
|
138
|
+
def call: (?) -> untyped
|
48
139
|
|
49
140
|
# <!--
|
50
141
|
# rdoc-file=proc.c
|
@@ -62,7 +153,7 @@ class Method < Object
|
|
62
153
|
# g = proc {|x| x + x }
|
63
154
|
# p (f << g).call(2) #=> 16
|
64
155
|
#
|
65
|
-
def <<: (Proc g) -> Proc
|
156
|
+
def <<: (Proc::_Callable g) -> Proc
|
66
157
|
|
67
158
|
# <!-- rdoc-file=proc.c -->
|
68
159
|
# Invokes the *meth* with the specified arguments, returning the method's return
|
@@ -90,7 +181,7 @@ class Method < Object
|
|
90
181
|
# g = proc {|x| x + x }
|
91
182
|
# p (f >> g).call(2) #=> 8
|
92
183
|
#
|
93
|
-
def >>: (Proc g) -> Proc
|
184
|
+
def >>: (Proc::_Callable g) -> Proc
|
94
185
|
|
95
186
|
# <!-- rdoc-file=proc.c -->
|
96
187
|
# Invokes the *meth* with the specified arguments, returning the method's return
|
@@ -161,7 +252,7 @@ class Method < Object
|
|
161
252
|
# m.call # => "bar"
|
162
253
|
# n = m.clone.call # => "bar"
|
163
254
|
#
|
164
|
-
def clone: () ->
|
255
|
+
def clone: () -> instance
|
165
256
|
|
166
257
|
# <!--
|
167
258
|
# rdoc-file=proc.c
|
@@ -194,7 +285,7 @@ class Method < Object
|
|
194
285
|
# proc3 = proc2.call(:y, :z) #=> #<Proc>
|
195
286
|
# proc3.call(:a) #=> [:x, :y, :z, :a]
|
196
287
|
#
|
197
|
-
def curry: (?
|
288
|
+
def curry: (?int? arity) -> Proc
|
198
289
|
|
199
290
|
# <!--
|
200
291
|
# rdoc-file=proc.c
|
@@ -273,7 +364,7 @@ class Method < Object
|
|
273
364
|
# Returns the Ruby source filename and line number containing this method or nil
|
274
365
|
# if this method was not defined in Ruby (i.e. native).
|
275
366
|
#
|
276
|
-
def source_location: () -> [
|
367
|
+
def source_location: () -> [String, Integer]?
|
277
368
|
|
278
369
|
# <!--
|
279
370
|
# rdoc-file=proc.c
|
data/core/module.rbs
CHANGED
@@ -396,7 +396,7 @@ class Module < Object
|
|
396
396
|
#
|
397
397
|
# Hello there!
|
398
398
|
#
|
399
|
-
def class_exec: [U] (*untyped
|
399
|
+
def class_exec: [U] (*untyped, **untyped) { (?) [self: self] -> U } -> U
|
400
400
|
|
401
401
|
# <!--
|
402
402
|
# rdoc-file=object.c
|
@@ -1106,7 +1106,7 @@ class Module < Object
|
|
1106
1106
|
#
|
1107
1107
|
# Hello there!
|
1108
1108
|
#
|
1109
|
-
def module_exec: [U] (*untyped
|
1109
|
+
def module_exec: [U] (*untyped, **untyped) { (?) [self: self] -> U } -> U
|
1110
1110
|
|
1111
1111
|
# <!--
|
1112
1112
|
# rdoc-file=vm_method.c
|
data/core/proc.rbs
CHANGED
@@ -288,8 +288,184 @@
|
|
288
288
|
#
|
289
289
|
# Numbered parameters were introduced in Ruby 2.7.
|
290
290
|
#
|
291
|
-
class Proc
|
292
|
-
|
291
|
+
class Proc
|
292
|
+
interface _Callable
|
293
|
+
def call: (?) -> untyped
|
294
|
+
end
|
295
|
+
|
296
|
+
# <!--
|
297
|
+
# rdoc-file=proc.c
|
298
|
+
# - Proc.new {|...| block } -> a_proc
|
299
|
+
# -->
|
300
|
+
# Creates a new Proc object, bound to the current context.
|
301
|
+
#
|
302
|
+
# proc = Proc.new { "hello" }
|
303
|
+
# proc.call #=> "hello"
|
304
|
+
#
|
305
|
+
# Raises ArgumentError if called without a block.
|
306
|
+
#
|
307
|
+
# Proc.new #=> ArgumentError
|
308
|
+
#
|
309
|
+
def self.new: () { (?) -> untyped } -> instance
|
310
|
+
|
311
|
+
def clone: () -> instance
|
312
|
+
def dup: () -> instance
|
313
|
+
|
314
|
+
# <!-- rdoc-file=proc.c -->
|
315
|
+
# Invokes the block, setting the block's parameters to the values in *params*
|
316
|
+
# using something close to method calling semantics. Returns the value of the
|
317
|
+
# last expression evaluated in the block.
|
318
|
+
#
|
319
|
+
# a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
|
320
|
+
# a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
|
321
|
+
# a_proc[9, 1, 2, 3] #=> [9, 18, 27]
|
322
|
+
# a_proc.(9, 1, 2, 3) #=> [9, 18, 27]
|
323
|
+
# a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27]
|
324
|
+
#
|
325
|
+
# Note that `prc.()` invokes `prc.call()` with the parameters given. It's
|
326
|
+
# syntactic sugar to hide "call".
|
327
|
+
#
|
328
|
+
# For procs created using #lambda or `->()` an error is generated if the wrong
|
329
|
+
# number of parameters are passed to the proc. For procs created using Proc.new
|
330
|
+
# or Kernel.proc, extra parameters are silently discarded and missing parameters
|
331
|
+
# are set to `nil`.
|
332
|
+
#
|
333
|
+
# a_proc = proc {|a,b| [a,b] }
|
334
|
+
# a_proc.call(1) #=> [1, nil]
|
335
|
+
#
|
336
|
+
# a_proc = lambda {|a,b| [a,b] }
|
337
|
+
# a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
|
338
|
+
#
|
339
|
+
# See also Proc#lambda?.
|
340
|
+
#
|
341
|
+
alias === call
|
342
|
+
|
343
|
+
# <!-- rdoc-file=proc.c -->
|
344
|
+
# Invokes the block, setting the block's parameters to the values in *params*
|
345
|
+
# using something close to method calling semantics. Returns the value of the
|
346
|
+
# last expression evaluated in the block.
|
347
|
+
#
|
348
|
+
# a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
|
349
|
+
# a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
|
350
|
+
# a_proc[9, 1, 2, 3] #=> [9, 18, 27]
|
351
|
+
# a_proc.(9, 1, 2, 3) #=> [9, 18, 27]
|
352
|
+
# a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27]
|
353
|
+
#
|
354
|
+
# Note that `prc.()` invokes `prc.call()` with the parameters given. It's
|
355
|
+
# syntactic sugar to hide "call".
|
356
|
+
#
|
357
|
+
# For procs created using #lambda or `->()` an error is generated if the wrong
|
358
|
+
# number of parameters are passed to the proc. For procs created using Proc.new
|
359
|
+
# or Kernel.proc, extra parameters are silently discarded and missing parameters
|
360
|
+
# are set to `nil`.
|
361
|
+
#
|
362
|
+
# a_proc = proc {|a,b| [a,b] }
|
363
|
+
# a_proc.call(1) #=> [1, nil]
|
364
|
+
#
|
365
|
+
# a_proc = lambda {|a,b| [a,b] }
|
366
|
+
# a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2)
|
367
|
+
#
|
368
|
+
# See also Proc#lambda?.
|
369
|
+
#
|
370
|
+
alias yield call
|
371
|
+
|
372
|
+
# <!--
|
373
|
+
# rdoc-file=proc.c
|
374
|
+
# - prc << g -> a_proc
|
375
|
+
# -->
|
376
|
+
# Returns a proc that is the composition of this proc and the given *g*. The
|
377
|
+
# returned proc takes a variable number of arguments, calls *g* with them then
|
378
|
+
# calls this proc with the result.
|
379
|
+
#
|
380
|
+
# f = proc {|x| x * x }
|
381
|
+
# g = proc {|x| x + x }
|
382
|
+
# p (f << g).call(2) #=> 16
|
383
|
+
#
|
384
|
+
# See Proc#>> for detailed explanations.
|
385
|
+
#
|
386
|
+
def <<: (_Callable callable) -> Proc
|
387
|
+
|
388
|
+
# <!--
|
389
|
+
# rdoc-file=proc.c
|
390
|
+
# - prc >> g -> a_proc
|
391
|
+
# -->
|
392
|
+
# Returns a proc that is the composition of this proc and the given *g*. The
|
393
|
+
# returned proc takes a variable number of arguments, calls this proc with them
|
394
|
+
# then calls *g* with the result.
|
395
|
+
#
|
396
|
+
# f = proc {|x| x * x }
|
397
|
+
# g = proc {|x| x + x }
|
398
|
+
# p (f >> g).call(2) #=> 8
|
399
|
+
#
|
400
|
+
# *g* could be other Proc, or Method, or any other object responding to `call`
|
401
|
+
# method:
|
402
|
+
#
|
403
|
+
# class Parser
|
404
|
+
# def self.call(text)
|
405
|
+
# # ...some complicated parsing logic...
|
406
|
+
# end
|
407
|
+
# end
|
408
|
+
#
|
409
|
+
# pipeline = File.method(:read) >> Parser >> proc { |data| puts "data size: #{data.count}" }
|
410
|
+
# pipeline.call('data.json')
|
411
|
+
#
|
412
|
+
# See also Method#>> and Method#<<.
|
413
|
+
#
|
414
|
+
def >>: (_Callable callable) -> Proc
|
415
|
+
|
416
|
+
# <!--
|
417
|
+
# rdoc-file=proc.c
|
418
|
+
# - prc == other -> true or false
|
419
|
+
# - prc.eql?(other) -> true or false
|
420
|
+
# -->
|
421
|
+
# Two procs are the same if, and only if, they were created from the same code
|
422
|
+
# block.
|
423
|
+
#
|
424
|
+
# def return_block(&block)
|
425
|
+
# block
|
426
|
+
# end
|
427
|
+
#
|
428
|
+
# def pass_block_twice(&block)
|
429
|
+
# [return_block(&block), return_block(&block)]
|
430
|
+
# end
|
431
|
+
#
|
432
|
+
# block1, block2 = pass_block_twice { puts 'test' }
|
433
|
+
# # Blocks might be instantiated into Proc's lazily, so they may, or may not,
|
434
|
+
# # be the same object.
|
435
|
+
# # But they are produced from the same code block, so they are equal
|
436
|
+
# block1 == block2
|
437
|
+
# #=> true
|
438
|
+
#
|
439
|
+
# # Another Proc will never be equal, even if the code is the "same"
|
440
|
+
# block1 == proc { puts 'test' }
|
441
|
+
# #=> false
|
442
|
+
#
|
443
|
+
def ==: (untyped other) -> bool
|
444
|
+
|
445
|
+
# <!-- rdoc-file=proc.c -->
|
446
|
+
# Two procs are the same if, and only if, they were created from the same code
|
447
|
+
# block.
|
448
|
+
#
|
449
|
+
# def return_block(&block)
|
450
|
+
# block
|
451
|
+
# end
|
452
|
+
#
|
453
|
+
# def pass_block_twice(&block)
|
454
|
+
# [return_block(&block), return_block(&block)]
|
455
|
+
# end
|
456
|
+
#
|
457
|
+
# block1, block2 = pass_block_twice { puts 'test' }
|
458
|
+
# # Blocks might be instantiated into Proc's lazily, so they may, or may not,
|
459
|
+
# # be the same object.
|
460
|
+
# # But they are produced from the same code block, so they are equal
|
461
|
+
# block1 == block2
|
462
|
+
# #=> true
|
463
|
+
#
|
464
|
+
# # Another Proc will never be equal, even if the code is the "same"
|
465
|
+
# block1 == proc { puts 'test' }
|
466
|
+
# #=> false
|
467
|
+
#
|
468
|
+
alias eql? ==
|
293
469
|
|
294
470
|
# <!--
|
295
471
|
# rdoc-file=proc.c
|
@@ -379,7 +555,7 @@ class Proc < Object
|
|
379
555
|
#
|
380
556
|
# See also Proc#lambda?.
|
381
557
|
#
|
382
|
-
def call: (
|
558
|
+
def call: (?) -> untyped
|
383
559
|
|
384
560
|
# <!-- rdoc-file=proc.c -->
|
385
561
|
# Invokes the block, setting the block's parameters to the values in *params*
|
@@ -408,7 +584,7 @@ class Proc < Object
|
|
408
584
|
#
|
409
585
|
# See also Proc#lambda?.
|
410
586
|
#
|
411
|
-
|
587
|
+
alias [] call
|
412
588
|
|
413
589
|
# <!--
|
414
590
|
# rdoc-file=proc.c
|
@@ -455,7 +631,7 @@ class Proc < Object
|
|
455
631
|
# b = proc { :foo }
|
456
632
|
# p b.curry[] #=> :foo
|
457
633
|
#
|
458
|
-
def curry: (?
|
634
|
+
def curry: (?int? arity) -> Proc
|
459
635
|
|
460
636
|
# <!--
|
461
637
|
# rdoc-file=proc.c
|
@@ -467,21 +643,6 @@ class Proc < Object
|
|
467
643
|
#
|
468
644
|
def hash: () -> Integer
|
469
645
|
|
470
|
-
# <!--
|
471
|
-
# rdoc-file=proc.c
|
472
|
-
# - Proc.new {|...| block } -> a_proc
|
473
|
-
# -->
|
474
|
-
# Creates a new Proc object, bound to the current context.
|
475
|
-
#
|
476
|
-
# proc = Proc.new { "hello" }
|
477
|
-
# proc.call #=> "hello"
|
478
|
-
#
|
479
|
-
# Raises ArgumentError if called without a block.
|
480
|
-
#
|
481
|
-
# Proc.new #=> ArgumentError
|
482
|
-
#
|
483
|
-
def initialize: () { (*untyped) -> untyped } -> void
|
484
|
-
|
485
646
|
# <!--
|
486
647
|
# rdoc-file=proc.c
|
487
648
|
# - prc.lambda? -> true or false
|
@@ -602,7 +763,7 @@ class Proc < Object
|
|
602
763
|
# prc = lambda{|x, y=42, *other|}
|
603
764
|
# prc.parameters(lambda: false) #=> [[:opt, :x], [:opt, :y], [:rest, :other]]
|
604
765
|
#
|
605
|
-
def parameters: (?lambda: boolish) -> ::
|
766
|
+
def parameters: (?lambda: boolish) -> Method::param_types
|
606
767
|
|
607
768
|
# <!--
|
608
769
|
# rdoc-file=proc.c
|
@@ -611,7 +772,7 @@ class Proc < Object
|
|
611
772
|
# Returns the Ruby source filename and line number containing this proc or `nil`
|
612
773
|
# if this proc was not defined in Ruby (i.e. native).
|
613
774
|
#
|
614
|
-
def source_location: () -> [
|
775
|
+
def source_location: () -> [String, Integer]?
|
615
776
|
|
616
777
|
# <!--
|
617
778
|
# rdoc-file=proc.c
|
@@ -635,5 +796,5 @@ class Proc < Object
|
|
635
796
|
# Returns the unique identifier for this proc, along with an indication of where
|
636
797
|
# the proc was defined.
|
637
798
|
#
|
638
|
-
|
799
|
+
alias inspect to_s
|
639
800
|
end
|
data/core/ractor.rbs
CHANGED
@@ -355,7 +355,7 @@ class Ractor
|
|
355
355
|
# p r
|
356
356
|
# #=> #<Ractor:#3 my ractor test.rb:1 terminated>
|
357
357
|
#
|
358
|
-
def self.new: (*untyped args, ?name: string) { (
|
358
|
+
def self.new: (*untyped args, ?name: string) { (?) -> untyped } -> Ractor
|
359
359
|
|
360
360
|
# <!--
|
361
361
|
# rdoc-file=ractor.rb
|
data/core/range.rbs
CHANGED
@@ -243,6 +243,36 @@
|
|
243
243
|
class Range[out Elem] < Object
|
244
244
|
include Enumerable[Elem]
|
245
245
|
|
246
|
+
# <!--
|
247
|
+
# rdoc-file=range.c
|
248
|
+
# - %(n) {|element| ... } -> self
|
249
|
+
# - %(n) -> enumerator
|
250
|
+
# -->
|
251
|
+
# Iterates over the elements of `self`.
|
252
|
+
#
|
253
|
+
# With a block given, calls the block with selected elements of the range;
|
254
|
+
# returns `self`:
|
255
|
+
#
|
256
|
+
# a = []
|
257
|
+
# (1..5).%(2) {|element| a.push(element) } # => 1..5
|
258
|
+
# a # => [1, 3, 5]
|
259
|
+
# a = []
|
260
|
+
# ('a'..'e').%(2) {|element| a.push(element) } # => "a".."e"
|
261
|
+
# a # => ["a", "c", "e"]
|
262
|
+
#
|
263
|
+
# With no block given, returns an enumerator, which will be of class
|
264
|
+
# Enumerator::ArithmeticSequence if `self` is numeric; otherwise of class
|
265
|
+
# Enumerator:
|
266
|
+
#
|
267
|
+
# e = (1..5) % 2 # => ((1..5).%(2))
|
268
|
+
# e.class # => Enumerator::ArithmeticSequence
|
269
|
+
# ('a'..'e') % 2 # => #<Enumerator: ...>
|
270
|
+
#
|
271
|
+
# Related: Range#step.
|
272
|
+
#
|
273
|
+
def %: (Numeric | int n) -> Enumerator[Elem, self]
|
274
|
+
| (Numeric | int n) { (Elem element) -> void } -> self
|
275
|
+
|
246
276
|
# <!--
|
247
277
|
# rdoc-file=range.c
|
248
278
|
# - self == other -> true or false
|
data/core/refinement.rbs
CHANGED
@@ -4,6 +4,21 @@
|
|
4
4
|
# #import_methods.
|
5
5
|
#
|
6
6
|
class Refinement < Module
|
7
|
+
# <!--
|
8
|
+
# rdoc-file=eval.c
|
9
|
+
# - target -> class_or_module
|
10
|
+
# -->
|
11
|
+
# Return the class or module refined by the receiver.
|
12
|
+
#
|
13
|
+
# module M
|
14
|
+
# refine String do
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# M.refinements[0].target # => String
|
19
|
+
#
|
20
|
+
def target: () -> Module?
|
21
|
+
|
7
22
|
private
|
8
23
|
|
9
24
|
# <!--
|
@@ -40,30 +55,5 @@ class Refinement < Module
|
|
40
55
|
# end
|
41
56
|
# end
|
42
57
|
#
|
43
|
-
def import_methods: (*Module) -> self
|
44
|
-
|
45
|
-
# <!--
|
46
|
-
# rdoc-file=eval.c
|
47
|
-
# - refined_class -> class
|
48
|
-
# -->
|
49
|
-
# Deprecated; prefer #target.
|
50
|
-
#
|
51
|
-
# Return the class refined by the receiver.
|
52
|
-
#
|
53
|
-
def refined_class: () -> Module
|
54
|
-
|
55
|
-
# <!--
|
56
|
-
# rdoc-file=eval.c
|
57
|
-
# - target -> class_or_module
|
58
|
-
# -->
|
59
|
-
# Return the class or module refined by the receiver.
|
60
|
-
#
|
61
|
-
# module M
|
62
|
-
# refine String do
|
63
|
-
# end
|
64
|
-
# end
|
65
|
-
#
|
66
|
-
# M.refinements[0].target # => String
|
67
|
-
#
|
68
|
-
def target: () -> Module
|
58
|
+
def import_methods: (Module module, *Module extra_modules) -> self
|
69
59
|
end
|
data/core/symbol.rbs
CHANGED
@@ -131,9 +131,7 @@ class Symbol
|
|
131
131
|
# Symbol.all_symbols.size # => 9334
|
132
132
|
# Symbol.all_symbols.take(3) # => [:!, :"\"", :"#"]
|
133
133
|
#
|
134
|
-
def self.all_symbols: () ->
|
135
|
-
|
136
|
-
public
|
134
|
+
def self.all_symbols: () -> Array[Symbol]
|
137
135
|
|
138
136
|
# <!--
|
139
137
|
# rdoc-file=string.c
|
@@ -152,8 +150,8 @@ class Symbol
|
|
152
150
|
#
|
153
151
|
# Related: String#<=>.
|
154
152
|
#
|
155
|
-
def <=>: (Symbol
|
156
|
-
| (untyped
|
153
|
+
def <=>: (Symbol object) -> (-1 | 0 | 1)
|
154
|
+
| (untyped) -> (-1 | 0 | 1)?
|
157
155
|
|
158
156
|
# <!--
|
159
157
|
# rdoc-file=string.c
|
@@ -161,12 +159,12 @@ class Symbol
|
|
161
159
|
# -->
|
162
160
|
# Returns `true` if `object` is the same object as `self`, `false` otherwise.
|
163
161
|
#
|
164
|
-
def ==: (untyped
|
162
|
+
def ==: (untyped object) -> bool
|
165
163
|
|
166
164
|
# <!-- rdoc-file=string.c -->
|
167
165
|
# Returns `true` if `object` is the same object as `self`, `false` otherwise.
|
168
166
|
#
|
169
|
-
|
167
|
+
alias === ==
|
170
168
|
|
171
169
|
# <!--
|
172
170
|
# rdoc-file=string.c
|
@@ -176,7 +174,7 @@ class Symbol
|
|
176
174
|
# variables; see String#=~.
|
177
175
|
#
|
178
176
|
def =~: (Regexp regex) -> Integer?
|
179
|
-
| [T] (String::_MatchAgainst[
|
177
|
+
| [T] (String::_MatchAgainst[String, T] object) -> T
|
180
178
|
|
181
179
|
# <!--
|
182
180
|
# rdoc-file=string.c
|
@@ -188,12 +186,10 @@ class Symbol
|
|
188
186
|
# -->
|
189
187
|
# Equivalent to `symbol.to_s[]`; see String#[].
|
190
188
|
#
|
191
|
-
def []: (int
|
192
|
-
| (int
|
193
|
-
| (
|
194
|
-
| (
|
195
|
-
| (Regexp regexp, int | String capture) -> String?
|
196
|
-
| (String match_str) -> String?
|
189
|
+
def []: (int start, ?int length) -> String?
|
190
|
+
| (range[int?] range) -> String?
|
191
|
+
| (Regexp regexp, ?MatchData::capture backref) -> String?
|
192
|
+
| (String substring) -> String?
|
197
193
|
|
198
194
|
# <!--
|
199
195
|
# rdoc-file=string.c
|
@@ -240,7 +236,7 @@ class Symbol
|
|
240
236
|
#
|
241
237
|
# Related: Symbol#casecmp?, String#casecmp.
|
242
238
|
#
|
243
|
-
def casecmp: (untyped
|
239
|
+
def casecmp: (untyped object) -> (-1 | 0 | 1)?
|
244
240
|
|
245
241
|
# <!--
|
246
242
|
# rdoc-file=string.c
|
@@ -273,7 +269,7 @@ class Symbol
|
|
273
269
|
#
|
274
270
|
# Related: Symbol#casecmp, String#casecmp?.
|
275
271
|
#
|
276
|
-
def casecmp?: (untyped
|
272
|
+
def casecmp?: (untyped object) -> bool?
|
277
273
|
|
278
274
|
# <!--
|
279
275
|
# rdoc-file=string.c
|
@@ -321,7 +317,7 @@ class Symbol
|
|
321
317
|
#
|
322
318
|
# Related: Symbol#inspect, Symbol#name.
|
323
319
|
#
|
324
|
-
|
320
|
+
alias id2name to_s
|
325
321
|
|
326
322
|
# <!--
|
327
323
|
# rdoc-file=string.c
|
@@ -340,7 +336,7 @@ class Symbol
|
|
340
336
|
# - intern()
|
341
337
|
# -->
|
342
338
|
#
|
343
|
-
|
339
|
+
alias intern to_sym
|
344
340
|
|
345
341
|
# <!--
|
346
342
|
# rdoc-file=string.c
|
@@ -358,8 +354,8 @@ class Symbol
|
|
358
354
|
# Equivalent to `self.to_s.match`, including possible updates to global
|
359
355
|
# variables; see String#match.
|
360
356
|
#
|
361
|
-
def match: (Regexp | string pattern, ?int
|
362
|
-
| (Regexp | string pattern, ?int
|
357
|
+
def match: (Regexp | string pattern, ?int offset) -> MatchData?
|
358
|
+
| [T] (Regexp | string pattern, ?int offset) { (MatchData matchdata) -> T } -> T?
|
363
359
|
|
364
360
|
# <!--
|
365
361
|
# rdoc-file=string.c
|
@@ -367,7 +363,7 @@ class Symbol
|
|
367
363
|
# -->
|
368
364
|
# Equivalent to `sym.to_s.match?`; see String#match.
|
369
365
|
#
|
370
|
-
def match?: (Regexp | string pattern, ?int
|
366
|
+
def match?: (Regexp | string pattern, ?int offset) -> bool
|
371
367
|
|
372
368
|
# <!-- rdoc-file=string.c -->
|
373
369
|
# Equivalent to `self.to_s.succ.to_sym`:
|
@@ -378,6 +374,20 @@ class Symbol
|
|
378
374
|
#
|
379
375
|
def next: () -> Symbol
|
380
376
|
|
377
|
+
# <!--
|
378
|
+
# rdoc-file=string.c
|
379
|
+
# - name -> string
|
380
|
+
# -->
|
381
|
+
# Returns a frozen string representation of `self` (not including the leading
|
382
|
+
# colon):
|
383
|
+
#
|
384
|
+
# :foo.name # => "foo"
|
385
|
+
# :foo.name.frozen? # => true
|
386
|
+
#
|
387
|
+
# Related: Symbol#to_s, Symbol#inspect.
|
388
|
+
#
|
389
|
+
def name: () -> String
|
390
|
+
|
381
391
|
# <!-- rdoc-file=string.c -->
|
382
392
|
# Equivalent to `self.to_s.length`; see String#length.
|
383
393
|
#
|
@@ -394,7 +404,7 @@ class Symbol
|
|
394
404
|
# -->
|
395
405
|
# Equivalent to `self.to_s.start_with?`; see String#start_with?.
|
396
406
|
#
|
397
|
-
def start_with?: (*
|
407
|
+
def start_with?: (*Regexp | string prefixes) -> bool
|
398
408
|
|
399
409
|
# <!--
|
400
410
|
# rdoc-file=string.c
|
@@ -445,7 +455,7 @@ class Symbol
|
|
445
455
|
#
|
446
456
|
# Related: Symbol#inspect, Symbol#name.
|
447
457
|
#
|
448
|
-
|
458
|
+
def to_s: () -> String
|
449
459
|
|
450
460
|
# <!--
|
451
461
|
# rdoc-file=symbol.rb
|
@@ -455,7 +465,7 @@ class Symbol
|
|
455
465
|
#
|
456
466
|
# Related: String#to_sym.
|
457
467
|
#
|
458
|
-
|
468
|
+
def to_sym: () -> self
|
459
469
|
|
460
470
|
# <!--
|
461
471
|
# rdoc-file=string.c
|
@@ -469,6 +479,4 @@ class Symbol
|
|
469
479
|
| (:ascii | :lithuanian | :turkic) -> Symbol
|
470
480
|
| (:lithuanian, :turkic) -> Symbol
|
471
481
|
| (:turkic, :lithuanian) -> Symbol
|
472
|
-
|
473
|
-
def clone: (?freeze: true?) -> self
|
474
482
|
end
|