rbs 3.3.2 → 3.4.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -5
  3. data/.github/workflows/ruby.yml +7 -8
  4. data/.github/workflows/typecheck.yml +37 -0
  5. data/CHANGELOG.md +50 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +11 -11
  8. data/Steepfile +2 -2
  9. data/core/array.rbs +19 -49
  10. data/core/basic_object.rbs +2 -2
  11. data/core/comparable.rbs +17 -8
  12. data/core/complex.rbs +82 -43
  13. data/core/data.rbs +2 -4
  14. data/core/dir.rbs +635 -295
  15. data/core/enumerable.rbs +11 -18
  16. data/core/enumerator.rbs +37 -31
  17. data/core/errors.rbs +4 -0
  18. data/core/false_class.rbs +34 -15
  19. data/core/fiber.rbs +23 -0
  20. data/core/file.rbs +329 -120
  21. data/core/float.rbs +17 -32
  22. data/core/gc.rbs +17 -11
  23. data/core/hash.rbs +22 -44
  24. data/core/integer.rbs +82 -113
  25. data/core/io/buffer.rbs +90 -47
  26. data/core/io.rbs +39 -116
  27. data/core/kernel.rbs +442 -489
  28. data/core/match_data.rbs +55 -56
  29. data/core/module.rbs +45 -1
  30. data/core/nil_class.rbs +98 -35
  31. data/core/numeric.rbs +22 -32
  32. data/core/object_space/weak_key_map.rbs +102 -0
  33. data/core/process.rbs +1242 -655
  34. data/core/ractor.rbs +139 -120
  35. data/core/range.rbs +100 -4
  36. data/core/rational.rbs +0 -4
  37. data/core/rbs/unnamed/argf.rbs +16 -8
  38. data/core/rbs/unnamed/env_class.rbs +0 -24
  39. data/core/refinement.rbs +8 -0
  40. data/core/regexp.rbs +1149 -598
  41. data/core/ruby_vm.rbs +126 -12
  42. data/core/rubygems/platform.rbs +9 -0
  43. data/core/rubygems/rubygems.rbs +1 -1
  44. data/core/rubygems/version.rbs +5 -1
  45. data/core/set.rbs +20 -22
  46. data/core/signal.rbs +4 -4
  47. data/core/string.rbs +283 -230
  48. data/core/string_io.rbs +2 -14
  49. data/core/struct.rbs +404 -24
  50. data/core/symbol.rbs +1 -19
  51. data/core/thread.rbs +29 -12
  52. data/core/time.rbs +227 -104
  53. data/core/trace_point.rbs +2 -5
  54. data/core/true_class.rbs +54 -21
  55. data/core/warning.rbs +14 -11
  56. data/docs/data_and_struct.md +29 -0
  57. data/docs/syntax.md +3 -5
  58. data/docs/tools.md +1 -0
  59. data/ext/rbs_extension/lexer.c +643 -559
  60. data/ext/rbs_extension/lexer.re +5 -1
  61. data/ext/rbs_extension/parser.c +12 -3
  62. data/ext/rbs_extension/unescape.c +7 -47
  63. data/lib/rbs/cli/diff.rb +4 -1
  64. data/lib/rbs/cli/validate.rb +280 -0
  65. data/lib/rbs/cli.rb +2 -194
  66. data/lib/rbs/collection/config.rb +5 -6
  67. data/lib/rbs/collection/sources/git.rb +1 -1
  68. data/lib/rbs/collection.rb +1 -0
  69. data/lib/rbs/diff.rb +7 -4
  70. data/lib/rbs/errors.rb +11 -0
  71. data/lib/rbs/test/errors.rb +4 -1
  72. data/lib/rbs/test/guaranteed.rb +2 -3
  73. data/lib/rbs/test/type_check.rb +15 -10
  74. data/lib/rbs/test.rb +3 -3
  75. data/lib/rbs/types.rb +29 -0
  76. data/lib/rbs/unit_test/convertibles.rb +176 -0
  77. data/lib/rbs/unit_test/spy.rb +136 -0
  78. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  79. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  80. data/lib/rbs/unit_test.rb +6 -0
  81. data/lib/rbs/version.rb +1 -1
  82. data/sig/cli/validate.rbs +43 -0
  83. data/sig/diff.rbs +3 -1
  84. data/sig/errors.rbs +8 -0
  85. data/sig/rbs.rbs +1 -1
  86. data/sig/test/errors.rbs +52 -0
  87. data/sig/test/guranteed.rbs +9 -0
  88. data/sig/test/type_check.rbs +19 -0
  89. data/sig/test.rbs +82 -0
  90. data/sig/types.rbs +6 -1
  91. data/sig/unit_test/convertibles.rbs +154 -0
  92. data/sig/unit_test/spy.rbs +28 -0
  93. data/sig/unit_test/type_assertions.rbs +194 -0
  94. data/sig/unit_test/with_aliases.rbs +136 -0
  95. data/stdlib/base64/0/base64.rbs +307 -45
  96. data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
  97. data/stdlib/coverage/0/coverage.rbs +2 -2
  98. data/stdlib/csv/0/csv.rbs +25 -55
  99. data/stdlib/date/0/date.rbs +1 -43
  100. data/stdlib/date/0/date_time.rbs +1 -13
  101. data/stdlib/delegate/0/delegator.rbs +186 -0
  102. data/stdlib/delegate/0/kernel.rbs +47 -0
  103. data/stdlib/delegate/0/simple_delegator.rbs +98 -0
  104. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
  105. data/stdlib/erb/0/erb.rbs +2 -2
  106. data/stdlib/fileutils/0/fileutils.rbs +0 -19
  107. data/stdlib/io-console/0/io-console.rbs +12 -1
  108. data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
  109. data/stdlib/json/0/json.rbs +320 -81
  110. data/stdlib/logger/0/logger.rbs +9 -5
  111. data/stdlib/monitor/0/monitor.rbs +78 -0
  112. data/stdlib/net-http/0/net-http.rbs +1880 -543
  113. data/stdlib/objspace/0/objspace.rbs +19 -13
  114. data/stdlib/openssl/0/openssl.rbs +508 -127
  115. data/stdlib/optparse/0/optparse.rbs +25 -11
  116. data/stdlib/pathname/0/pathname.rbs +1 -1
  117. data/stdlib/pp/0/pp.rbs +2 -5
  118. data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
  119. data/stdlib/pstore/0/pstore.rbs +2 -4
  120. data/stdlib/rdoc/0/comment.rbs +1 -2
  121. data/stdlib/resolv/0/resolv.rbs +4 -2
  122. data/stdlib/socket/0/socket.rbs +2 -2
  123. data/stdlib/socket/0/unix_socket.rbs +2 -2
  124. data/stdlib/strscan/0/string_scanner.rbs +3 -2
  125. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  126. data/stdlib/uri/0/common.rbs +245 -123
  127. metadata +23 -4
  128. data/lib/rbs/test/spy.rb +0 -6
data/core/match_data.rbs CHANGED
@@ -45,15 +45,16 @@
45
45
  # See also "Special global variables" section in Regexp documentation.
46
46
  #
47
47
  class MatchData
48
- public
48
+ type capture = String | Symbol | int
49
+
50
+ def initialize_copy: (MatchData instance) -> self
49
51
 
50
52
  # <!-- rdoc-file=re.c -->
51
53
  # Returns `true` if `object` is another MatchData object whose target string,
52
54
  # regexp, match, and captures are the same as `self`, `false` otherwise.
53
55
  #
54
- # MatchData#eql? is an alias for MatchData#==.
55
- #
56
- def ==: (untyped other) -> bool
56
+ def ==: (MatchData other) -> bool
57
+ | (untyped) -> false
57
58
 
58
59
  # <!--
59
60
  # rdoc-file=re.c
@@ -80,10 +81,9 @@ class MatchData
80
81
  # m['foo'] # => "h"
81
82
  # m[:bar] # => "ge"
82
83
  #
83
- def []: (Integer idx) -> String?
84
- | (Integer start, Integer length) -> ::Array[String?]
85
- | (::Range[Integer] range) -> ::Array[String?]
86
- | (interned name) -> String?
84
+ def []: (capture backref, ?nil) -> String?
85
+ | (int start, int length) -> Array[String?]
86
+ | (range[int?] range) -> Array[String?]
87
87
 
88
88
  # <!--
89
89
  # rdoc-file=re.c
@@ -121,7 +121,7 @@ class MatchData
121
121
  #
122
122
  # Related: MatchData#end, MatchData#offset, MatchData#byteoffset.
123
123
  #
124
- def begin: (Integer | interned n_or_name) -> Integer?
124
+ def begin: (capture backref) -> Integer?
125
125
 
126
126
  # <!--
127
127
  # rdoc-file=re.c
@@ -139,7 +139,7 @@ class MatchData
139
139
  # p m.byteoffset(:foo) #=> [0, 1]
140
140
  # p m.byteoffset(:bar) #=> [2, 3]
141
141
  #
142
- def byteoffset: (Integer | interned n_or_name) -> ([ Integer, Integer ] | [ nil, nil ])
142
+ def byteoffset: (capture backref) -> ([Integer, Integer] | [nil, nil])
143
143
 
144
144
  # <!--
145
145
  # rdoc-file=re.c
@@ -154,7 +154,7 @@ class MatchData
154
154
  #
155
155
  # Related: MatchData.to_a.
156
156
  #
157
- def captures: () -> ::Array[String?]
157
+ def captures: () -> Array[String?]
158
158
 
159
159
  # <!-- rdoc-file=re.c -->
160
160
  # Returns the array of captures, which are all matches except `m[0]`:
@@ -178,12 +178,12 @@ class MatchData
178
178
  # m.deconstruct_keys([:hours, :minutes]) # => {:hours => "18", :minutes => "37"}
179
179
  # m.deconstruct_keys(nil) # => {:hours => "18", :minutes => "37", :seconds => "22"}
180
180
  #
181
- # Returns an empty hash of no named captures were defined:
181
+ # Returns an empty hash if no named captures were defined:
182
182
  #
183
183
  # m = /(\d{2}):(\d{2}):(\d{2})/.match("18:37:22")
184
184
  # m.deconstruct_keys(nil) # => {}
185
185
  #
186
- def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol, String?]
186
+ def deconstruct_keys: (Array[Symbol]? array_of_names) -> Hash[Symbol, String?]
187
187
 
188
188
  # <!--
189
189
  # rdoc-file=re.c
@@ -221,7 +221,7 @@ class MatchData
221
221
  #
222
222
  # Related: MatchData#begin, MatchData#offset, MatchData#byteoffset.
223
223
  #
224
- def end: (Integer | interned n_or_name) -> Integer?
224
+ def end: (capture backref) -> Integer?
225
225
 
226
226
  # <!--
227
227
  # rdoc-file=re.c
@@ -230,9 +230,7 @@ class MatchData
230
230
  # Returns `true` if `object` is another MatchData object whose target string,
231
231
  # regexp, match, and captures are the same as `self`, `false` otherwise.
232
232
  #
233
- # MatchData#eql? is an alias for MatchData#==.
234
- #
235
- def eql?: (untyped other) -> bool
233
+ alias eql? ==
236
234
 
237
235
  # <!--
238
236
  # rdoc-file=re.c
@@ -251,19 +249,19 @@ class MatchData
251
249
  # -->
252
250
  # Returns a string representation of `self`:
253
251
  #
254
- # m = /.$/.match("foo")
255
- # # => #<MatchData "o">
256
- # m.inspect # => "#<MatchData \"o\">"
252
+ # m = /.$/.match("foo")
253
+ # # => #<MatchData "o">
254
+ # m.inspect # => "#<MatchData \"o\">"
257
255
  #
258
- # m = /(.)(.)(.)/.match("foo")
259
- # # => #<MatchData "foo" 1:"f" 2:"o" 3:"o">
260
- # m.inspect # => "#<MatchData \"foo\" 1:\"f\" 2:\"o\
256
+ # m = /(.)(.)(.)/.match("foo")
257
+ # # => #<MatchData "foo" 1:"f" 2:"o" 3:"o">
258
+ # m.inspect # => "#<MatchData \"foo\" 1:\"f\" 2:\"o\
261
259
  #
262
- # m = /(.)(.)?(.)/.match("fo")
263
- # # => #<MatchData "fo" 1:"f" 2:nil 3:"o">
264
- # m.inspect # => "#<MatchData \"fo\" 1:\"f\" 2:nil 3:\"o\">"
260
+ # m = /(.)(.)?(.)/.match("fo")
261
+ # # => #<MatchData "fo" 1:"f" 2:nil 3:"o">
262
+ # m.inspect # => "#<MatchData \"fo\" 1:\"f\" 2:nil 3:\"o\">"
265
263
  #
266
- # Related: MatchData#to_s.
264
+ # Related: MatchData#to_s.
267
265
  #
268
266
  def inspect: () -> String
269
267
 
@@ -274,34 +272,41 @@ class MatchData
274
272
  # # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
275
273
  # m.size # => 5
276
274
  #
277
- # MatchData#length is an alias for MatchData.size.
278
- #
279
- def length: () -> Integer
275
+ alias length size
280
276
 
281
277
  # <!--
282
278
  # rdoc-file=re.c
283
- # - named_captures -> hash
279
+ # - named_captures(symbolize_names: false) -> hash
284
280
  # -->
285
- # Returns a hash of the named captures; each key is a capture name; each value
286
- # is its captured string or `nil`:
281
+ # Returns a hash of the named captures;
282
+ # each key is a capture name; each value is its captured string or +nil+:
287
283
  #
288
- # m = /(?<foo>.)(.)(?<bar>.+)/.match("hoge")
289
- # # => #<MatchData "hoge" foo:"h" bar:"ge">
290
- # m.named_captures # => {"foo"=>"h", "bar"=>"ge"}
284
+ # m = /(?<foo>.)(.)(?<bar>.+)/.match("hoge")
285
+ # # => #<MatchData "hoge" foo:"h" bar:"ge">
286
+ # m.named_captures # => {"foo"=>"h", "bar"=>"ge"}
291
287
  #
292
- # m = /(?<a>.)(?<b>.)/.match("01")
293
- # # => #<MatchData "01" a:"0" b:"1">
294
- # m.named_captures #=> {"a" => "0", "b" => "1"}
288
+ # m = /(?<a>.)(?<b>.)/.match("01")
289
+ # # => #<MatchData "01" a:"0" b:"1">
290
+ # m.named_captures #=> {"a" => "0", "b" => "1"}
295
291
  #
296
- # m = /(?<a>.)(?<b>.)?/.match("0")
297
- # # => #<MatchData "0" a:"0" b:nil>
298
- # m.named_captures #=> {"a" => "0", "b" => nil}
292
+ # m = /(?<a>.)(?<b>.)?/.match("0")
293
+ # # => #<MatchData "0" a:"0" b:nil>
294
+ # m.named_captures #=> {"a" => "0", "b" => nil}
295
+ #
296
+ # m = /(?<a>.)(?<a>.)/.match("01")
297
+ # # => #<MatchData "01" a:"0" a:"1">
298
+ # m.named_captures #=> {"a" => "1"}
299
+ #
300
+ # If keyword argument `symbolize_names` is given a true value, the keys in the
301
+ # resulting hash are Symbols:
299
302
  #
300
303
  # m = /(?<a>.)(?<a>.)/.match("01")
301
304
  # # => #<MatchData "01" a:"0" a:"1">
302
- # m.named_captures #=> {"a" => "1"}
305
+ # m.named_captures(symbolize_names: true) #=> {:a => "1"}
303
306
  #
304
- def named_captures: () -> ::Hash[String, String?]
307
+ def named_captures: () -> Hash[String, String?]
308
+ | (symbolize_names: true) -> Hash[Symbol, String?]
309
+ | (symbolize_names: boolish) -> Hash[String | Symbol, String?]
305
310
 
306
311
  # <!--
307
312
  # rdoc-file=re.c
@@ -322,7 +327,7 @@ class MatchData
322
327
  # m = /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge")
323
328
  # m.regexp.names # => ["foo", "bar", "baz"]
324
329
  #
325
- def names: () -> ::Array[String]
330
+ def names: () -> Array[String]
326
331
 
327
332
  # <!--
328
333
  # rdoc-file=re.c
@@ -348,7 +353,7 @@ class MatchData
348
353
  # m.match('foo') # => "h"
349
354
  # m.match(:bar) # => "ge"
350
355
  #
351
- def match: (int | interned) -> String?
356
+ def match: (capture backref) -> String?
352
357
 
353
358
  # <!--
354
359
  # rdoc-file=re.c
@@ -375,7 +380,7 @@ class MatchData
375
380
  # m.match_length('foo') # => 1
376
381
  # m.match_length(:bar) # => 2
377
382
  #
378
- def match_length: (int | interned) -> Integer?
383
+ def match_length: (capture backref) -> Integer?
379
384
 
380
385
  # <!--
381
386
  # rdoc-file=re.c
@@ -414,7 +419,7 @@ class MatchData
414
419
  #
415
420
  # Related: MatchData#byteoffset, MatchData#begin, MatchData#end.
416
421
  #
417
- def offset: (Integer | interned n_or_name) -> ([ Integer, Integer ] | [ nil, nil ])
422
+ def offset: (capture backref) -> ([Integer, Integer] | [nil, nil])
418
423
 
419
424
  # <!--
420
425
  # rdoc-file=re.c
@@ -471,8 +476,6 @@ class MatchData
471
476
  # # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
472
477
  # m.size # => 5
473
478
  #
474
- # MatchData#length is an alias for MatchData.size.
475
- #
476
479
  def size: () -> Integer
477
480
 
478
481
  # <!--
@@ -500,7 +503,7 @@ class MatchData
500
503
  #
501
504
  # Related: MatchData#captures.
502
505
  #
503
- def to_a: () -> ::Array[String?]
506
+ def to_a: () -> Array[String?]
504
507
 
505
508
  # <!--
506
509
  # rdoc-file=re.c
@@ -544,9 +547,5 @@ class MatchData
544
547
  # m.values_at(0, 1..2, :a, :b, :op)
545
548
  # # => ["1 + 2", "1", "+", "1", "2", "+"]
546
549
  #
547
- def values_at: (*Integer | interned n_or_name) -> ::Array[String?]
548
-
549
- private
550
-
551
- def initialize_copy: (self object) -> void
550
+ def values_at: (*capture | range[int?] backrefs) -> Array[String?]
552
551
  end
data/core/module.rbs CHANGED
@@ -1463,7 +1463,7 @@ class Module < Object
1463
1463
  #
1464
1464
  # Returns a module, where refined methods are defined.
1465
1465
  #
1466
- def refine: (Module mod) { () -> void } -> Refinement
1466
+ def refine: (Module mod) { () [self: Refinement] -> void } -> Refinement
1467
1467
 
1468
1468
  # <!--
1469
1469
  # rdoc-file=eval.c
@@ -1527,6 +1527,50 @@ class Module < Object
1527
1527
  #
1528
1528
  def remove_method: (*interned arg0) -> self
1529
1529
 
1530
+ # <!--
1531
+ # rdoc-file=object.c
1532
+ # - mod.set_temporary_name(string) -> self
1533
+ # - mod.set_temporary_name(nil) -> self
1534
+ # -->
1535
+ # Sets the temporary name of the module `mod`. This name is used as a prefix for
1536
+ # the names of constants declared in `mod`. If the module is assigned a
1537
+ # permanent name, the temporary name is discarded.
1538
+ #
1539
+ # After a permanent name is assigned, a temporary name can no longer be set, and
1540
+ # this method raises a RuntimeError.
1541
+ #
1542
+ # If the name given is not a string or is a zero length string, this method
1543
+ # raises an ArgumentError.
1544
+ #
1545
+ # The temporary name must not be a valid constant name, to avoid confusion with
1546
+ # actual constants. If you attempt to set a temporary name that is a a valid
1547
+ # constant name, this method raises an ArgumentError.
1548
+ #
1549
+ # If the given name is `nil`, the module becomes anonymous.
1550
+ #
1551
+ # Example:
1552
+ #
1553
+ # m = Module.new # => #<Module:0x0000000102c68f38>
1554
+ # m.name #=> nil
1555
+ #
1556
+ # m.set_temporary_name("fake_name") # => fake_name
1557
+ # m.name #=> "fake_name"
1558
+ #
1559
+ # m.set_temporary_name(nil) # => #<Module:0x0000000102c68f38>
1560
+ # m.name #=> nil
1561
+ #
1562
+ # n = Module.new
1563
+ # n.set_temporary_name("fake_name")
1564
+ #
1565
+ # n::M = m
1566
+ # n::M.name #=> "fake_name::M"
1567
+ # N = n
1568
+ #
1569
+ # N.name #=> "N"
1570
+ # N::M.name #=> "N::M"
1571
+ #
1572
+ def set_temporary_name: (string?) -> self
1573
+
1530
1574
  # <!--
1531
1575
  # rdoc-file=object.c
1532
1576
  # - mod.singleton_class? -> true or false
data/core/nil_class.rbs CHANGED
@@ -1,90 +1,145 @@
1
1
  # <!-- rdoc-file=object.c -->
2
2
  # The class of the singleton object `nil`.
3
3
  #
4
+ # Several of its methods act as operators:
5
+ #
6
+ # * #&
7
+ # * #|
8
+ # * #===
9
+ # * #=~
10
+ # * #^
11
+ #
12
+ #
13
+ # Others act as converters, carrying the concept of *nullity* to other classes:
14
+ #
15
+ # * #rationalize
16
+ # * #to_a
17
+ # * #to_c
18
+ # * #to_h
19
+ # * #to_r
20
+ # * #to_s
21
+ #
22
+ #
23
+ # Another method provides inspection:
24
+ #
25
+ # * #inspect
26
+ #
27
+ #
28
+ # Finally, there is this query method:
29
+ #
30
+ # * #nil?
31
+ #
4
32
  class NilClass
5
33
  def !: () -> true
6
34
 
7
35
  # <!--
8
36
  # rdoc-file=object.c
9
- # - false & obj -> false
10
- # - nil & obj -> false
37
+ # - false & object -> false
38
+ # - nil & object -> false
11
39
  # -->
12
- # And---Returns `false`. *obj* is always evaluated as it is the argument to a
13
- # method call---there is no short-circuit evaluation in this case.
40
+ # Returns `false`:
41
+ #
42
+ # false & true # => false
43
+ # false & Object.new # => false
44
+ #
45
+ # Argument `object` is evaluated:
46
+ #
47
+ # false & raise # Raises RuntimeError.
14
48
  #
15
49
  def &: (untyped obj) -> false
16
50
 
17
51
  # <!--
18
52
  # rdoc-file=object.c
19
- # - obj === other -> true or false
53
+ # - true === other -> true or false
54
+ # - false === other -> true or false
55
+ # - nil === other -> true or false
20
56
  # -->
21
- # Case Equality -- For class Object, effectively the same as calling `#==`, but
22
- # typically overridden by descendants to provide meaningful semantics in `case`
23
- # statements.
57
+ # Returns `true` or `false`.
58
+ #
59
+ # Like Object#==, if `object` is an instance of Object (and not an instance of
60
+ # one of its many subclasses).
61
+ #
62
+ # This method is commonly overridden by those subclasses, to provide meaningful
63
+ # semantics in `case` statements.
24
64
  #
25
65
  def ===: (nil) -> true
26
66
  | (untyped obj) -> bool
27
67
 
28
68
  # <!--
29
69
  # rdoc-file=object.c
30
- # - nil =~ other -> nil
70
+ # - nil =~ object -> nil
31
71
  # -->
32
- # Dummy pattern matching -- always returns nil.
72
+ # Returns `nil`.
33
73
  #
34
- # This method makes it possible to `while gets =~ /re/ do`.
74
+ # This method makes it useful to write:
75
+ #
76
+ # while gets =~ /re/
77
+ # # ...
78
+ # end
35
79
  #
36
80
  def =~: (untyped obj) -> nil
37
81
 
38
82
  # <!--
39
83
  # rdoc-file=object.c
40
- # - false ^ obj -> true or false
41
- # - nil ^ obj -> true or false
84
+ # - false ^ object -> true or false
85
+ # - nil ^ object -> true or false
42
86
  # -->
43
- # Exclusive Or---If *obj* is `nil` or `false`, returns `false`; otherwise,
44
- # returns `true`.
87
+ # Returns `false` if `object` is `nil` or `false`, `true` otherwise:
88
+ #
89
+ # nil ^ nil # => false
90
+ # nil ^ false # => false
91
+ # nil ^ Object.new # => true
45
92
  #
46
93
  def ^: (false | nil) -> false
47
94
  | (untyped obj) -> bool
48
95
 
49
96
  # <!--
50
97
  # rdoc-file=object.c
51
- # - nil.inspect -> "nil"
98
+ # - inspect -> 'nil'
52
99
  # -->
53
- # Always returns the string "nil".
100
+ # Returns string `'nil'`:
101
+ #
102
+ # nil.inspect # => "nil"
54
103
  #
55
104
  def inspect: () -> "nil"
56
105
 
57
106
  # <!--
58
107
  # rdoc-file=object.c
59
- # - nil.nil? -> true
108
+ # - nil.nil? -> true
60
109
  # -->
61
- # Only the object *nil* responds `true` to `nil?`.
110
+ # Returns `true`. For all other objects, method `nil?` returns `false`.
62
111
  #
63
112
  def nil?: () -> true
64
113
 
65
114
  # <!--
66
115
  # rdoc-file=rational.c
67
- # - nil.rationalize([eps]) -> (0/1)
116
+ # - rationalize(eps = nil) -> (0/1)
68
117
  # -->
69
- # Returns zero as a rational. The optional argument `eps` is always ignored.
118
+ # Returns zero as a Rational:
119
+ #
120
+ # nil.rationalize # => (0/1)
121
+ #
122
+ # Argument `eps` is ignored.
70
123
  #
71
124
  def rationalize: (?untyped eps) -> Rational
72
125
 
73
126
  # <!--
74
127
  # rdoc-file=object.c
75
- # - nil.to_a -> []
128
+ # - to_a -> []
76
129
  # -->
77
- # Always returns an empty array.
130
+ # Returns an empty Array.
78
131
  #
79
- # nil.to_a #=> []
132
+ # nil.to_a # => []
80
133
  #
81
134
  def to_a: () -> []
82
135
 
83
136
  # <!--
84
137
  # rdoc-file=complex.c
85
- # - nil.to_c -> (0+0i)
138
+ # - to_c -> (0+0i)
86
139
  # -->
87
- # Returns zero as a complex.
140
+ # Returns zero as a Complex:
141
+ #
142
+ # nil.to_c # => (0+0i)
88
143
  #
89
144
  def to_c: () -> Complex
90
145
 
@@ -100,9 +155,9 @@ class NilClass
100
155
 
101
156
  # <!--
102
157
  # rdoc-file=object.c
103
- # - nil.to_h -> {}
158
+ # - to_h -> {}
104
159
  # -->
105
- # Always returns an empty hash.
160
+ # Returns an empty Hash.
106
161
  #
107
162
  # nil.to_h #=> {}
108
163
  #
@@ -120,26 +175,34 @@ class NilClass
120
175
 
121
176
  # <!--
122
177
  # rdoc-file=rational.c
123
- # - nil.to_r -> (0/1)
178
+ # - to_r -> (0/1)
124
179
  # -->
125
- # Returns zero as a rational.
180
+ # Returns zero as a Rational:
181
+ #
182
+ # nil.to_r # => (0/1)
126
183
  #
127
184
  def to_r: () -> Rational
128
185
 
129
186
  # <!--
130
187
  # rdoc-file=object.c
131
- # - nil.to_s -> ""
188
+ # - to_s -> ''
132
189
  # -->
133
- # Always returns the empty string.
190
+ # Returns an empty String:
191
+ #
192
+ # nil.to_s # => ""
134
193
  #
135
194
  def to_s: () -> ""
136
195
 
137
196
  # <!--
138
197
  # rdoc-file=object.c
139
- # - false | obj -> true or false
140
- # - nil | obj -> true or false
198
+ # - false | object -> true or false
199
+ # - nil | object -> true or false
141
200
  # -->
142
- # Or---Returns `false` if *obj* is `nil` or `false`; `true` otherwise.
201
+ # Returns `false` if `object` is `nil` or `false`, `true` otherwise:
202
+ #
203
+ # nil | nil # => false
204
+ # nil | false # => false
205
+ # nil | Object.new # => true
143
206
  #
144
207
  def |: (nil | false) -> false
145
208
  | (untyped obj) -> bool
data/core/numeric.rbs CHANGED
@@ -196,8 +196,6 @@ class Numeric
196
196
  # (-r) % r2 # => (119/100)
197
197
  # (-r) %-r2 # => (-21/100)
198
198
  #
199
- # Numeric#modulo is an alias for Numeric#%.
200
- #
201
199
  def %: (Numeric) -> Numeric
202
200
 
203
201
  # Performs addition: the class of the resulting object depends on the class of
@@ -246,8 +244,6 @@ class Numeric
246
244
  # (-34.56).abs #=> 34.56
247
245
  # -34.56.abs #=> 34.56
248
246
  #
249
- # Numeric#magnitude is an alias for Numeric#abs.
250
- #
251
247
  def abs: () -> Numeric
252
248
 
253
249
  # <!--
@@ -329,10 +325,9 @@ class Numeric
329
325
 
330
326
  # <!--
331
327
  # rdoc-file=numeric.rb
332
- # - num.conj -> self
333
- # - num.conjugate -> self
328
+ # - conj -> self
334
329
  # -->
335
- # Returns self.
330
+ # Returns `self`.
336
331
  #
337
332
  def conjugate: () -> Numeric
338
333
 
@@ -421,9 +416,9 @@ class Numeric
421
416
 
422
417
  # <!--
423
418
  # rdoc-file=numeric.rb
424
- # - num.finite? -> true or false
419
+ # - finite? -> true or false
425
420
  # -->
426
- # Returns `true` if `num` is a finite number, otherwise returns `false`.
421
+ # Returns `true` if `self` is a finite number, `false` otherwise.
427
422
  #
428
423
  def finite?: () -> bool
429
424
 
@@ -463,8 +458,7 @@ class Numeric
463
458
 
464
459
  # <!--
465
460
  # rdoc-file=numeric.rb
466
- # - num.imag -> 0
467
- # - num.imaginary -> 0
461
+ # - imag -> 0
468
462
  # -->
469
463
  # Returns zero.
470
464
  #
@@ -472,21 +466,21 @@ class Numeric
472
466
 
473
467
  # <!--
474
468
  # rdoc-file=numeric.rb
475
- # - num.infinite? -> -1, 1, or nil
469
+ # - infinite? -> -1, 1, or nil
476
470
  # -->
477
- # Returns `nil`, -1, or 1 depending on whether the value is finite, `-Infinity`,
478
- # or `+Infinity`.
471
+ # Returns `nil`, -1, or 1 depending on whether `self` is finite, `-Infinity`, or
472
+ # `+Infinity`.
479
473
  #
480
474
  def infinite?: () -> Integer?
481
475
 
482
476
  # <!--
483
477
  # rdoc-file=numeric.rb
484
- # - num.integer? -> true or false
478
+ # - integer? -> true or false
485
479
  # -->
486
- # Returns `true` if `num` is an Integer.
480
+ # Returns `true` if `self` is an Integer.
487
481
  #
488
- # 1.0.integer? #=> false
489
- # 1.integer? #=> true
482
+ # 1.0.integer? # => false
483
+ # 1.integer? # => true
490
484
  #
491
485
  def integer?: () -> bool
492
486
 
@@ -497,8 +491,6 @@ class Numeric
497
491
  # (-34.56).abs #=> 34.56
498
492
  # -34.56.abs #=> 34.56
499
493
  #
500
- # Numeric#magnitude is an alias for Numeric#abs.
501
- #
502
494
  alias magnitude abs
503
495
 
504
496
  # <!-- rdoc-file=numeric.c -->
@@ -530,8 +522,6 @@ class Numeric
530
522
  # (-r) % r2 # => (119/100)
531
523
  # (-r) %-r2 # => (-21/100)
532
524
  #
533
- # Numeric#modulo is an alias for Numeric#%.
534
- #
535
525
  def modulo: (Numeric) -> Numeric
536
526
 
537
527
  # <!--
@@ -600,17 +590,17 @@ class Numeric
600
590
 
601
591
  # <!--
602
592
  # rdoc-file=numeric.rb
603
- # - num.real -> self
593
+ # - real -> self
604
594
  # -->
605
- # Returns self.
595
+ # Returns `self`.
606
596
  #
607
597
  def real: () -> Numeric
608
598
 
609
599
  # <!--
610
600
  # rdoc-file=numeric.rb
611
- # - num.real? -> true or false
601
+ # - real? -> true or false
612
602
  # -->
613
- # Returns `true` if `num` is a real number (i.e. not Complex).
603
+ # Returns `true` if `self` is a real number (i.e. not Complex).
614
604
  #
615
605
  def real?: () -> bool
616
606
 
@@ -697,11 +687,11 @@ class Numeric
697
687
  # The generated sequence:
698
688
  #
699
689
  # - Begins with +self+.
700
- # - Continues at intervals of +step+ (which may not be zero).
701
- # - Ends with the last number that is within or equal to +limit+;
702
- # that is, less than or equal to +limit+ if +step+ is positive,
703
- # greater than or equal to +limit+ if +step+ is negative.
704
- # If +limit+ is not given, the sequence is of infinite length.
690
+ # - Continues at intervals of +by+ (which may not be zero).
691
+ # - Ends with the last number that is within or equal to +to+;
692
+ # that is, less than or equal to +to+ if +by+ is positive,
693
+ # greater than or equal to +to+ if +by+ is negative.
694
+ # If +to+ is +nil+, the sequence is of infinite length.
705
695
  #
706
696
  # If a block is given, calls the block with each number in the sequence;
707
697
  # returns +self+. If no block is given, returns an Enumerator::ArithmeticSequence.
@@ -743,7 +733,7 @@ class Numeric
743
733
  #
744
734
  # <b>Positional Arguments</b>
745
735
  #
746
- # With optional positional arguments +limit+ and +step+,
736
+ # With optional positional arguments +to+ and +by+,
747
737
  # their values (or defaults) determine the step and limit:
748
738
  #
749
739
  # squares = []