rbs 3.5.3 → 3.6.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- 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/.rubocop.yml +28 -1
- data/CHANGELOG.md +58 -0
- data/Rakefile +8 -2
- data/core/array.rbs +10 -10
- data/core/basic_object.rbs +4 -4
- data/core/builtin.rbs +4 -4
- data/core/dir.rbs +1 -1
- data/core/enumerable.rbs +17 -11
- data/core/enumerator/product.rbs +1 -1
- data/core/enumerator.rbs +9 -2
- data/core/errors.rbs +1 -1
- data/core/exception.rbs +1 -1
- data/core/fiber.rbs +1 -1
- data/core/file.rbs +1 -1
- data/core/global_variables.rbs +2 -2
- data/core/integer.rbs +4 -4
- data/core/kernel.rbs +69 -40
- data/core/method.rbs +98 -7
- data/core/module.rbs +3 -3
- data/core/proc.rbs +184 -23
- data/core/ractor.rbs +1 -1
- data/core/random.rbs +1 -1
- data/core/range.rbs +30 -0
- data/core/rbs/unnamed/env_class.rbs +7 -7
- data/core/rbs/unnamed/random.rbs +14 -14
- data/core/refinement.rbs +16 -26
- data/core/regexp.rbs +2 -2
- data/core/symbol.rbs +34 -26
- data/core/thread.rbs +8 -7
- data/core/trace_point.rbs +12 -12
- data/core/unbound_method.rbs +1 -1
- data/docs/syntax.md +26 -12
- data/ext/rbs_extension/lexer.c +1 -1
- data/ext/rbs_extension/lexer.h +5 -0
- data/ext/rbs_extension/lexer.re +1 -1
- data/ext/rbs_extension/lexstate.c +16 -0
- data/ext/rbs_extension/location.c +27 -39
- data/ext/rbs_extension/location.h +7 -2
- 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/buffer.rb +5 -0
- data/lib/rbs/cli/validate.rb +81 -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 +8 -3
- data/lib/rbs/file_finder.rb +9 -12
- data/lib/rbs/location_aux.rb +2 -6
- 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 +13 -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/location.rbs +0 -3
- 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 +44 -6
- data/stdlib/digest/0/digest.rbs +22 -28
- data/stdlib/ipaddr/0/ipaddr.rbs +1 -1
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/net-http/0/net-http.rbs +2 -2
- data/stdlib/psych/0/store.rbs +1 -1
- data/stdlib/uri/0/ldap.rbs +1 -1
- data/stdlib/zlib/0/deflate.rbs +1 -1
- data/stdlib/zlib/0/gzip_reader.rbs +5 -1
- metadata +6 -2
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/random.rbs
CHANGED
@@ -91,7 +91,7 @@ class Random < RBS::Unnamed::Random_Base
|
|
91
91
|
#
|
92
92
|
# See also Random#rand.
|
93
93
|
#
|
94
|
-
def self.rand: () -> Float
|
94
|
+
def self.rand: (?0) -> Float
|
95
95
|
| (Integer | ::Range[Integer] max) -> Integer
|
96
96
|
| (Float | ::Range[Float] max) -> Float
|
97
97
|
| [T < Numeric] (::Range[T]) -> T
|
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
|
@@ -231,8 +231,8 @@ module RBS
|
|
231
231
|
#
|
232
232
|
%a{annotate:rdoc:copy:ENV.fetch}
|
233
233
|
def fetch: (String name) -> String
|
234
|
-
|
235
|
-
|
234
|
+
| [X] (String name, X default) -> (String | X)
|
235
|
+
| [X] (String name) { (String) -> X } -> (String | X)
|
236
236
|
|
237
237
|
# <!--
|
238
238
|
# rdoc-file=hash.c
|
@@ -382,7 +382,7 @@ module RBS
|
|
382
382
|
#
|
383
383
|
%a{annotate:rdoc:copy:ENV.each_pair}
|
384
384
|
def each_pair: () -> ::Enumerator[[ String, String ], self]
|
385
|
-
|
385
|
+
| () { ([ String, String ]) -> void } -> self
|
386
386
|
|
387
387
|
# <!--
|
388
388
|
# rdoc-file=hash.c
|
@@ -479,7 +479,7 @@ module RBS
|
|
479
479
|
#
|
480
480
|
%a{annotate:rdoc:copy:ENV.delete_if}
|
481
481
|
def delete_if: () -> ::Enumerator[[ String, String ], self]
|
482
|
-
|
482
|
+
| () { (String name, String value) -> boolish } -> self
|
483
483
|
|
484
484
|
# <!--
|
485
485
|
# rdoc-file=hash.c
|
@@ -501,7 +501,7 @@ module RBS
|
|
501
501
|
#
|
502
502
|
%a{annotate:rdoc:copy:ENV.keep_if}
|
503
503
|
def keep_if: () -> ::Enumerator[[ String, String ], self]
|
504
|
-
|
504
|
+
| () { (String name, String value) -> boolish } -> self
|
505
505
|
|
506
506
|
# <!--
|
507
507
|
# rdoc-file=hash.c
|
@@ -588,7 +588,7 @@ module RBS
|
|
588
588
|
#
|
589
589
|
%a{annotate:rdoc:copy:ENV.reject!}
|
590
590
|
def reject!: () -> ::Enumerator[[ String, String ], self?]
|
591
|
-
|
591
|
+
| () { (String name, String value) -> boolish } -> self?
|
592
592
|
|
593
593
|
# <!--
|
594
594
|
# rdoc-file=hash.c
|
@@ -674,7 +674,7 @@ module RBS
|
|
674
674
|
#
|
675
675
|
%a{annotate:rdoc:copy:ENV.select!}
|
676
676
|
def select!: () -> ::Enumerator[[ String, String ], self?]
|
677
|
-
|
677
|
+
| () { (String name, String value) -> boolish } -> self?
|
678
678
|
|
679
679
|
# <!--
|
680
680
|
# rdoc-file=hash.c
|
data/core/rbs/unnamed/random.rbs
CHANGED
@@ -47,7 +47,7 @@ module RBS
|
|
47
47
|
# (`-`) and add (`+`)methods, or rand will raise an ArgumentError.
|
48
48
|
#
|
49
49
|
%a{annotate:rdoc:copy:Random#rand}
|
50
|
-
def rand: () -> Float
|
50
|
+
def rand: (?0) -> Float
|
51
51
|
| (Integer | ::Range[Integer] max) -> Integer
|
52
52
|
| (Float | ::Range[Float] max) -> Float
|
53
53
|
|
@@ -200,13 +200,13 @@ module RBS
|
|
200
200
|
# Generates formatted random number from raw random bytes. See Random#rand.
|
201
201
|
#
|
202
202
|
%a{annotate:rdoc:copy:Random::Formatter#rand}
|
203
|
-
def rand: () -> Float
|
204
|
-
| (
|
205
|
-
| (
|
206
|
-
| (
|
207
|
-
| (
|
208
|
-
| (
|
209
|
-
| (
|
203
|
+
def rand: (?0) -> Float
|
204
|
+
| (Float? n) -> Float
|
205
|
+
| (Integer n) -> Integer
|
206
|
+
| (Numeric n) -> Numeric
|
207
|
+
| (::Range[Float] n) -> Float
|
208
|
+
| (::Range[Integer] n) -> Integer
|
209
|
+
| (::Range[Numeric] n) -> Numeric
|
210
210
|
|
211
211
|
%a{annotate:rdoc:copy:Random::Formatter#random_byte}
|
212
212
|
def random_bytes: (?Integer? n) -> String
|
@@ -224,12 +224,12 @@ module RBS
|
|
224
224
|
#
|
225
225
|
%a{annotate:rdoc:copy:Random::Formatter#random_number}
|
226
226
|
def random_number: () -> Float
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
227
|
+
| (?Float? n) -> Float
|
228
|
+
| (?Integer? n) -> Integer
|
229
|
+
| (?Numeric? n) -> Numeric
|
230
|
+
| (?::Range[Float]? n) -> Float
|
231
|
+
| (?::Range[Integer]? n) -> Integer
|
232
|
+
| (?::Range[Numeric]? n) -> Numeric
|
233
233
|
|
234
234
|
# <!--
|
235
235
|
# rdoc-file=lib/random/formatter.rb
|
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/regexp.rbs
CHANGED
@@ -1596,8 +1596,8 @@ class Regexp
|
|
1596
1596
|
# r3 = Regexp.new(r, timeout: 3.14) # => /foo/m
|
1597
1597
|
# r3.timeout # => 3.14
|
1598
1598
|
#
|
1599
|
-
def initialize: (Regexp regexp, ?timeout: _ToF?) ->
|
1600
|
-
| (string pattern, ?int | string | bool | nil options, ?timeout: _ToF?) ->
|
1599
|
+
def initialize: (Regexp regexp, ?timeout: _ToF?) -> void
|
1600
|
+
| (string pattern, ?int | string | bool | nil options, ?timeout: _ToF?) -> void
|
1601
1601
|
|
1602
1602
|
def initialize_copy: (self object) -> self
|
1603
1603
|
|
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
|