rbs 3.3.2 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) 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 +65 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +11 -11
  8. data/README.md +1 -0
  9. data/Rakefile +2 -2
  10. data/Steepfile +2 -2
  11. data/core/array.rbs +19 -49
  12. data/core/basic_object.rbs +2 -2
  13. data/core/comparable.rbs +17 -8
  14. data/core/complex.rbs +82 -43
  15. data/core/data.rbs +2 -4
  16. data/core/dir.rbs +635 -295
  17. data/core/enumerable.rbs +11 -18
  18. data/core/enumerator.rbs +37 -31
  19. data/core/errors.rbs +4 -0
  20. data/core/false_class.rbs +34 -15
  21. data/core/fiber.rbs +23 -0
  22. data/core/file.rbs +329 -120
  23. data/core/float.rbs +17 -32
  24. data/core/gc.rbs +17 -11
  25. data/core/hash.rbs +22 -44
  26. data/core/integer.rbs +82 -113
  27. data/core/io/buffer.rbs +90 -47
  28. data/core/io.rbs +54 -121
  29. data/core/kernel.rbs +442 -489
  30. data/core/match_data.rbs +55 -56
  31. data/core/module.rbs +45 -1
  32. data/core/nil_class.rbs +98 -35
  33. data/core/numeric.rbs +22 -32
  34. data/core/object_space/weak_key_map.rbs +102 -0
  35. data/core/process.rbs +1242 -655
  36. data/core/ractor.rbs +139 -120
  37. data/core/range.rbs +100 -4
  38. data/core/rational.rbs +0 -4
  39. data/core/rbs/unnamed/argf.rbs +16 -8
  40. data/core/rbs/unnamed/env_class.rbs +0 -24
  41. data/core/refinement.rbs +8 -0
  42. data/core/regexp.rbs +1149 -598
  43. data/core/ruby_vm.rbs +126 -12
  44. data/core/rubygems/platform.rbs +9 -0
  45. data/core/rubygems/rubygems.rbs +1 -1
  46. data/core/rubygems/version.rbs +5 -1
  47. data/core/set.rbs +20 -22
  48. data/core/signal.rbs +4 -4
  49. data/core/string.rbs +283 -230
  50. data/core/string_io.rbs +2 -14
  51. data/core/struct.rbs +404 -24
  52. data/core/symbol.rbs +1 -19
  53. data/core/thread.rbs +29 -12
  54. data/core/time.rbs +227 -104
  55. data/core/trace_point.rbs +2 -5
  56. data/core/true_class.rbs +54 -21
  57. data/core/warning.rbs +14 -11
  58. data/docs/data_and_struct.md +29 -0
  59. data/docs/gem.md +58 -0
  60. data/docs/syntax.md +3 -5
  61. data/docs/tools.md +1 -0
  62. data/ext/rbs_extension/lexer.c +643 -559
  63. data/ext/rbs_extension/lexer.re +5 -1
  64. data/ext/rbs_extension/parser.c +12 -3
  65. data/ext/rbs_extension/unescape.c +7 -47
  66. data/lib/rbs/cli/diff.rb +4 -1
  67. data/lib/rbs/cli/validate.rb +280 -0
  68. data/lib/rbs/cli.rb +2 -194
  69. data/lib/rbs/collection/config.rb +5 -6
  70. data/lib/rbs/collection/sources/git.rb +1 -1
  71. data/lib/rbs/collection.rb +1 -0
  72. data/lib/rbs/diff.rb +7 -4
  73. data/lib/rbs/errors.rb +11 -0
  74. data/lib/rbs/test/errors.rb +10 -2
  75. data/lib/rbs/test/guaranteed.rb +2 -3
  76. data/lib/rbs/test/type_check.rb +15 -10
  77. data/lib/rbs/test.rb +3 -3
  78. data/lib/rbs/types.rb +29 -0
  79. data/lib/rbs/unit_test/convertibles.rb +176 -0
  80. data/lib/rbs/unit_test/spy.rb +136 -0
  81. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  82. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  83. data/lib/rbs/unit_test.rb +6 -0
  84. data/lib/rbs/version.rb +1 -1
  85. data/sig/cli/validate.rbs +43 -0
  86. data/sig/diff.rbs +3 -1
  87. data/sig/errors.rbs +8 -0
  88. data/sig/rbs.rbs +1 -1
  89. data/sig/test/errors.rbs +52 -0
  90. data/sig/test/guranteed.rbs +9 -0
  91. data/sig/test/type_check.rbs +19 -0
  92. data/sig/test.rbs +82 -0
  93. data/sig/types.rbs +6 -1
  94. data/sig/unit_test/convertibles.rbs +154 -0
  95. data/sig/unit_test/spy.rbs +28 -0
  96. data/sig/unit_test/type_assertions.rbs +194 -0
  97. data/sig/unit_test/with_aliases.rbs +136 -0
  98. data/stdlib/base64/0/base64.rbs +307 -45
  99. data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
  100. data/stdlib/coverage/0/coverage.rbs +2 -2
  101. data/stdlib/csv/0/csv.rbs +25 -55
  102. data/stdlib/date/0/date.rbs +1 -43
  103. data/stdlib/date/0/date_time.rbs +1 -13
  104. data/stdlib/delegate/0/delegator.rbs +186 -0
  105. data/stdlib/delegate/0/kernel.rbs +47 -0
  106. data/stdlib/delegate/0/simple_delegator.rbs +98 -0
  107. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
  108. data/stdlib/erb/0/erb.rbs +2 -2
  109. data/stdlib/fileutils/0/fileutils.rbs +0 -19
  110. data/stdlib/io-console/0/io-console.rbs +12 -1
  111. data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
  112. data/stdlib/json/0/json.rbs +320 -81
  113. data/stdlib/logger/0/logger.rbs +9 -5
  114. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +6 -6
  115. data/stdlib/monitor/0/monitor.rbs +78 -0
  116. data/stdlib/net-http/0/net-http.rbs +1880 -543
  117. data/stdlib/objspace/0/objspace.rbs +19 -13
  118. data/stdlib/openssl/0/openssl.rbs +508 -127
  119. data/stdlib/optparse/0/optparse.rbs +25 -11
  120. data/stdlib/pathname/0/pathname.rbs +1 -1
  121. data/stdlib/pp/0/pp.rbs +2 -5
  122. data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
  123. data/stdlib/pstore/0/pstore.rbs +2 -4
  124. data/stdlib/rdoc/0/comment.rbs +1 -2
  125. data/stdlib/resolv/0/resolv.rbs +4 -2
  126. data/stdlib/socket/0/socket.rbs +2 -2
  127. data/stdlib/socket/0/unix_socket.rbs +2 -2
  128. data/stdlib/strscan/0/string_scanner.rbs +3 -2
  129. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  130. data/stdlib/uri/0/common.rbs +245 -123
  131. metadata +24 -4
  132. data/lib/rbs/test/spy.rb +0 -6
data/core/io.rbs CHANGED
@@ -110,7 +110,7 @@
110
110
  #
111
111
  #
112
112
  # Also available are the options offered in String#encode, which may control
113
- # conversion between external internal encoding.
113
+ # conversion between external and internal encoding.
114
114
  #
115
115
  # ## Basic IO
116
116
  #
@@ -398,7 +398,7 @@
398
398
  # # => 41
399
399
  # f.close
400
400
  #
401
- # * When a stream is read, `#.` is set to the line number for that stream:
401
+ # * When a stream is read, `$.` is set to the line number for that stream:
402
402
  #
403
403
  # f0 = File.new('t.txt')
404
404
  # f1 = File.new('t.dat')
@@ -684,14 +684,14 @@ class IO < Object
684
684
  # -->
685
685
  # Sets auto-close flag.
686
686
  #
687
- # f = open("/dev/null")
688
- # IO.for_fd(f.fileno)
689
- # # ...
690
- # f.gets # may cause Errno::EBADF
687
+ # f = File.open(File::NULL)
688
+ # IO.for_fd(f.fileno).close
689
+ # f.gets # raises Errno::EBADF
691
690
  #
692
- # f = open("/dev/null")
693
- # IO.for_fd(f.fileno).autoclose = false
694
- # # ...
691
+ # f = File.open(File::NULL)
692
+ # g = IO.for_fd(f.fileno)
693
+ # g.autoclose = false
694
+ # g.close
695
695
  # f.gets # won't cause Errno::EBADF
696
696
  #
697
697
  def autoclose=: (boolish bool) -> boolish
@@ -700,8 +700,8 @@ class IO < Object
700
700
  # rdoc-file=io.c
701
701
  # - ios.autoclose? -> true or false
702
702
  # -->
703
- # Returns `true` if the underlying file descriptor of *ios* will be closed
704
- # automatically at its finalization, otherwise `false`.
703
+ # Returns `true` if the underlying file descriptor of *ios* will be closed at
704
+ # its finalization or at calling #close, otherwise `false`.
705
705
  #
706
706
  def autoclose?: () -> bool
707
707
 
@@ -764,7 +764,7 @@ class IO < Object
764
764
  # -->
765
765
  # Sets a close-on-exec flag.
766
766
  #
767
- # f = open("/dev/null")
767
+ # f = File.open(File::NULL)
768
768
  # f.close_on_exec = true
769
769
  # system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory
770
770
  # f.closed? #=> false
@@ -976,8 +976,6 @@ class IO < Object
976
976
  # not behave as you intend with IO#eof?, unless you call IO#rewind first (which
977
977
  # is not available for some streams).
978
978
  #
979
- # IO#eof? is an alias for IO#eof.
980
- #
981
979
  def eof: () -> bool
982
980
 
983
981
  # <!--
@@ -988,7 +986,7 @@ class IO < Object
988
986
  # provides a mechanism for issuing low-level commands to control or query a
989
987
  # file-oriented I/O stream. Arguments and results are platform dependent.
990
988
  #
991
- # If +argument is a number, its value is passed directly; if it is a string, it
989
+ # If `argument` is a number, its value is passed directly; if it is a string, it
992
990
  # is interpreted as a binary sequence of bytes. (Array#pack might be a useful
993
991
  # way to build this string.)
994
992
  #
@@ -1018,8 +1016,6 @@ class IO < Object
1018
1016
  # File.open('t.txt').fileno # => 10
1019
1017
  # f.close
1020
1018
  #
1021
- # IO#to_i is an alias for IO#fileno.
1022
- #
1023
1019
  def fileno: () -> Integer
1024
1020
 
1025
1021
  # <!--
@@ -1160,7 +1156,8 @@ class IO < Object
1160
1156
  # f.gets(chomp: true) # => nil
1161
1157
  # f.close
1162
1158
  #
1163
- def gets: (?String sep, ?Integer limit) -> String?
1159
+ def gets: (string? sep, ?int limit, ?chomp: boolish) -> String?
1160
+ | (?int limit, ?chomp: boolish) -> String?
1164
1161
 
1165
1162
  # <!--
1166
1163
  # rdoc-file=io.c
@@ -1256,8 +1253,6 @@ class IO < Object
1256
1253
  # f = File.new('/dev/tty').isatty #=> true
1257
1254
  # f.close
1258
1255
  #
1259
- # IO#tty? is an alias for IO#isatty.
1260
- #
1261
1256
  def isatty: () -> bool
1262
1257
 
1263
1258
  # <!--
@@ -1537,7 +1532,8 @@ class IO < Object
1537
1532
  #
1538
1533
  # Related: IO#write.
1539
1534
  #
1540
- def read: (?int? length, ?string outbuf) -> String?
1535
+ def read: (?nil, ?string outbuf) -> String
1536
+ | (int? length, ?string outbuf) -> String?
1541
1537
 
1542
1538
  # <!--
1543
1539
  # rdoc-file=io.rb
@@ -1632,7 +1628,7 @@ class IO < Object
1632
1628
  def readchar: () -> String
1633
1629
 
1634
1630
  # <!--
1635
- # rdoc-file=io.c
1631
+ # rdoc-file=io.rb
1636
1632
  # - readline(sep = $/, chomp: false) -> string
1637
1633
  # - readline(limit, chomp: false) -> string
1638
1634
  # - readline(sep, limit, chomp: false) -> string
@@ -1915,16 +1911,19 @@ class IO < Object
1915
1911
  # -->
1916
1912
  # See [Encodings](rdoc-ref:File@Encodings).
1917
1913
  #
1918
- # Argument `ext_enc`, if given, must be an Encoding object; it is assigned as
1919
- # the encoding for the stream.
1914
+ # Argument `ext_enc`, if given, must be an Encoding object or a String with the
1915
+ # encoding name; it is assigned as the encoding for the stream.
1920
1916
  #
1921
- # Argument `int_enc`, if given, must be an Encoding object; it is assigned as
1922
- # the encoding for the internal string.
1917
+ # Argument `int_enc`, if given, must be an Encoding object or a String with the
1918
+ # encoding name; it is assigned as the encoding for the internal string.
1923
1919
  #
1924
1920
  # Argument `'ext_enc:int_enc'`, if given, is a string containing two
1925
1921
  # colon-separated encoding names; corresponding Encoding objects are assigned as
1926
1922
  # the external and internal encodings for the stream.
1927
1923
  #
1924
+ # If the external encoding of a string is binary/ASCII-8BIT, the internal
1925
+ # encoding of the string is set to nil, since no transcoding is needed.
1926
+ #
1928
1927
  # Optional keyword arguments `enc_opts` specify [Encoding
1929
1928
  # options](rdoc-ref:encodings.rdoc@Encoding+Options).
1930
1929
  #
@@ -2066,8 +2065,6 @@ class IO < Object
2066
2065
  #
2067
2066
  # Related: IO#pos=, IO#seek.
2068
2067
  #
2069
- # IO#pos is an alias for IO#tell.
2070
- #
2071
2068
  def tell: () -> Integer
2072
2069
 
2073
2070
  # <!-- rdoc-file=io.c -->
@@ -2082,8 +2079,6 @@ class IO < Object
2082
2079
  #
2083
2080
  # Related: IO#pos=, IO#seek.
2084
2081
  #
2085
- # IO#pos is an alias for IO#tell.
2086
- #
2087
2082
  alias pos tell
2088
2083
 
2089
2084
  # <!--
@@ -2099,8 +2094,11 @@ class IO < Object
2099
2094
  # - timeout = duration -> duration
2100
2095
  # - timeout = nil -> nil
2101
2096
  # -->
2102
- # Set the internal timeout to the specified duration or nil. The timeout applies
2103
- # to all blocking operations where possible.
2097
+ # Sets the internal timeout to the specified duration or nil. The timeout
2098
+ # applies to all blocking operations where possible.
2099
+ #
2100
+ # When the operation performs longer than the timeout set, IO::TimeoutError is
2101
+ # raised.
2104
2102
  #
2105
2103
  # This affects the following methods (but is not limited to): #gets, #puts,
2106
2104
  # #read, #write, #wait_readable and #wait_writable. This also affects blocking
@@ -2131,8 +2129,6 @@ class IO < Object
2131
2129
  # f = File.new('/dev/tty').isatty #=> true
2132
2130
  # f.close
2133
2131
  #
2134
- # IO#tty? is an alias for IO#isatty.
2135
- #
2136
2132
  alias tty? isatty
2137
2133
 
2138
2134
  # <!--
@@ -2298,7 +2294,6 @@ class IO < Object
2298
2294
 
2299
2295
  # <!--
2300
2296
  # rdoc-file=io.c
2301
- # - IO.binread(command, length = nil, offset = 0) -> string or nil
2302
2297
  # - IO.binread(path, length = nil, offset = 0) -> string or nil
2303
2298
  # -->
2304
2299
  # Behaves like IO.read, except that the stream is opened in binary mode with
@@ -2312,7 +2307,6 @@ class IO < Object
2312
2307
 
2313
2308
  # <!--
2314
2309
  # rdoc-file=io.c
2315
- # - IO.binwrite(command, string, offset = 0) -> integer
2316
2310
  # - IO.binwrite(path, string, offset = 0) -> integer
2317
2311
  # -->
2318
2312
  # Behaves like IO.write, except that the stream is opened in binary mode with
@@ -2540,19 +2534,25 @@ class IO < Object
2540
2534
  #
2541
2535
  # Raises exceptions that IO.pipe and Kernel.spawn raise.
2542
2536
  #
2543
- def self.popen: (string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
2544
- | (Hash[string, string?] env, string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
2545
- | [X] (string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
2546
- | [X] (Hash[string, string?] env, string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
2537
+ def self.popen: (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
2538
+ | (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
2539
+ | [X] (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
2540
+ | [X] (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
2541
+
2542
+ # The command can be given as:
2543
+ #
2544
+ # * Array of string `["ruby", "-v"]`, or
2545
+ # * Array of string with the first element of array `[["ruby", "RUBY"], "-v"]`
2546
+ #
2547
+ # But RBS cannot define such a type. So this is simply a union of `string` or `[String, String]`.
2548
+ #
2549
+ type cmd_array = array[string | [String, String]]
2547
2550
 
2548
2551
  # <!--
2549
2552
  # rdoc-file=io.c
2550
2553
  # - IO.foreach(path, sep = $/, **opts) {|line| block } -> nil
2551
2554
  # - IO.foreach(path, limit, **opts) {|line| block } -> nil
2552
2555
  # - IO.foreach(path, sep, limit, **opts) {|line| block } -> nil
2553
- # - IO.foreach(command, sep = $/, **opts) {|line| block } -> nil
2554
- # - IO.foreach(command, limit, **opts) {|line| block } -> nil
2555
- # - IO.foreach(command, sep, limit, **opts) {|line| block } -> nil
2556
2556
  # - IO.foreach(...) -> an_enumerator
2557
2557
  # -->
2558
2558
  # Calls the block with each successive line read from the stream.
@@ -2561,17 +2561,7 @@ class IO < Object
2561
2561
  # potential security vulnerabilities if called with untrusted input; see
2562
2562
  # [Command Injection](rdoc-ref:command_injection.rdoc).
2563
2563
  #
2564
- # The first argument must be a string that is one of the following:
2565
- #
2566
- # * Path: if `self` is a subclass of IO (File, for example), or if the string
2567
- # *does* *not* start with the pipe character (`'|'`), the string is the path
2568
- # to a file.
2569
- # * Command: if `self` is the class IO, and if the string starts with the pipe
2570
- # character, the rest of the string is a command to be executed as a
2571
- # subprocess. This usage has potential security vulnerabilities if called
2572
- # with untrusted input; see [Command
2573
- # Injection](rdoc-ref:command_injection.rdoc).
2574
- #
2564
+ # The first argument must be a string that is the path to a file.
2575
2565
  #
2576
2566
  # With only argument `path` given, parses lines from the file at the given
2577
2567
  # `path`, as determined by the default line separator, and calls the block with
@@ -2631,7 +2621,7 @@ class IO < Object
2631
2621
  #
2632
2622
  # * [Open Options](rdoc-ref:IO@Open+Options).
2633
2623
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2634
- # * [Line Options](rdoc-ref:IO@Line+Options).
2624
+ # * [Line Options](rdoc-ref:IO@Line+IO).
2635
2625
  #
2636
2626
  #
2637
2627
  # Returns an Enumerator if no block is given.
@@ -2644,9 +2634,9 @@ class IO < Object
2644
2634
  # - IO.pipe(**opts) -> [read_io, write_io]
2645
2635
  # - IO.pipe(enc, **opts) -> [read_io, write_io]
2646
2636
  # - IO.pipe(ext_enc, int_enc, **opts) -> [read_io, write_io]
2647
- # - IO.pipe(**opts) {|read_io, write_io] ...} -> object
2648
- # - IO.pipe(enc, **opts) {|read_io, write_io] ...} -> object
2649
- # - IO.pipe(ext_enc, int_enc, **opts) {|read_io, write_io] ...} -> object
2637
+ # - IO.pipe(**opts) {|read_io, write_io| ...} -> object
2638
+ # - IO.pipe(enc, **opts) {|read_io, write_io| ...} -> object
2639
+ # - IO.pipe(ext_enc, int_enc, **opts) {|read_io, write_io| ...} -> object
2650
2640
  # -->
2651
2641
  # Creates a pair of pipe endpoints, `read_io` and `write_io`, connected to each
2652
2642
  # other.
@@ -2722,7 +2712,6 @@ class IO < Object
2722
2712
 
2723
2713
  # <!--
2724
2714
  # rdoc-file=io.c
2725
- # - IO.read(command, length = nil, offset = 0, **opts) -> string or nil
2726
2715
  # - IO.read(path, length = nil, offset = 0, **opts) -> string or nil
2727
2716
  # -->
2728
2717
  # Opens the stream, reads and returns some or all of its content, and closes the
@@ -2732,19 +2721,7 @@ class IO < Object
2732
2721
  # potential security vulnerabilities if called with untrusted input; see
2733
2722
  # [Command Injection](rdoc-ref:command_injection.rdoc).
2734
2723
  #
2735
- # The first argument must be a string; its meaning depends on whether it starts
2736
- # with the pipe character (`'|'`):
2737
- #
2738
- # * If so (and if `self` is IO), the rest of the string is a command to be
2739
- # executed as a subprocess.
2740
- # * Otherwise, the string is the path to a file.
2741
- #
2742
- #
2743
- # With only argument `command` given, executes the command in a shell, returns
2744
- # its entire $stdout:
2745
- #
2746
- # IO.read('| cat t.txt')
2747
- # # => "First line\nSecond line\n\nThird line\nFourth line\n"
2724
+ # The first argument must be a string that is the path to a file.
2748
2725
  #
2749
2726
  # With only argument `path` given, reads in text mode and returns the entire
2750
2727
  # content of the file at the given path:
@@ -2756,8 +2733,6 @@ class IO < Object
2756
2733
  # when encountering certain special bytes. Consider using IO.binread if all
2757
2734
  # bytes in the file should be read.
2758
2735
  #
2759
- # For both forms, command and path, the remaining arguments are the same.
2760
- #
2761
2736
  # With argument `length`, returns `length` bytes if available:
2762
2737
  #
2763
2738
  # IO.read('t.txt', 7) # => "First l"
@@ -2779,9 +2754,6 @@ class IO < Object
2779
2754
 
2780
2755
  # <!--
2781
2756
  # rdoc-file=io.c
2782
- # - IO.readlines(command, sep = $/, **opts) -> array
2783
- # - IO.readlines(command, limit, **opts) -> array
2784
- # - IO.readlines(command, sep, limit, **opts) -> array
2785
2757
  # - IO.readlines(path, sep = $/, **opts) -> array
2786
2758
  # - IO.readlines(path, limit, **opts) -> array
2787
2759
  # - IO.readlines(path, sep, limit, **opts) -> array
@@ -2792,20 +2764,7 @@ class IO < Object
2792
2764
  # potential security vulnerabilities if called with untrusted input; see
2793
2765
  # [Command Injection](rdoc-ref:command_injection.rdoc).
2794
2766
  #
2795
- # The first argument must be a string; its meaning depends on whether it starts
2796
- # with the pipe character (`'|'`):
2797
- #
2798
- # * If so (and if `self` is IO), the rest of the string is a command to be
2799
- # executed as a subprocess.
2800
- # * Otherwise, the string is the path to a file.
2801
- #
2802
- #
2803
- # With only argument `command` given, executes the command in a shell, parses
2804
- # its $stdout into lines, as determined by the default line separator, and
2805
- # returns those lines in an array:
2806
- #
2807
- # IO.readlines('| cat t.txt')
2808
- # # => ["First line\n", "Second line\n", "\n", "Third line\n", "Fourth line\n"]
2767
+ # The first argument must be a string that is the path to a file.
2809
2768
  #
2810
2769
  # With only argument `path` given, parses lines from the file at the given
2811
2770
  # `path`, as determined by the default line separator, and returns those lines
@@ -2814,8 +2773,6 @@ class IO < Object
2814
2773
  # IO.readlines('t.txt')
2815
2774
  # # => ["First line\n", "Second line\n", "\n", "Third line\n", "Fourth line\n"]
2816
2775
  #
2817
- # For both forms, command and path, the remaining arguments are the same.
2818
- #
2819
2776
  # With argument `sep` given, parses lines as determined by that line separator
2820
2777
  # (see [Line Separator](rdoc-ref:IO@Line+Separator)):
2821
2778
  #
@@ -2844,7 +2801,7 @@ class IO < Object
2844
2801
  #
2845
2802
  # * [Open Options](rdoc-ref:IO@Open+Options).
2846
2803
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2847
- # * [Line Options](rdoc-ref:IO@Line+Options).
2804
+ # * [Line Options](rdoc-ref:IO@Line+IO).
2848
2805
  #
2849
2806
  def self.readlines: (String | _ToPath name, ?String sep, ?Integer limit, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?chomp: boolish) -> ::Array[String]
2850
2807
 
@@ -3022,7 +2979,6 @@ class IO < Object
3022
2979
 
3023
2980
  # <!--
3024
2981
  # rdoc-file=io.c
3025
- # - IO.write(command, data, **opts) -> integer
3026
2982
  # - IO.write(path, data, offset = 0, **opts) -> integer
3027
2983
  # -->
3028
2984
  # Opens the stream, writes the given `data` to it, and closes the stream;
@@ -3032,25 +2988,10 @@ class IO < Object
3032
2988
  # potential security vulnerabilities if called with untrusted input; see
3033
2989
  # [Command Injection](rdoc-ref:command_injection.rdoc).
3034
2990
  #
3035
- # The first argument must be a string; its meaning depends on whether it starts
3036
- # with the pipe character (`'|'`):
3037
- #
3038
- # * If so (and if `self` is IO), the rest of the string is a command to be
3039
- # executed as a subprocess.
3040
- # * Otherwise, the string is the path to a file.
2991
+ # The first argument must be a string that is the path to a file.
3041
2992
  #
3042
- #
3043
- # With argument `command` given, executes the command in a shell, passes `data`
3044
- # through standard input, writes its output to $stdout, and returns the length
3045
- # of the given `data`:
3046
- #
3047
- # IO.write('| cat', 'Hello World!') # => 12
3048
- #
3049
- # Output:
3050
- #
3051
- # Hello World!
3052
- #
3053
- # With argument `path` given, writes the given `data` to the file at that path:
2993
+ # With only argument `path` given, writes the given `data` to the file at that
2994
+ # path:
3054
2995
  #
3055
2996
  # IO.write('t.tmp', 'abc') # => 3
3056
2997
  # File.read('t.tmp') # => "abc"
@@ -3200,8 +3141,6 @@ class IO < Object
3200
3141
  #
3201
3142
  # Returns an Enumerator if no block is given.
3202
3143
  #
3203
- # IO#each is an alias for IO#each_line.
3204
- #
3205
3144
  def each_line: (?String sep, ?Integer limit) { (String line) -> void } -> self
3206
3145
  | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
3207
3146
 
@@ -3307,8 +3246,6 @@ class IO < Object
3307
3246
  #
3308
3247
  # Returns an Enumerator if no block is given.
3309
3248
  #
3310
- # IO#each is an alias for IO#each_line.
3311
- #
3312
3249
  alias each each_line
3313
3250
 
3314
3251
  # <!-- rdoc-file=io.c -->
@@ -3342,8 +3279,6 @@ class IO < Object
3342
3279
  # not behave as you intend with IO#eof?, unless you call IO#rewind first (which
3343
3280
  # is not available for some streams).
3344
3281
  #
3345
- # IO#eof? is an alias for IO#eof.
3346
- #
3347
3282
  alias eof? eof
3348
3283
 
3349
3284
  # <!-- rdoc-file=io.c -->
@@ -3355,8 +3290,6 @@ class IO < Object
3355
3290
  # File.open('t.txt').fileno # => 10
3356
3291
  # f.close
3357
3292
  #
3358
- # IO#to_i is an alias for IO#fileno.
3359
- #
3360
3293
  alias to_i fileno
3361
3294
  end
3362
3295