rbs 3.6.1 → 3.9.5

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 (268) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -2
  3. data/.github/workflows/dependabot.yml +1 -1
  4. data/.github/workflows/ruby.yml +34 -10
  5. data/.github/workflows/windows.yml +20 -3
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +26 -1
  8. data/CHANGELOG.md +241 -0
  9. data/Rakefile +54 -4
  10. data/config.yml +317 -0
  11. data/core/array.rbs +1756 -1591
  12. data/core/basic_object.rbs +38 -35
  13. data/core/comparable.rbs +1 -1
  14. data/core/complex.rbs +166 -94
  15. data/core/data.rbs +2 -2
  16. data/core/dir.rbs +2 -18
  17. data/core/encoding.rbs +12 -32
  18. data/core/enumerable.rbs +270 -266
  19. data/core/enumerator.rbs +14 -4
  20. data/core/env.rbs +1 -1
  21. data/core/errno.rbs +33 -16
  22. data/core/errors.rbs +6 -2
  23. data/core/exception.rbs +342 -167
  24. data/core/fiber.rbs +3 -2
  25. data/core/file.rbs +26 -75
  26. data/core/float.rbs +125 -72
  27. data/core/gc.rbs +158 -42
  28. data/core/hash.rbs +122 -143
  29. data/core/integer.rbs +79 -50
  30. data/core/io/buffer.rbs +49 -43
  31. data/core/io.rbs +108 -151
  32. data/core/kernel.rbs +341 -209
  33. data/core/match_data.rbs +76 -2
  34. data/core/math.rbs +0 -36
  35. data/core/method.rbs +2 -2
  36. data/core/module.rbs +32 -27
  37. data/core/nil_class.rbs +2 -2
  38. data/core/numeric.rbs +101 -104
  39. data/core/object.rbs +1 -5
  40. data/core/object_space/weak_key_map.rbs +3 -4
  41. data/core/object_space.rbs +3 -3
  42. data/core/proc.rbs +82 -14
  43. data/core/process.rbs +110 -58
  44. data/core/ractor.rbs +57 -4
  45. data/core/range.rbs +114 -87
  46. data/core/rational.rbs +0 -2
  47. data/core/rbs/unnamed/argf.rbs +237 -36
  48. data/core/rbs/unnamed/env_class.rbs +35 -53
  49. data/core/rbs/unnamed/random.rbs +1 -2
  50. data/core/regexp.rbs +10 -56
  51. data/core/ruby_vm.rbs +88 -9
  52. data/core/rubygems/config_file.rbs +3 -0
  53. data/core/rubygems/errors.rbs +3 -6
  54. data/core/rubygems/platform.rbs +0 -9
  55. data/core/rubygems/rubygems.rbs +3 -6
  56. data/core/rubygems/version.rbs +8 -8
  57. data/core/set.rbs +4 -16
  58. data/core/string.rbs +271 -264
  59. data/core/struct.rbs +6 -18
  60. data/core/symbol.rbs +14 -21
  61. data/core/thread.rbs +32 -35
  62. data/core/time.rbs +131 -50
  63. data/core/trace_point.rbs +124 -113
  64. data/core/true_class.rbs +0 -1
  65. data/core/unbound_method.rbs +1 -1
  66. data/core/warning.rbs +9 -2
  67. data/docs/architecture.md +1 -1
  68. data/docs/syntax.md +17 -10
  69. data/ext/rbs_extension/extconf.rb +11 -0
  70. data/ext/rbs_extension/location.c +61 -29
  71. data/ext/rbs_extension/location.h +4 -3
  72. data/ext/rbs_extension/main.c +23 -1
  73. data/ext/rbs_extension/parser.c +506 -517
  74. data/ext/rbs_extension/parserstate.c +109 -30
  75. data/ext/rbs_extension/parserstate.h +6 -4
  76. data/ext/rbs_extension/rbs_extension.h +1 -10
  77. data/{ext/rbs_extension → include/rbs}/constants.h +21 -19
  78. data/include/rbs/ruby_objs.h +72 -0
  79. data/include/rbs/util/rbs_constant_pool.h +219 -0
  80. data/include/rbs.h +7 -0
  81. data/lib/rbs/annotate/annotations.rb +3 -3
  82. data/lib/rbs/annotate/rdoc_source.rb +2 -2
  83. data/lib/rbs/ast/declarations.rb +9 -4
  84. data/lib/rbs/ast/directives.rb +10 -0
  85. data/lib/rbs/ast/members.rb +2 -0
  86. data/lib/rbs/ast/type_param.rb +2 -12
  87. data/lib/rbs/cli/diff.rb +3 -3
  88. data/lib/rbs/cli/validate.rb +2 -1
  89. data/lib/rbs/cli.rb +16 -16
  90. data/lib/rbs/collection/config/lockfile_generator.rb +58 -8
  91. data/lib/rbs/collection/config.rb +5 -3
  92. data/lib/rbs/collection/sources/rubygems.rb +1 -1
  93. data/lib/rbs/collection.rb +1 -0
  94. data/lib/rbs/definition.rb +51 -34
  95. data/lib/rbs/definition_builder/ancestor_builder.rb +5 -3
  96. data/lib/rbs/definition_builder.rb +83 -24
  97. data/lib/rbs/environment.rb +33 -18
  98. data/lib/rbs/environment_loader.rb +6 -1
  99. data/lib/rbs/errors.rb +24 -0
  100. data/lib/rbs/locator.rb +2 -0
  101. data/lib/rbs/method_type.rb +2 -0
  102. data/lib/rbs/namespace.rb +1 -0
  103. data/lib/rbs/parser_aux.rb +40 -3
  104. data/lib/rbs/prototype/rb.rb +20 -12
  105. data/lib/rbs/prototype/rbi.rb +11 -6
  106. data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
  107. data/lib/rbs/prototype/runtime.rb +7 -5
  108. data/lib/rbs/subtractor.rb +3 -3
  109. data/lib/rbs/test/hook.rb +47 -42
  110. data/lib/rbs/test/type_check.rb +7 -5
  111. data/lib/rbs/type_name.rb +14 -9
  112. data/lib/rbs/types.rb +63 -14
  113. data/lib/rbs/unit_test/spy.rb +4 -2
  114. data/lib/rbs/unit_test/type_assertions.rb +19 -13
  115. data/lib/rbs/unit_test/with_aliases.rb +3 -1
  116. data/lib/rbs/validator.rb +7 -1
  117. data/lib/rbs/version.rb +1 -1
  118. data/lib/rbs/writer.rb +10 -5
  119. data/lib/rbs.rb +1 -0
  120. data/lib/rdoc_plugin/parser.rb +2 -2
  121. data/rbs.gemspec +6 -2
  122. data/sig/ancestor_graph.rbs +5 -5
  123. data/sig/annotate/rdoc_source.rbs +2 -0
  124. data/sig/cli.rbs +2 -0
  125. data/sig/collection/config/lockfile_generator.rbs +9 -1
  126. data/sig/declarations.rbs +10 -3
  127. data/sig/definition.rbs +80 -12
  128. data/sig/definition_builder.rbs +18 -4
  129. data/sig/directives.rbs +17 -1
  130. data/sig/environment.rbs +3 -1
  131. data/sig/errors.rbs +19 -0
  132. data/sig/namespace.rbs +2 -3
  133. data/sig/parser.rbs +5 -1
  134. data/sig/prototype/rb.rbs +1 -1
  135. data/sig/resolver/constant_resolver.rbs +2 -2
  136. data/sig/resolver/context.rbs +1 -1
  137. data/sig/subtractor.rbs +1 -1
  138. data/sig/test/type_check.rbs +2 -2
  139. data/sig/type_alias_dependency.rbs +2 -2
  140. data/sig/type_alias_regularity.rbs +6 -6
  141. data/sig/type_param.rbs +4 -4
  142. data/sig/typename.rbs +8 -5
  143. data/sig/types.rbs +1 -1
  144. data/sig/unit_test/spy.rbs +2 -0
  145. data/sig/unit_test/type_assertions.rbs +2 -0
  146. data/sig/use_map.rbs +1 -1
  147. data/sig/validator.rbs +6 -2
  148. data/sig/vendorer.rbs +1 -1
  149. data/sig/writer.rbs +1 -1
  150. data/{ext/rbs_extension → src}/constants.c +35 -36
  151. data/src/ruby_objs.c +799 -0
  152. data/src/util/rbs_constant_pool.c +342 -0
  153. data/stdlib/base64/0/base64.rbs +0 -9
  154. data/stdlib/benchmark/0/benchmark.rbs +11 -2
  155. data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
  156. data/stdlib/cgi/0/core.rbs +60 -3
  157. data/stdlib/cgi/0/manifest.yaml +1 -0
  158. data/stdlib/coverage/0/coverage.rbs +0 -3
  159. data/stdlib/csv/0/csv.rbs +18 -58
  160. data/stdlib/csv/0/manifest.yaml +1 -0
  161. data/stdlib/date/0/date.rbs +27 -42
  162. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -6
  163. data/stdlib/digest/0/digest.rbs +25 -2
  164. data/stdlib/erb/0/erb.rbs +0 -1
  165. data/stdlib/etc/0/etc.rbs +51 -34
  166. data/stdlib/fileutils/0/fileutils.rbs +3 -44
  167. data/stdlib/io-console/0/io-console.rbs +69 -15
  168. data/stdlib/ipaddr/0/ipaddr.rbs +16 -4
  169. data/stdlib/json/0/json.rbs +107 -120
  170. data/stdlib/logger/0/log_device.rbs +1 -1
  171. data/stdlib/logger/0/logger.rbs +3 -18
  172. data/stdlib/minitest/0/kernel.rbs +2 -2
  173. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
  174. data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
  175. data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
  176. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
  177. data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
  178. data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
  179. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  180. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  181. data/stdlib/minitest/0/minitest/mock.rbs +9 -5
  182. data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
  183. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
  184. data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
  185. data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
  186. data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
  187. data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
  188. data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
  189. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
  190. data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
  191. data/stdlib/minitest/0/minitest/spec.rbs +1 -1
  192. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
  193. data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
  194. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +1 -1
  195. data/stdlib/minitest/0/minitest/test.rbs +7 -14
  196. data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
  197. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  198. data/stdlib/minitest/0/minitest/unit.rbs +1 -2
  199. data/stdlib/minitest/0/minitest.rbs +41 -892
  200. data/stdlib/monitor/0/monitor.rbs +13 -4
  201. data/stdlib/net-http/0/net-http.rbs +42 -109
  202. data/stdlib/nkf/0/nkf.rbs +30 -0
  203. data/stdlib/objspace/0/objspace.rbs +1 -2
  204. data/stdlib/observable/0/observable.rbs +1 -1
  205. data/stdlib/open-uri/0/manifest.yaml +1 -0
  206. data/stdlib/open-uri/0/open-uri.rbs +52 -0
  207. data/stdlib/open3/0/open3.rbs +0 -8
  208. data/stdlib/openssl/0/manifest.yaml +1 -0
  209. data/stdlib/openssl/0/openssl.rbs +235 -143
  210. data/stdlib/optparse/0/optparse.rbs +58 -18
  211. data/stdlib/pathname/0/pathname.rbs +2 -8
  212. data/stdlib/pp/0/pp.rbs +3 -1
  213. data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
  214. data/stdlib/pstore/0/pstore.rbs +0 -6
  215. data/stdlib/psych/0/core_ext.rbs +12 -0
  216. data/stdlib/psych/0/psych.rbs +15 -4
  217. data/stdlib/pty/0/pty.rbs +46 -4
  218. data/stdlib/rdoc/0/code_object.rbs +0 -4
  219. data/stdlib/rdoc/0/markup.rbs +10 -12
  220. data/stdlib/rdoc/0/rdoc.rbs +13 -8
  221. data/stdlib/resolv/0/resolv.rbs +21 -12
  222. data/stdlib/ripper/0/ripper.rbs +0 -2
  223. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  224. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  225. data/stdlib/singleton/0/singleton.rbs +0 -1
  226. data/stdlib/socket/0/addrinfo.rbs +1 -2
  227. data/stdlib/socket/0/basic_socket.rbs +0 -5
  228. data/stdlib/socket/0/socket.rbs +32 -27
  229. data/stdlib/socket/0/tcp_server.rbs +0 -3
  230. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  231. data/stdlib/socket/0/udp_socket.rbs +0 -1
  232. data/stdlib/socket/0/unix_server.rbs +0 -3
  233. data/stdlib/socket/0/unix_socket.rbs +4 -2
  234. data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +1 -1
  235. data/stdlib/strscan/0/string_scanner.rbs +1265 -422
  236. data/stdlib/tempfile/0/tempfile.rbs +135 -28
  237. data/stdlib/time/0/time.rbs +48 -35
  238. data/stdlib/timeout/0/timeout.rbs +11 -8
  239. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  240. data/stdlib/tsort/0/tsort.rbs +0 -4
  241. data/stdlib/uri/0/common.rbs +28 -30
  242. data/stdlib/uri/0/ftp.rbs +1 -1
  243. data/stdlib/uri/0/generic.rbs +22 -18
  244. data/stdlib/uri/0/http.rbs +2 -2
  245. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  246. data/stdlib/zlib/0/buf_error.rbs +1 -70
  247. data/stdlib/zlib/0/data_error.rbs +1 -70
  248. data/stdlib/zlib/0/deflate.rbs +8 -72
  249. data/stdlib/zlib/0/error.rbs +1 -70
  250. data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
  251. data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
  252. data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
  253. data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
  254. data/stdlib/zlib/0/gzip_file.rbs +1 -71
  255. data/stdlib/zlib/0/gzip_reader.rbs +3 -74
  256. data/stdlib/zlib/0/gzip_writer.rbs +1 -70
  257. data/stdlib/zlib/0/inflate.rbs +4 -71
  258. data/stdlib/zlib/0/mem_error.rbs +1 -70
  259. data/stdlib/zlib/0/need_dict.rbs +1 -70
  260. data/stdlib/zlib/0/stream_end.rbs +1 -70
  261. data/stdlib/zlib/0/stream_error.rbs +1 -70
  262. data/stdlib/zlib/0/version_error.rbs +1 -70
  263. data/stdlib/zlib/0/zlib.rbs +0 -2
  264. data/stdlib/zlib/0/zstream.rbs +4 -72
  265. metadata +17 -13
  266. data/ext/rbs_extension/ruby_objs.c +0 -602
  267. data/ext/rbs_extension/ruby_objs.h +0 -51
  268. data/stdlib/minitest/0/manifest.yaml +0 -2
data/core/io.rbs CHANGED
@@ -21,7 +21,6 @@
21
21
  # * $stderr.
22
22
  # * Instances of class File.
23
23
  #
24
- #
25
24
  # An instance of IO may be created using:
26
25
  #
27
26
  # * IO.new: returns a new IO object for the given integer file descriptor.
@@ -31,7 +30,6 @@
31
30
  # * Kernel#open: Returns a new IO object connected to a given source: stream,
32
31
  # file, or subprocess.
33
32
  #
34
- #
35
33
  # Like a File stream, an IO stream has:
36
34
  #
37
35
  # * A read/write mode, which may be read-only, write-only, or read/write; see
@@ -40,7 +38,6 @@
40
38
  # Mode](rdoc-ref:File@Data+Mode).
41
39
  # * Internal and external encodings; see [Encodings](rdoc-ref:File@Encodings).
42
40
  #
43
- #
44
41
  # And like other IO streams, it has:
45
42
  #
46
43
  # * A position, which determines where in the stream the next read or write is
@@ -49,7 +46,6 @@
49
46
  # from the position mentioned above); see [Line
50
47
  # Number](rdoc-ref:IO@Line+Number).
51
48
  #
52
- #
53
49
  # ## Extension `io/console`
54
50
  #
55
51
  # Extension `io/console` provides numerous methods for interacting with the
@@ -108,7 +104,6 @@
108
104
  # * `:path:` If a string value is provided, it is used in #inspect and is
109
105
  # available as #path method.
110
106
  #
111
- #
112
107
  # Also available are the options offered in String#encode, which may control
113
108
  # conversion between external and internal encoding.
114
109
  #
@@ -122,7 +117,6 @@
122
117
  # * IO#write: Writes zero or more strings to the stream; each given object
123
118
  # that is not already a string is converted via `to_s`.
124
119
  #
125
- #
126
120
  # ### Position
127
121
  #
128
122
  # An IO stream has a nonnegative integer *position*, which is the byte offset at
@@ -130,6 +124,9 @@
130
124
  # line number zero); method `rewind` resets the position (and line number) to
131
125
  # zero.
132
126
  #
127
+ # These methods discard [buffers](rdoc-ref:IO@Buffering) and the
128
+ # Encoding::Converter instances used for that IO.
129
+ #
133
130
  # The relevant methods:
134
131
  #
135
132
  # * IO#tell (aliased as `#pos`): Returns the current position (in bytes) in
@@ -142,7 +139,6 @@
142
139
  # * IO#rewind: Positions the stream at the beginning (also resetting the line
143
140
  # number).
144
141
  #
145
- #
146
142
  # ### Open and Closed Streams
147
143
  #
148
144
  # A new IO stream may be open for reading, open for writing, or both.
@@ -158,7 +154,6 @@
158
154
  # * IO#close_write: Closes the stream for writing.
159
155
  # * IO#closed?: Returns whether the stream is closed.
160
156
  #
161
- #
162
157
  # ### End-of-Stream
163
158
  #
164
159
  # You can query whether a stream is positioned at its end:
@@ -166,7 +161,6 @@
166
161
  # * IO#eof? (also aliased as `#eof`): Returns whether the stream is at
167
162
  # end-of-stream.
168
163
  #
169
- #
170
164
  # You can reposition to end-of-stream by using method IO#seek:
171
165
  #
172
166
  # f = File.new('t.txt')
@@ -184,58 +178,62 @@
184
178
  #
185
179
  # ## Line IO
186
180
  #
187
- # You can read an IO stream line-by-line using these methods:
188
- #
189
- # * IO#each_line: Reads each remaining line, passing it to the given block.
190
- # * IO#gets: Returns the next line.
191
- # * IO#readline: Like #gets, but raises an exception at end-of-stream.
192
- # * IO#readlines: Returns all remaining lines in an array.
181
+ # Class IO supports line-oriented [input](rdoc-ref:IO@Line+Input) and
182
+ # [output](rdoc-ref:IO@Line+Output)
193
183
  #
184
+ # ### Line Input
194
185
  #
195
- # Each of these reader methods accepts:
186
+ # Class IO supports line-oriented input for [files](rdoc-ref:IO@File+Line+Input)
187
+ # and [IO streams](rdoc-ref:IO@Stream+Line+Input)
196
188
  #
197
- # * An optional line separator, `sep`; see [Line
198
- # Separator](rdoc-ref:IO@Line+Separator).
199
- # * An optional line-size limit, `limit`; see [Line
200
- # Limit](rdoc-ref:IO@Line+Limit).
189
+ # #### File Line Input
201
190
  #
191
+ # You can read lines from a file using these methods:
202
192
  #
203
- # For each of these reader methods, reading may begin mid-line, depending on the
204
- # stream's position; see [Position](rdoc-ref:IO@Position):
193
+ # * IO.foreach: Reads each line and passes it to the given block.
194
+ # * IO.readlines: Reads and returns all lines in an array.
205
195
  #
206
- # f = File.new('t.txt')
207
- # f.pos = 27
208
- # f.each_line {|line| p line }
209
- # f.close
196
+ # For each of these methods:
210
197
  #
211
- # Output:
198
+ # * You can specify [open options](rdoc-ref:IO@Open+Options).
199
+ # * Line parsing depends on the effective *line separator*; see [Line
200
+ # Separator](rdoc-ref:IO@Line+Separator).
201
+ # * The length of each returned line depends on the effective *line limit*;
202
+ # see [Line Limit](rdoc-ref:IO@Line+Limit).
212
203
  #
213
- # "rth line\n"
214
- # "Fifth line\n"
204
+ # #### Stream Line Input
215
205
  #
216
- # You can write to an IO stream line-by-line using this method:
206
+ # You can read lines from an IO stream using these methods:
217
207
  #
218
- # * IO#puts: Writes objects to the stream.
208
+ # * IO#each_line: Reads each remaining line, passing it to the given block.
209
+ # * IO#gets: Returns the next line.
210
+ # * IO#readline: Like #gets, but raises an exception at end-of-stream.
211
+ # * IO#readlines: Returns all remaining lines in an array.
219
212
  #
213
+ # For each of these methods:
220
214
  #
221
- # ### Line Separator
215
+ # * Reading may begin mid-line, depending on the stream's *position*; see
216
+ # [Position](rdoc-ref:IO@Position).
217
+ # * Line parsing depends on the effective *line separator*; see [Line
218
+ # Separator](rdoc-ref:IO@Line+Separator).
219
+ # * The length of each returned line depends on the effective *line limit*;
220
+ # see [Line Limit](rdoc-ref:IO@Line+Limit).
222
221
  #
223
- # Each of these methods uses a *line separator*, which is the string that
224
- # delimits lines:
222
+ # ##### Line Separator
225
223
  #
226
- # * IO.foreach.
227
- # * IO.readlines.
228
- # * IO#each_line.
229
- # * IO#gets.
230
- # * IO#readline.
231
- # * IO#readlines.
224
+ # Each of the [line input methods](rdoc-ref:IO@Line+Input) uses a *line
225
+ # separator*: the string that determines what is considered a line; it is
226
+ # sometimes called the *input record separator*.
232
227
  #
228
+ # The default line separator is taken from global variable `$/`, whose initial
229
+ # value is `"\n"`.
233
230
  #
234
- # The default line separator is the given by the global variable `$/`, whose
235
- # value is by default `"\n"`. The line to be read next is all data from the
236
- # current position to the next line separator:
231
+ # Generally, the line to be read next is all data from the current
232
+ # [position](rdoc-ref:IO@Position) to the next line separator (but see [Special
233
+ # Line Separator Values](rdoc-ref:IO@Special+Line+Separator+Values)):
237
234
  #
238
235
  # f = File.new('t.txt')
236
+ # # Method gets with no sep argument returns the next line, according to $/.
239
237
  # f.gets # => "First line\n"
240
238
  # f.gets # => "Second line\n"
241
239
  # f.gets # => "\n"
@@ -243,7 +241,7 @@
243
241
  # f.gets # => "Fifth line\n"
244
242
  # f.close
245
243
  #
246
- # You can specify a different line separator:
244
+ # You can use a different line separator by passing argument `sep`:
247
245
  #
248
246
  # f = File.new('t.txt')
249
247
  # f.gets('l') # => "First l"
@@ -252,40 +250,45 @@
252
250
  # f.gets # => "e\n"
253
251
  # f.close
254
252
  #
255
- # There are two special line separators:
253
+ # Or by setting global variable `$/`:
254
+ #
255
+ # f = File.new('t.txt')
256
+ # $/ = 'l'
257
+ # f.gets # => "First l"
258
+ # f.gets # => "ine\nSecond l"
259
+ # f.gets # => "ine\n\nFourth l"
260
+ # f.close
261
+ #
262
+ # ##### Special Line Separator Values
263
+ #
264
+ # Each of the [line input methods](rdoc-ref:IO@Line+Input) accepts two special
265
+ # values for parameter `sep`:
256
266
  #
257
- # * `nil`: The entire stream is read into a single string:
267
+ # * `nil`: The entire stream is to be read ("slurped") into a single string:
258
268
  #
259
269
  # f = File.new('t.txt')
260
270
  # f.gets(nil) # => "First line\nSecond line\n\nFourth line\nFifth line\n"
261
271
  # f.close
262
272
  #
263
- # * `''` (the empty string): The next "paragraph" is read (paragraphs being
264
- # separated by two consecutive line separators):
273
+ # * `''` (the empty string): The next "paragraph" is to be read (paragraphs
274
+ # being separated by two consecutive line separators):
265
275
  #
266
276
  # f = File.new('t.txt')
267
277
  # f.gets('') # => "First line\nSecond line\n\n"
268
278
  # f.gets('') # => "Fourth line\nFifth line\n"
269
279
  # f.close
270
280
  #
281
+ # ##### Line Limit
271
282
  #
272
- # ### Line Limit
273
- #
274
- # Each of these methods uses a *line limit*, which specifies that the number of
275
- # bytes returned may not be (much) longer than the given `limit`;
283
+ # Each of the [line input methods](rdoc-ref:IO@Line+Input) uses an integer *line
284
+ # limit*, which restricts the number of bytes that may be returned. (A
285
+ # multi-byte character will not be split, and so a returned line may be slightly
286
+ # longer than the limit).
276
287
  #
277
- # * IO.foreach.
278
- # * IO.readlines.
279
- # * IO#each_line.
280
- # * IO#gets.
281
- # * IO#readline.
282
- # * IO#readlines.
288
+ # The default limit value is `-1`; any negative limit value means that there is
289
+ # no limit.
283
290
  #
284
- #
285
- # A multi-byte character will not be split, and so a line may be slightly longer
286
- # than the given limit.
287
- #
288
- # If `limit` is not given, the line is determined only by `sep`.
291
+ # If there is no limit, the line is determined only by `sep`.
289
292
  #
290
293
  # # Text with 1-byte characters.
291
294
  # File.open('t.txt') {|f| f.gets(1) } # => "F"
@@ -303,32 +306,28 @@
303
306
  # File.open('t.rus') {|f| f.gets(3).size } # => 2
304
307
  # File.open('t.rus') {|f| f.gets(4).size } # => 2
305
308
  #
306
- # ### Line Separator and Line Limit
309
+ # ##### Line Separator and Line Limit
307
310
  #
308
311
  # With arguments `sep` and `limit` given, combines the two behaviors:
309
312
  #
310
313
  # * Returns the next line as determined by line separator `sep`.
311
- # * But returns no more bytes than are allowed by the limit.
312
- #
314
+ # * But returns no more bytes than are allowed by the limit `limit`.
313
315
  #
314
316
  # Example:
315
317
  #
316
318
  # File.open('t.txt') {|f| f.gets('li', 20) } # => "First li"
317
319
  # File.open('t.txt') {|f| f.gets('li', 2) } # => "Fi"
318
320
  #
319
- # ### Line Number
321
+ # ##### Line Number
320
322
  #
321
- # A readable IO stream has a non-negative integer *line number*.
322
- #
323
- # The relevant methods:
323
+ # A readable IO stream has a non-negative integer *line number*:
324
324
  #
325
325
  # * IO#lineno: Returns the line number.
326
326
  # * IO#lineno=: Resets and returns the line number.
327
327
  #
328
- #
329
328
  # Unless modified by a call to method IO#lineno=, the line number is the number
330
- # of lines read by certain line-oriented methods, according to the given line
331
- # separator `sep`:
329
+ # of lines read by certain line-oriented methods, according to the effective
330
+ # [line separator](rdoc-ref:IO@Line+Separator):
332
331
  #
333
332
  # * IO.foreach: Increments the line number on each call to the block.
334
333
  # * IO#each_line: Increments the line number on each call to the block.
@@ -336,7 +335,6 @@
336
335
  # * IO#readline: Increments the line number.
337
336
  # * IO#readlines: Increments the line number for each line read.
338
337
  #
339
- #
340
338
  # A new stream is initially has line number zero (and position zero); method
341
339
  # `rewind` resets the line number (and position) to zero:
342
340
  #
@@ -419,6 +417,11 @@
419
417
  # $. # => 5
420
418
  # f.close
421
419
  #
420
+ # ### Line Output
421
+ #
422
+ # You can write to an IO stream line-by-line using this method:
423
+ #
424
+ # * IO#puts: Writes objects to the stream.
422
425
  #
423
426
  # ## Character IO
424
427
  #
@@ -442,7 +445,6 @@
442
445
  # * IO#each_byte: Reads each remaining byte in the stream, passing the byte to
443
446
  # the given block.
444
447
  #
445
- #
446
448
  # ## Codepoint IO
447
449
  #
448
450
  # You can process an IO stream codepoint-by-codepoint:
@@ -450,7 +452,6 @@
450
452
  # * IO#each_codepoint: Reads each remaining codepoint, passing it to the given
451
453
  # block.
452
454
  #
453
- #
454
455
  # ## What's Here
455
456
  #
456
457
  # First, what's elsewhere. Class IO:
@@ -459,7 +460,6 @@
459
460
  # * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
460
461
  # provides dozens of additional methods.
461
462
  #
462
- #
463
463
  # Here, class IO provides methods that are useful for:
464
464
  #
465
465
  # * [Creating](rdoc-ref:IO@Creating)
@@ -473,7 +473,6 @@
473
473
  # * [Low-Level Access](rdoc-ref:IO@Low-Level+Access)
474
474
  # * [Other](rdoc-ref:IO@Other)
475
475
  #
476
- #
477
476
  # ### Creating
478
477
  #
479
478
  # * ::new (aliased as ::for_fd): Creates and returns a new IO object for the
@@ -484,7 +483,6 @@
484
483
  # * ::select: Selects which given IO instances are ready for reading, writing,
485
484
  # or have pending exceptions.
486
485
  #
487
- #
488
486
  # ### Reading
489
487
  #
490
488
  # * ::binread: Returns a binary string with all or a subset of bytes from the
@@ -511,7 +509,6 @@
511
509
  # * #readlines: Returns an array of all lines read read from `self`.
512
510
  # * #readpartial: Returns up to the given number of bytes from `self`.
513
511
  #
514
- #
515
512
  # ### Writing
516
513
  #
517
514
  # * ::binwrite: Writes the given string to the file at the given filepath, in
@@ -528,7 +525,6 @@
528
525
  # * #write_nonblock: Writes one or more given strings to `self` in
529
526
  # non-blocking mode.
530
527
  #
531
- #
532
528
  # ### Positioning
533
529
  #
534
530
  # * #lineno: Returns the current line number in `self`.
@@ -539,7 +535,6 @@
539
535
  # * #rewind: Positions `self` to the beginning of input.
540
536
  # * #seek: Sets the offset for `self` relative to given position.
541
537
  #
542
- #
543
538
  # ### Iterating
544
539
  #
545
540
  # * ::foreach: Yields each line of given file to the block.
@@ -552,7 +547,6 @@
552
547
  # * #each_codepoint: Calls the given block with each successive codepoint in
553
548
  # `self` as an integer.
554
549
  #
555
- #
556
550
  # ### Settings
557
551
  #
558
552
  # * #autoclose=: Sets whether `self` auto-closes.
@@ -566,7 +560,6 @@
566
560
  # byte-order-mark.
567
561
  # * #sync=: Sets the sync-mode to the given value.
568
562
  #
569
- #
570
563
  # ### Querying
571
564
  #
572
565
  # * #autoclose?: Returns whether `self` auto-closes.
@@ -584,7 +577,6 @@
584
577
  # * #sync: Returns whether `self` is in sync-mode.
585
578
  # * #tty? (aliased as #isatty): Returns whether `self` is a terminal.
586
579
  #
587
- #
588
580
  # ### Buffering
589
581
  #
590
582
  # * #fdatasync: Immediately writes all buffered data in `self` to disk.
@@ -595,7 +587,6 @@
595
587
  # * #ungetbyte: Prepends buffer for `self` with given integer byte or string.
596
588
  # * #ungetc: Prepends buffer for `self` with given string.
597
589
  #
598
- #
599
590
  # ### Low-Level Access
600
591
  #
601
592
  # * ::sysopen: Opens the file given by its path, returning the integer file
@@ -611,7 +602,6 @@
611
602
  # * #sysseek: Sets the offset for `self`.
612
603
  # * #syswrite: Writes the given string to `self` using a low-level write.
613
604
  #
614
- #
615
605
  # ### Other
616
606
  #
617
607
  # * ::copy_stream: Copies data from a source to a destination, each of which
@@ -660,7 +650,6 @@ class IO < Object
660
650
  # * `len`: The number of bytes to be accessed; if `len` is zero, or is larger
661
651
  # than the number of bytes remaining, all remaining bytes will be accessed.
662
652
  #
663
- #
664
653
  # Argument `advice` is one of the following symbols:
665
654
  #
666
655
  # * `:normal`: The application has no advice to give about its access pattern
@@ -673,7 +662,6 @@ class IO < Object
673
662
  # * `:willneed`: The specified data will be accessed in the near future.
674
663
  # * `:dontneed`: The specified data will not be accessed in the near future.
675
664
  #
676
- #
677
665
  # Not implemented on all platforms.
678
666
  #
679
667
  def advise: (:normal | :sequential | :random | :willneed | :dontneed | :noreuse advise, ?Integer offset, ?Integer len) -> nil
@@ -739,6 +727,9 @@ class IO < Object
739
727
  # If the stream was opened by IO.popen, sets global variable `$?` (child exit
740
728
  # status).
741
729
  #
730
+ # It is not an error to close an IO object that has already been closed. It just
731
+ # returns nil.
732
+ #
742
733
  # Example:
743
734
  #
744
735
  # IO.popen('ruby', 'r+') do |pipe|
@@ -1045,7 +1036,6 @@ class IO < Object
1045
1036
  # * IO#fsync: Ensures both that data is flushed from internal buffers, and
1046
1037
  # that data is written to disk.
1047
1038
  #
1048
- #
1049
1039
  # Raises an exception if the operating system does not support `fsync(2)`.
1050
1040
  #
1051
1041
  def fsync: () -> Integer?
@@ -1136,12 +1126,8 @@ class IO < Object
1136
1126
  # File.open('t.txt') {|f| f.gets(11) } # => "First line\n"
1137
1127
  # File.open('t.txt') {|f| f.gets(12) } # => "First line\n"
1138
1128
  #
1139
- # With arguments `sep` and `limit` given, combines the two behaviors:
1140
- #
1141
- # * Returns the next line as determined by line separator `sep`, or `nil` if
1142
- # none.
1143
- # * But returns no more bytes than are allowed by the limit.
1144
- #
1129
+ # With arguments `sep` and `limit` given, combines the two behaviors (see [Line
1130
+ # Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)).
1145
1131
  #
1146
1132
  # Optional keyword argument `chomp` specifies whether line separators are to be
1147
1133
  # omitted:
@@ -1193,7 +1179,6 @@ class IO < Object
1193
1179
  # * [Open Options](rdoc-ref:IO@Open+Options).
1194
1180
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
1195
1181
  #
1196
- #
1197
1182
  # Examples:
1198
1183
  #
1199
1184
  # IO.new(fd, internal_encoding: nil) # => #<IO:fd 3>
@@ -1341,7 +1326,6 @@ class IO < Object
1341
1326
  # * If not the last object, writes the output field separator
1342
1327
  # `$OUTPUT_FIELD_SEPARATOR` (`$,`) if it is not `nil`.
1343
1328
  #
1344
- #
1345
1329
  # With default separators:
1346
1330
  #
1347
1331
  # f = File.open('t.tmp', 'w+')
@@ -1431,7 +1415,6 @@ class IO < Object
1431
1415
  # * Neither string nor array: writes `object.to_s`.
1432
1416
  # * Array: writes each element of the array; arrays may be nested.
1433
1417
  #
1434
- #
1435
1418
  # To keep these examples brief, we define this helper method:
1436
1419
  #
1437
1420
  # def show(*objects)
@@ -1470,7 +1453,6 @@ class IO < Object
1470
1453
  # * If `maxlen` is `nil`, reads all bytes using the stream's data mode.
1471
1454
  # * Otherwise reads up to `maxlen` bytes in binary mode.
1472
1455
  #
1473
- #
1474
1456
  # Returns a string (either a new string or the given `out_string`) containing
1475
1457
  # the bytes read. The encoding of the string depends on both `maxLen` and
1476
1458
  # `out_string`:
@@ -1482,8 +1464,6 @@ class IO < Object
1482
1464
  # * `out_string` given: encoding of `out_string` not modified.
1483
1465
  # * `out_string` not given: ASCII-8BIT is used.
1484
1466
  #
1485
- #
1486
- #
1487
1467
  # **Without Argument `out_string`**
1488
1468
  #
1489
1469
  # When argument `out_string` is omitted, the returned value is a new string:
@@ -1638,7 +1618,7 @@ class IO < Object
1638
1618
  # Optional keyword argument `chomp` specifies whether line separators are to be
1639
1619
  # omitted.
1640
1620
  #
1641
- def readline: (?String sep, ?Integer limit) -> String
1621
+ def readline: (?String sep, ?Integer limit, ?chomp: boolish) -> String
1642
1622
 
1643
1623
  # <!--
1644
1624
  # rdoc-file=io.c
@@ -1687,11 +1667,8 @@ class IO < Object
1687
1667
  # # => ["First li", "ne\n", "Second l", "ine\n", "\n", "Fourth l", "ine\n", "Fifth li", "ne\n"]
1688
1668
  # f.close
1689
1669
  #
1690
- # With arguments `sep` and `limit` given, combines the two behaviors:
1691
- #
1692
- # * Returns lines as determined by line separator `sep`.
1693
- # * But returns no more bytes in a line than are allowed by the limit.
1694
- #
1670
+ # With arguments `sep` and `limit` given, combines the two behaviors (see [Line
1671
+ # Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)).
1695
1672
  #
1696
1673
  # Optional keyword argument `chomp` specifies whether line separators are to be
1697
1674
  # omitted:
@@ -1701,7 +1678,7 @@ class IO < Object
1701
1678
  # # => ["First line", "Second line", "", "Fourth line", "Fifth line"]
1702
1679
  # f.close
1703
1680
  #
1704
- def readlines: (?String sep, ?Integer limit) -> ::Array[String]
1681
+ def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String]
1705
1682
 
1706
1683
  # <!--
1707
1684
  # rdoc-file=io.c
@@ -1718,7 +1695,6 @@ class IO < Object
1718
1695
  # * Otherwise contains all available bytes, if any available.
1719
1696
  # * Otherwise is an empty string.
1720
1697
  #
1721
- #
1722
1698
  # With the single non-negative integer argument `maxlen` given, returns a new
1723
1699
  # string:
1724
1700
  #
@@ -1747,20 +1723,17 @@ class IO < Object
1747
1723
  # * The content of the stream is empty.
1748
1724
  # * The stream is not at EOF.
1749
1725
  #
1750
- #
1751
1726
  # When blocked, the method waits for either more data or EOF on the stream:
1752
1727
  #
1753
1728
  # * If more data is read, the method returns the data.
1754
1729
  # * If EOF is reached, the method raises EOFError.
1755
1730
  #
1756
- #
1757
1731
  # When not blocked, the method responds immediately:
1758
1732
  #
1759
1733
  # * Returns data from the buffer if there is any.
1760
1734
  # * Otherwise returns data from the stream if there is any.
1761
1735
  # * Otherwise raises EOFError if the stream has reached EOF.
1762
1736
  #
1763
- #
1764
1737
  # Note that this method is similar to sysread. The differences are:
1765
1738
  #
1766
1739
  # * If the byte buffer is not empty, read from the byte buffer instead of
@@ -1769,7 +1742,6 @@ class IO < Object
1769
1742
  # meets EWOULDBLOCK and EINTR by read system call, readpartial retries the
1770
1743
  # system call.
1771
1744
  #
1772
- #
1773
1745
  # The latter means that readpartial is non-blocking-flag insensitive. It blocks
1774
1746
  # on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking
1775
1747
  # mode.
@@ -1898,7 +1870,6 @@ class IO < Object
1898
1870
  # f.tell # => 40
1899
1871
  # f.close
1900
1872
  #
1901
- #
1902
1873
  # Related: IO#pos=, IO#tell.
1903
1874
  #
1904
1875
  def seek: (Integer amount, ?Integer whence) -> Integer
@@ -1997,7 +1968,6 @@ class IO < Object
1997
1968
  # system and is not buffered internally.
1998
1969
  # * `false`: Output may be buffered internally.
1999
1970
  #
2000
- #
2001
1971
  # Example;
2002
1972
  #
2003
1973
  # f = File.open('t.tmp', 'w')
@@ -2153,7 +2123,6 @@ class IO < Object
2153
2123
  # IO#sysread).
2154
2124
  # * Calling #rewind on the stream discards the pushed-back data.
2155
2125
  #
2156
- #
2157
2126
  # When argument `integer` is given, uses only its low-order byte:
2158
2127
  #
2159
2128
  # File.write('t.tmp', '012')
@@ -2193,7 +2162,6 @@ class IO < Object
2193
2162
  # IO#sysread).
2194
2163
  # * Calling #rewind on the stream discards the pushed-back data.
2195
2164
  #
2196
- #
2197
2165
  # When argument `integer` is given, interprets the integer as a character:
2198
2166
  #
2199
2167
  # File.write('t.tmp', '012')
@@ -2310,7 +2278,7 @@ class IO < Object
2310
2278
  # potential security vulnerabilities if called with untrusted input; see
2311
2279
  # [Command Injection](rdoc-ref:command_injection.rdoc).
2312
2280
  #
2313
- def self.binread: (String name, ?Integer length, ?Integer offset) -> String
2281
+ def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
2314
2282
 
2315
2283
  # <!--
2316
2284
  # rdoc-file=io.c
@@ -2338,15 +2306,12 @@ class IO < Object
2338
2306
  # * An IO-like object, opened for reading and capable of responding to
2339
2307
  # method `:readpartial` or method `:read`.
2340
2308
  #
2341
- #
2342
2309
  # * The given `dst` must be one of the following:
2343
2310
  #
2344
2311
  # * The path to a writable file, to which data is to be written.
2345
2312
  # * An IO-like object, opened for writing and capable of responding to
2346
2313
  # method `:write`.
2347
2314
  #
2348
- #
2349
- #
2350
2315
  # The examples here use file `t.txt` as source:
2351
2316
  #
2352
2317
  # File.read('t.txt')
@@ -2378,7 +2343,7 @@ class IO < Object
2378
2343
  # IO.copy_stream('t.txt', 't.tmp', 11, 11) # => 11
2379
2344
  # IO.read('t.tmp') # => "Second line"
2380
2345
  #
2381
- def self.copy_stream: (String | _Reader | _ReaderPartial src, String | _Writer dst, ?Integer copy_length, ?Integer src_offset) -> Integer
2346
+ def self.copy_stream: (String | _Reader | _ReaderPartial src, String | _Writer dst, ?Integer? copy_length, ?Integer src_offset) -> Integer
2382
2347
 
2383
2348
  # <!--
2384
2349
  # rdoc-file=io.c
@@ -2409,7 +2374,6 @@ class IO < Object
2409
2374
  # * A specified program runs with specified arguments.
2410
2375
  # * A specified program runs with specified arguments and a specified `argv0`.
2411
2376
  #
2412
- #
2413
2377
  # Each of these is detailed below.
2414
2378
  #
2415
2379
  # The optional hash argument `env` specifies name/value pairs that are to be
@@ -2427,7 +2391,6 @@ class IO < Object
2427
2391
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2428
2392
  # * Options for Kernel#spawn.
2429
2393
  #
2430
- #
2431
2394
  # **Forked \Process**
2432
2395
  #
2433
2396
  # When argument `cmd` is the 1-character string `'-'`, causes the process to
@@ -2496,7 +2459,6 @@ class IO < Object
2496
2459
  # program's `argv[0]`.
2497
2460
  # * `cmd[1..-1]` (the strings in the outer array) are the program's arguments.
2498
2461
  #
2499
- #
2500
2462
  # Example (sets `$0` to 'foo'):
2501
2463
  #
2502
2464
  # IO.popen([['/bin/sh', 'foo'], '-c', 'echo $0']).read # => "foo\n"
@@ -2604,6 +2566,7 @@ class IO < Object
2604
2566
  #
2605
2567
  # With argument `limit` given, parses lines as determined by the default line
2606
2568
  # separator and the given line-length limit (see [Line
2569
+ # Separator](rdoc-ref:IO@Line+Separator) and [Line
2607
2570
  # Limit](rdoc-ref:IO@Line+Limit)):
2608
2571
  #
2609
2572
  # File.foreach('t.txt', 7) {|line| p line }
@@ -2620,9 +2583,8 @@ class IO < Object
2620
2583
  # "Fourth l"
2621
2584
  # "line\n"
2622
2585
  #
2623
- # With arguments `sep` and `limit` given, parses lines as determined by the
2624
- # given line separator and the given line-length limit (see [Line Separator and
2625
- # Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)):
2586
+ # With arguments `sep` and `limit` given, combines the two behaviors (see [Line
2587
+ # Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)).
2626
2588
  #
2627
2589
  # Optional keyword arguments `opts` specify:
2628
2590
  #
@@ -2630,7 +2592,6 @@ class IO < Object
2630
2592
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2631
2593
  # * [Line Options](rdoc-ref:IO@Line+IO).
2632
2594
  #
2633
- #
2634
2595
  # Returns an Enumerator if no block is given.
2635
2596
  #
2636
2597
  def self.foreach: (string | _ToPath path, ?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) { (String line) -> void } -> nil
@@ -2654,7 +2615,6 @@ class IO < Object
2654
2615
  # * The colon-separated names of two encodings to be used as the external and
2655
2616
  # internal encodings.
2656
2617
  #
2657
- #
2658
2618
  # If argument `int_enc` is given, it must be an Encoding object or encoding name
2659
2619
  # string that specifies the internal encoding to be used; if argument `ext_enc`
2660
2620
  # is also given, it must be an Encoding object or encoding name string that
@@ -2672,7 +2632,6 @@ class IO < Object
2672
2632
  # * [Open Options](rdoc-ref:IO@Open+Options).
2673
2633
  # * [Encoding Options](rdoc-ref:encodings.rdoc@Encoding+Options).
2674
2634
  #
2675
- #
2676
2635
  # With no block given, returns the two endpoints in an array:
2677
2636
  #
2678
2637
  # IO.pipe # => [#<IO:fd 4>, #<IO:fd 5>]
@@ -2757,7 +2716,7 @@ class IO < Object
2757
2716
  # * [Open Options](rdoc-ref:IO@Open+Options).
2758
2717
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2759
2718
  #
2760
- def self.read: (String name, ?Integer length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String
2719
+ def self.read: (String name, ?Integer? length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String
2761
2720
 
2762
2721
  # <!--
2763
2722
  # rdoc-file=io.c
@@ -2795,14 +2754,14 @@ class IO < Object
2795
2754
  #
2796
2755
  # With argument `limit` given, parses lines as determined by the default line
2797
2756
  # separator and the given line-length limit (see [Line
2798
- # Limit](rdoc-ref:IO@Line+Limit)):
2757
+ # Separator](rdoc-ref:IO@Line+Separator) and [Line
2758
+ # Limit](rdoc-ref:IO@Line+Limit):
2799
2759
  #
2800
2760
  # IO.readlines('t.txt', 7)
2801
2761
  # # => ["First l", "ine\n", "Second ", "line\n", "\n", "Third l", "ine\n", "Fourth ", "line\n"]
2802
2762
  #
2803
- # With arguments `sep` and `limit` given, parses lines as determined by the
2804
- # given line separator and the given line-length limit (see [Line Separator and
2805
- # Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)):
2763
+ # With arguments `sep` and `limit` given, combines the two behaviors (see [Line
2764
+ # Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)).
2806
2765
  #
2807
2766
  # Optional keyword arguments `opts` specify:
2808
2767
  #
@@ -2825,7 +2784,8 @@ class IO < Object
2825
2784
  # Each of the arguments `read_ios`, `write_ios`, and `error_ios` is an array of
2826
2785
  # IO objects.
2827
2786
  #
2828
- # Argument `timeout` is an integer timeout interval in seconds.
2787
+ # Argument `timeout` is a numeric value (such as integer or float) timeout
2788
+ # interval in seconds.
2829
2789
  #
2830
2790
  # The method monitors the IO objects given in all three arrays, waiting for some
2831
2791
  # to be ready; returns a 3-element array whose elements are:
@@ -2834,7 +2794,6 @@ class IO < Object
2834
2794
  # * An array of the objects in `write_ios` that are ready for writing.
2835
2795
  # * An array of the objects in `error_ios` have pending exceptions.
2836
2796
  #
2837
- #
2838
2797
  # If no object becomes ready within the given `timeout`, `nil` is returned.
2839
2798
  #
2840
2799
  # IO.select peeks the buffer of IO objects for testing readability. If the IO
@@ -3125,11 +3084,8 @@ class IO < Object
3125
3084
  # "Fifth li"
3126
3085
  # "ne\n"
3127
3086
  #
3128
- # With arguments `sep` and `limit` given, combines the two behaviors:
3129
- #
3130
- # * Calls with the next line as determined by line separator `sep`.
3131
- # * But returns no more bytes than are allowed by the limit.
3132
- #
3087
+ # With arguments `sep` and `limit` given, combines the two behaviors (see [Line
3088
+ # Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)).
3133
3089
  #
3134
3090
  # Optional keyword argument `chomp` specifies whether line separators are to be
3135
3091
  # omitted:
@@ -3148,8 +3104,8 @@ class IO < Object
3148
3104
  #
3149
3105
  # Returns an Enumerator if no block is given.
3150
3106
  #
3151
- def each_line: (?String sep, ?Integer limit) { (String line) -> void } -> self
3152
- | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
3107
+ def each_line: (?string sep, ?int limit, ?chomp: boolish) { (String line) -> void } -> self
3108
+ | (?string sep, ?int limit, ?chomp: boolish) -> ::Enumerator[String, self]
3153
3109
 
3154
3110
  # <!--
3155
3111
  # rdoc-file=io.c
@@ -3230,11 +3186,8 @@ class IO < Object
3230
3186
  # "Fifth li"
3231
3187
  # "ne\n"
3232
3188
  #
3233
- # With arguments `sep` and `limit` given, combines the two behaviors:
3234
- #
3235
- # * Calls with the next line as determined by line separator `sep`.
3236
- # * But returns no more bytes than are allowed by the limit.
3237
- #
3189
+ # With arguments `sep` and `limit` given, combines the two behaviors (see [Line
3190
+ # Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)).
3238
3191
  #
3239
3192
  # Optional keyword argument `chomp` specifies whether line separators are to be
3240
3193
  # omitted:
@@ -3298,6 +3251,10 @@ class IO < Object
3298
3251
  # f.close
3299
3252
  #
3300
3253
  alias to_i fileno
3254
+
3255
+ interface _ForFd[RET]
3256
+ def for_fd: (?) -> RET
3257
+ end
3301
3258
  end
3302
3259
 
3303
3260
  IO::APPEND: Integer