rbs 4.0.0.dev.4 → 4.0.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 (281) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +18 -11
  5. data/.github/workflows/comments.yml +5 -3
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/ruby.yml +27 -34
  8. data/.github/workflows/rust.yml +95 -0
  9. data/.github/workflows/typecheck.yml +2 -2
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/CHANGELOG.md +323 -0
  13. data/README.md +1 -1
  14. data/Rakefile +43 -33
  15. data/Steepfile +1 -0
  16. data/config.yml +426 -24
  17. data/core/array.rbs +307 -227
  18. data/core/basic_object.rbs +9 -8
  19. data/core/binding.rbs +0 -2
  20. data/core/builtin.rbs +2 -2
  21. data/core/class.rbs +6 -5
  22. data/core/comparable.rbs +55 -34
  23. data/core/complex.rbs +104 -78
  24. data/core/dir.rbs +61 -49
  25. data/core/encoding.rbs +12 -15
  26. data/core/enumerable.rbs +179 -87
  27. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  28. data/core/enumerator.rbs +65 -2
  29. data/core/errno.rbs +11 -2
  30. data/core/errors.rbs +58 -29
  31. data/core/exception.rbs +13 -13
  32. data/core/fiber.rbs +74 -54
  33. data/core/file.rbs +280 -177
  34. data/core/file_test.rbs +3 -3
  35. data/core/float.rbs +257 -92
  36. data/core/gc.rbs +425 -281
  37. data/core/hash.rbs +1045 -739
  38. data/core/integer.rbs +135 -137
  39. data/core/io/buffer.rbs +53 -42
  40. data/core/io/wait.rbs +13 -35
  41. data/core/io.rbs +192 -144
  42. data/core/kernel.rbs +216 -155
  43. data/core/marshal.rbs +4 -4
  44. data/core/match_data.rbs +15 -13
  45. data/core/math.rbs +107 -66
  46. data/core/method.rbs +69 -33
  47. data/core/module.rbs +244 -106
  48. data/core/nil_class.rbs +7 -6
  49. data/core/numeric.rbs +74 -63
  50. data/core/object.rbs +9 -11
  51. data/core/object_space.rbs +30 -23
  52. data/core/pathname.rbs +1322 -0
  53. data/core/proc.rbs +95 -58
  54. data/core/process.rbs +222 -202
  55. data/core/ractor.rbs +371 -515
  56. data/core/random.rbs +21 -3
  57. data/core/range.rbs +159 -57
  58. data/core/rational.rbs +60 -89
  59. data/core/rbs/unnamed/argf.rbs +60 -53
  60. data/core/rbs/unnamed/env_class.rbs +19 -14
  61. data/core/rbs/unnamed/main_class.rbs +123 -0
  62. data/core/rbs/unnamed/random.rbs +11 -118
  63. data/core/regexp.rbs +258 -214
  64. data/core/ruby.rbs +53 -0
  65. data/core/ruby_vm.rbs +38 -34
  66. data/core/rubygems/config_file.rbs +5 -5
  67. data/core/rubygems/errors.rbs +4 -71
  68. data/core/rubygems/requirement.rbs +5 -5
  69. data/core/rubygems/rubygems.rbs +16 -82
  70. data/core/rubygems/version.rbs +2 -3
  71. data/core/set.rbs +490 -360
  72. data/core/signal.rbs +26 -16
  73. data/core/string.rbs +3234 -1285
  74. data/core/struct.rbs +27 -26
  75. data/core/symbol.rbs +41 -34
  76. data/core/thread.rbs +135 -67
  77. data/core/time.rbs +81 -50
  78. data/core/trace_point.rbs +41 -35
  79. data/core/true_class.rbs +2 -2
  80. data/core/unbound_method.rbs +24 -16
  81. data/core/warning.rbs +7 -7
  82. data/docs/aliases.md +79 -0
  83. data/docs/collection.md +3 -3
  84. data/docs/config.md +171 -0
  85. data/docs/encoding.md +56 -0
  86. data/docs/gem.md +0 -1
  87. data/docs/inline.md +576 -0
  88. data/docs/sigs.md +3 -3
  89. data/docs/syntax.md +46 -16
  90. data/docs/type_fingerprint.md +21 -0
  91. data/exe/rbs +1 -1
  92. data/ext/rbs_extension/ast_translation.c +544 -116
  93. data/ext/rbs_extension/ast_translation.h +3 -0
  94. data/ext/rbs_extension/class_constants.c +16 -2
  95. data/ext/rbs_extension/class_constants.h +8 -0
  96. data/ext/rbs_extension/extconf.rb +5 -1
  97. data/ext/rbs_extension/legacy_location.c +33 -56
  98. data/ext/rbs_extension/legacy_location.h +37 -0
  99. data/ext/rbs_extension/main.c +44 -35
  100. data/include/rbs/ast.h +448 -173
  101. data/include/rbs/defines.h +27 -0
  102. data/include/rbs/lexer.h +30 -11
  103. data/include/rbs/location.h +25 -44
  104. data/include/rbs/parser.h +6 -6
  105. data/include/rbs/string.h +0 -2
  106. data/include/rbs/util/rbs_allocator.h +34 -13
  107. data/include/rbs/util/rbs_assert.h +12 -1
  108. data/include/rbs/util/rbs_constant_pool.h +0 -3
  109. data/include/rbs/util/rbs_encoding.h +2 -0
  110. data/include/rbs/util/rbs_unescape.h +2 -1
  111. data/include/rbs.h +8 -0
  112. data/lib/rbs/ast/annotation.rb +1 -1
  113. data/lib/rbs/ast/comment.rb +1 -1
  114. data/lib/rbs/ast/declarations.rb +10 -10
  115. data/lib/rbs/ast/members.rb +14 -14
  116. data/lib/rbs/ast/ruby/annotations.rb +293 -3
  117. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  118. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  119. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  120. data/lib/rbs/ast/ruby/members.rb +532 -22
  121. data/lib/rbs/ast/type_param.rb +24 -4
  122. data/lib/rbs/buffer.rb +20 -15
  123. data/lib/rbs/cli/diff.rb +16 -15
  124. data/lib/rbs/cli/validate.rb +38 -106
  125. data/lib/rbs/cli.rb +52 -19
  126. data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
  127. data/lib/rbs/collection/sources/git.rb +1 -0
  128. data/lib/rbs/definition.rb +1 -1
  129. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  130. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  131. data/lib/rbs/definition_builder.rb +147 -25
  132. data/lib/rbs/diff.rb +7 -1
  133. data/lib/rbs/environment.rb +227 -74
  134. data/lib/rbs/environment_loader.rb +0 -6
  135. data/lib/rbs/errors.rb +27 -18
  136. data/lib/rbs/inline_parser.rb +342 -6
  137. data/lib/rbs/location_aux.rb +1 -1
  138. data/lib/rbs/locator.rb +5 -1
  139. data/lib/rbs/method_type.rb +5 -3
  140. data/lib/rbs/parser_aux.rb +20 -7
  141. data/lib/rbs/prototype/helpers.rb +57 -0
  142. data/lib/rbs/prototype/rb.rb +3 -28
  143. data/lib/rbs/prototype/rbi.rb +3 -20
  144. data/lib/rbs/prototype/runtime.rb +8 -0
  145. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  146. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  147. data/lib/rbs/subtractor.rb +3 -1
  148. data/lib/rbs/test/type_check.rb +19 -2
  149. data/lib/rbs/type_name.rb +1 -1
  150. data/lib/rbs/types.rb +88 -78
  151. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  152. data/lib/rbs/validator.rb +2 -2
  153. data/lib/rbs/version.rb +1 -1
  154. data/lib/rbs.rb +1 -2
  155. data/lib/rdoc/discover.rb +1 -1
  156. data/lib/rdoc_plugin/parser.rb +1 -1
  157. data/rbs.gemspec +4 -3
  158. data/rust/.gitignore +1 -0
  159. data/rust/Cargo.lock +378 -0
  160. data/rust/Cargo.toml +7 -0
  161. data/rust/ruby-rbs/Cargo.toml +22 -0
  162. data/rust/ruby-rbs/build.rs +764 -0
  163. data/rust/ruby-rbs/examples/locations.rs +60 -0
  164. data/rust/ruby-rbs/src/lib.rs +1 -0
  165. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  166. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  167. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  168. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  169. data/rust/ruby-rbs-sys/build.rs +204 -0
  170. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  171. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  172. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  173. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  174. data/schema/typeParam.json +17 -1
  175. data/sig/ast/ruby/annotations.rbs +315 -4
  176. data/sig/ast/ruby/comment_block.rbs +8 -0
  177. data/sig/ast/ruby/declarations.rbs +102 -4
  178. data/sig/ast/ruby/members.rbs +108 -2
  179. data/sig/cli/diff.rbs +5 -11
  180. data/sig/cli/validate.rbs +12 -8
  181. data/sig/cli.rbs +18 -18
  182. data/sig/definition.rbs +6 -1
  183. data/sig/definition_builder.rbs +2 -0
  184. data/sig/environment.rbs +70 -12
  185. data/sig/errors.rbs +13 -14
  186. data/sig/inline_parser.rbs +39 -2
  187. data/sig/locator.rbs +0 -2
  188. data/sig/manifest.yaml +0 -1
  189. data/sig/method_builder.rbs +3 -1
  190. data/sig/parser.rbs +31 -13
  191. data/sig/prototype/helpers.rbs +2 -0
  192. data/sig/resolver/type_name_resolver.rbs +35 -7
  193. data/sig/source.rbs +3 -3
  194. data/sig/type_param.rbs +13 -8
  195. data/sig/types.rbs +6 -7
  196. data/sig/unit_test/spy.rbs +0 -8
  197. data/sig/unit_test/type_assertions.rbs +11 -0
  198. data/src/ast.c +410 -153
  199. data/src/lexer.c +1392 -1313
  200. data/src/lexer.re +3 -0
  201. data/src/lexstate.c +58 -37
  202. data/src/location.c +8 -48
  203. data/src/parser.c +977 -516
  204. data/src/string.c +0 -48
  205. data/src/util/rbs_allocator.c +89 -71
  206. data/src/util/rbs_assert.c +1 -1
  207. data/src/util/rbs_buffer.c +2 -2
  208. data/src/util/rbs_constant_pool.c +10 -14
  209. data/src/util/rbs_encoding.c +4 -8
  210. data/src/util/rbs_unescape.c +56 -20
  211. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  212. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  213. data/stdlib/cgi/0/core.rbs +9 -393
  214. data/stdlib/cgi/0/manifest.yaml +1 -0
  215. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  216. data/stdlib/coverage/0/coverage.rbs +7 -4
  217. data/stdlib/date/0/date.rbs +92 -79
  218. data/stdlib/date/0/date_time.rbs +25 -24
  219. data/stdlib/delegate/0/delegator.rbs +10 -7
  220. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  221. data/stdlib/digest/0/digest.rbs +110 -0
  222. data/stdlib/erb/0/erb.rbs +748 -347
  223. data/stdlib/etc/0/etc.rbs +55 -50
  224. data/stdlib/fileutils/0/fileutils.rbs +158 -139
  225. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  226. data/stdlib/io-console/0/io-console.rbs +2 -2
  227. data/stdlib/json/0/json.rbs +217 -136
  228. data/stdlib/monitor/0/monitor.rbs +3 -3
  229. data/stdlib/net-http/0/net-http.rbs +162 -134
  230. data/stdlib/objspace/0/objspace.rbs +17 -34
  231. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  232. data/stdlib/open3/0/open3.rbs +469 -10
  233. data/stdlib/openssl/0/openssl.rbs +475 -357
  234. data/stdlib/optparse/0/optparse.rbs +26 -17
  235. data/stdlib/pathname/0/pathname.rbs +11 -1381
  236. data/stdlib/pp/0/pp.rbs +9 -8
  237. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  238. data/stdlib/pstore/0/pstore.rbs +35 -30
  239. data/stdlib/psych/0/psych.rbs +65 -12
  240. data/stdlib/psych/0/store.rbs +2 -4
  241. data/stdlib/pty/0/pty.rbs +9 -6
  242. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  243. data/stdlib/rdoc/0/code_object.rbs +2 -1
  244. data/stdlib/rdoc/0/parser.rbs +1 -1
  245. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  246. data/stdlib/rdoc/0/store.rbs +1 -1
  247. data/stdlib/resolv/0/resolv.rbs +25 -68
  248. data/stdlib/ripper/0/ripper.rbs +22 -19
  249. data/stdlib/securerandom/0/manifest.yaml +2 -0
  250. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  251. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  252. data/stdlib/singleton/0/singleton.rbs +3 -0
  253. data/stdlib/socket/0/addrinfo.rbs +7 -7
  254. data/stdlib/socket/0/basic_socket.rbs +3 -3
  255. data/stdlib/socket/0/ip_socket.rbs +10 -8
  256. data/stdlib/socket/0/socket.rbs +23 -10
  257. data/stdlib/socket/0/tcp_server.rbs +1 -1
  258. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  259. data/stdlib/socket/0/udp_socket.rbs +1 -1
  260. data/stdlib/socket/0/unix_server.rbs +1 -1
  261. data/stdlib/stringio/0/stringio.rbs +1177 -85
  262. data/stdlib/strscan/0/string_scanner.rbs +27 -25
  263. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  264. data/stdlib/time/0/time.rbs +8 -6
  265. data/stdlib/timeout/0/timeout.rbs +63 -7
  266. data/stdlib/tsort/0/cyclic.rbs +3 -0
  267. data/stdlib/tsort/0/tsort.rbs +7 -6
  268. data/stdlib/uri/0/common.rbs +42 -20
  269. data/stdlib/uri/0/file.rbs +3 -3
  270. data/stdlib/uri/0/generic.rbs +26 -18
  271. data/stdlib/uri/0/http.rbs +2 -2
  272. data/stdlib/uri/0/ldap.rbs +2 -2
  273. data/stdlib/uri/0/mailto.rbs +3 -3
  274. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  275. data/stdlib/zlib/0/deflate.rbs +4 -3
  276. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  277. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  278. data/stdlib/zlib/0/inflate.rbs +1 -1
  279. data/stdlib/zlib/0/need_dict.rbs +1 -1
  280. data/stdlib/zlib/0/zstream.rbs +1 -0
  281. metadata +50 -6
data/core/io.rbs CHANGED
@@ -7,9 +7,9 @@
7
7
  # classes in the Ruby standard library are also subclasses of IO; these include
8
8
  # TCPSocket and UDPSocket.
9
9
  #
10
- # The global constant ARGF (also accessible as `$<`) provides an IO-like stream
11
- # that allows access to all file paths found in ARGV (or found in STDIN if ARGV
12
- # is empty). ARGF is not itself a subclass of IO.
10
+ # The global constant ARGF (also accessible as <code>$<</code>) provides an
11
+ # IO-like stream that allows access to all file paths found in ARGV (or found in
12
+ # STDIN if ARGV is empty). ARGF is not itself a subclass of IO.
13
13
  #
14
14
  # Class StringIO provides an IO-like stream that handles a String. StringIO is
15
15
  # not itself a subclass of IO.
@@ -46,10 +46,10 @@
46
46
  # from the position mentioned above); see [Line
47
47
  # Number](rdoc-ref:IO@Line+Number).
48
48
  #
49
- # ## Extension `io/console`
49
+ # ## Extension <code>io/console</code>
50
50
  #
51
- # Extension `io/console` provides numerous methods for interacting with the
52
- # console; requiring it adds numerous methods to class IO.
51
+ # Extension <code>io/console</code> provides numerous methods for interacting
52
+ # with the console; requiring it adds numerous methods to class IO.
53
53
  #
54
54
  # ## Example Files
55
55
  #
@@ -86,23 +86,23 @@
86
86
  # A number of IO methods accept optional keyword arguments that determine how a
87
87
  # new stream is to be opened:
88
88
  #
89
- # * `:mode`: Stream mode.
90
- # * `:flags`: Integer file open flags; If `mode` is also given, the two are
91
- # bitwise-ORed.
92
- # * `:external_encoding`: External encoding for the stream.
93
- # * `:internal_encoding`: Internal encoding for the stream. `'-'` is a synonym
94
- # for the default internal encoding. If the value is `nil` no conversion
95
- # occurs.
96
- # * `:encoding`: Specifies external and internal encodings as
97
- # `'extern:intern'`.
98
- # * `:textmode`: If a truthy value, specifies the mode as text-only, binary
99
- # otherwise.
100
- # * `:binmode`: If a truthy value, specifies the mode as binary, text-only
101
- # otherwise.
102
- # * `:autoclose`: If a truthy value, specifies that the `fd` will close when
103
- # the stream closes; otherwise it remains open.
104
- # * `:path:` If a string value is provided, it is used in #inspect and is
105
- # available as #path method.
89
+ # * <code>:mode</code>: Stream mode.
90
+ # * <code>:flags</code>: Integer file open flags; If `mode` is also given, the
91
+ # two are bitwise-ORed.
92
+ # * <code>:external_encoding</code>: External encoding for the stream.
93
+ # * <code>:internal_encoding</code>: Internal encoding for the stream.
94
+ # <code>'-'</code> is a synonym for the default internal encoding. If the
95
+ # value is `nil` no conversion occurs.
96
+ # * <code>:encoding</code>: Specifies external and internal encodings as
97
+ # <code>'extern:intern'</code>.
98
+ # * <code>:textmode</code>: If a truthy value, specifies the mode as
99
+ # text-only, binary otherwise.
100
+ # * <code>:binmode</code>: If a truthy value, specifies the mode as binary,
101
+ # text-only otherwise.
102
+ # * <code>:autoclose</code>: If a truthy value, specifies that the `fd` will
103
+ # close when the stream closes; otherwise it remains open.
104
+ # * <code>:path:</code> If a string value is provided, it is used in #inspect
105
+ # and is available as #path method.
106
106
  #
107
107
  # Also available are the options offered in String#encode, which may control
108
108
  # conversion between external and internal encoding.
@@ -129,8 +129,8 @@
129
129
  #
130
130
  # The relevant methods:
131
131
  #
132
- # * IO#tell (aliased as `#pos`): Returns the current position (in bytes) in
133
- # the stream.
132
+ # * IO#tell (aliased as <code>#pos</code>): Returns the current position (in
133
+ # bytes) in the stream.
134
134
  # * IO#pos=: Sets the position of the stream to a given integer `new_position`
135
135
  # (in bytes).
136
136
  # * IO#seek: Sets the position of the stream to a given integer `offset` (in
@@ -158,8 +158,8 @@
158
158
  #
159
159
  # You can query whether a stream is positioned at its end:
160
160
  #
161
- # * IO#eof? (also aliased as `#eof`): Returns whether the stream is at
162
- # end-of-stream.
161
+ # * IO#eof? (also aliased as <code>#eof</code>): Returns whether the stream is
162
+ # at end-of-stream.
163
163
  #
164
164
  # You can reposition to end-of-stream by using method IO#seek:
165
165
  #
@@ -225,8 +225,8 @@
225
225
  # separator*: the string that determines what is considered a line; it is
226
226
  # sometimes called the *input record separator*.
227
227
  #
228
- # The default line separator is taken from global variable `$/`, whose initial
229
- # value is `"\n"`.
228
+ # The default line separator is taken from global variable <code>$/</code>,
229
+ # whose initial value is <code>"\n"</code>.
230
230
  #
231
231
  # Generally, the line to be read next is all data from the current
232
232
  # [position](rdoc-ref:IO@Position) to the next line separator (but see [Special
@@ -250,7 +250,7 @@
250
250
  # f.gets # => "e\n"
251
251
  # f.close
252
252
  #
253
- # Or by setting global variable `$/`:
253
+ # Or by setting global variable <code>$/</code>:
254
254
  #
255
255
  # f = File.new('t.txt')
256
256
  # $/ = 'l'
@@ -270,8 +270,8 @@
270
270
  # f.gets(nil) # => "First line\nSecond line\n\nFourth line\nFifth line\n"
271
271
  # f.close
272
272
  #
273
- # * `''` (the empty string): The next "paragraph" is to be read (paragraphs
274
- # being separated by two consecutive line separators):
273
+ # * <code>''</code> (the empty string): The next "paragraph" is to be read
274
+ # (paragraphs being separated by two consecutive line separators):
275
275
  #
276
276
  # f = File.new('t.txt')
277
277
  # f.gets('') # => "First line\nSecond line\n\n"
@@ -285,8 +285,8 @@
285
285
  # multi-byte character will not be split, and so a returned line may be slightly
286
286
  # longer than the limit).
287
287
  #
288
- # The default limit value is `-1`; any negative limit value means that there is
289
- # no limit.
288
+ # The default limit value is <code>-1</code>; any negative limit value means
289
+ # that there is no limit.
290
290
  #
291
291
  # If there is no limit, the line is determined only by `sep`.
292
292
  #
@@ -385,10 +385,10 @@
385
385
  # f.lineno # => 1001
386
386
  # f.close
387
387
  #
388
- # Associated with the line number is the global variable `$.`:
388
+ # Associated with the line number is the global variable <code>$.</code>:
389
389
  #
390
- # * When a stream is opened, `$.` is not set; its value is left over from
391
- # previous activity in the process:
390
+ # * When a stream is opened, <code>$.</code> is not set; its value is left
391
+ # over from previous activity in the process:
392
392
  #
393
393
  # $. = 41
394
394
  # f = File.new('t.txt')
@@ -396,7 +396,8 @@
396
396
  # # => 41
397
397
  # f.close
398
398
  #
399
- # * When a stream is read, `$.` is set to the line number for that stream:
399
+ # * When a stream is read, <code>$.</code> is set to the line number for that
400
+ # stream:
400
401
  #
401
402
  # f0 = File.new('t.txt')
402
403
  # f1 = File.new('t.dat')
@@ -407,7 +408,7 @@
407
408
  # f0.close
408
409
  # f1.close
409
410
  #
410
- # * Methods IO#rewind and IO#seek do not affect `$.`:
411
+ # * Methods IO#rewind and IO#seek do not affect <code>$.</code>:
411
412
  #
412
413
  # f = File.new('t.txt')
413
414
  # f.readlines # => ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
@@ -652,15 +653,17 @@ class IO < Object
652
653
  #
653
654
  # Argument `advice` is one of the following symbols:
654
655
  #
655
- # * `:normal`: The application has no advice to give about its access pattern
656
- # for the specified data. If no advice is given for an open file, this is
657
- # the default assumption.
658
- # * `:sequential`: The application expects to access the specified data
659
- # sequentially (with lower offsets read before higher ones).
660
- # * `:random`: The specified data will be accessed in random order.
661
- # * `:noreuse`: The specified data will be accessed only once.
662
- # * `:willneed`: The specified data will be accessed in the near future.
663
- # * `:dontneed`: The specified data will not be accessed in the near future.
656
+ # * <code>:normal</code>: The application has no advice to give about its
657
+ # access pattern for the specified data. If no advice is given for an open
658
+ # file, this is the default assumption.
659
+ # * <code>:sequential</code>: The application expects to access the specified
660
+ # data sequentially (with lower offsets read before higher ones).
661
+ # * <code>:random</code>: The specified data will be accessed in random order.
662
+ # * <code>:noreuse</code>: The specified data will be accessed only once.
663
+ # * <code>:willneed</code>: The specified data will be accessed in the near
664
+ # future.
665
+ # * <code>:dontneed</code>: The specified data will not be accessed in the
666
+ # near future.
664
667
  #
665
668
  # Not implemented on all platforms.
666
669
  #
@@ -724,8 +727,8 @@ class IO < Object
724
727
  # If the stream is open for writing, flushes any buffered writes to the
725
728
  # operating system before closing.
726
729
  #
727
- # If the stream was opened by IO.popen, sets global variable `$?` (child exit
728
- # status).
730
+ # If the stream was opened by IO.popen, sets global variable <code>$?</code>
731
+ # (child exit status).
729
732
  #
730
733
  # It is not an error to close an IO object that has already been closed. It just
731
734
  # returns nil.
@@ -790,7 +793,7 @@ class IO < Object
790
793
  # and Closed Streams](rdoc-ref:IO@Open+and+Closed+Streams).
791
794
  #
792
795
  # If the stream was opened by IO.popen and is also closed for writing, sets
793
- # global variable `$?` (child exit status).
796
+ # global variable <code>$?</code> (child exit status).
794
797
  #
795
798
  # Example:
796
799
  #
@@ -824,7 +827,7 @@ class IO < Object
824
827
  # Flushes any buffered writes to the operating system before closing.
825
828
  #
826
829
  # If the stream was opened by IO.popen and is also closed for reading, sets
827
- # global variable `$?` (child exit status).
830
+ # global variable <code>$?</code> (child exit status).
828
831
  #
829
832
  # IO.popen('ruby', 'r+') do |pipe|
830
833
  # puts pipe.closed?
@@ -990,8 +993,8 @@ class IO < Object
990
993
  # - fdatasync -> 0
991
994
  # -->
992
995
  # Immediately writes to disk all data buffered in the stream, via the operating
993
- # system's: `fdatasync(2)`, if supported, otherwise via `fsync(2)`, if
994
- # supported; otherwise raises an exception.
996
+ # system's: <code>fdatasync(2)</code>, if supported, otherwise via
997
+ # <code>fsync(2)</code>, if supported; otherwise raises an exception.
995
998
  #
996
999
  def fdatasync: () -> Integer?
997
1000
 
@@ -1026,7 +1029,7 @@ class IO < Object
1026
1029
  # - fsync -> 0
1027
1030
  # -->
1028
1031
  # Immediately writes to disk all data buffered in the stream, via the operating
1029
- # system's `fsync(2)`.
1032
+ # system's <code>fsync(2)</code>.
1030
1033
  #
1031
1034
  # Note this difference:
1032
1035
  #
@@ -1036,7 +1039,8 @@ class IO < Object
1036
1039
  # * IO#fsync: Ensures both that data is flushed from internal buffers, and
1037
1040
  # that data is written to disk.
1038
1041
  #
1039
- # Raises an exception if the operating system does not support `fsync(2)`.
1042
+ # Raises an exception if the operating system does not support
1043
+ # <code>fsync(2)</code>.
1040
1044
  #
1041
1045
  def fsync: () -> Integer?
1042
1046
 
@@ -1082,11 +1086,11 @@ class IO < Object
1082
1086
  # - gets(limit, chomp: false) -> string or nil
1083
1087
  # - gets(sep, limit, chomp: false) -> string or nil
1084
1088
  # -->
1085
- # Reads and returns a line from the stream; assigns the return value to `$_`.
1086
- # See [Line IO](rdoc-ref:IO@Line+IO).
1089
+ # Reads and returns a line from the stream; assigns the return value to
1090
+ # <code>$_</code>. See [Line IO](rdoc-ref:IO@Line+IO).
1087
1091
  #
1088
1092
  # With no arguments given, returns the next line as determined by line separator
1089
- # `$/`, or `nil` if none:
1093
+ # <code>$/</code>, or `nil` if none:
1090
1094
  #
1091
1095
  # f = File.open('t.txt')
1092
1096
  # f.gets # => "First line\n"
@@ -1316,15 +1320,15 @@ class IO < Object
1316
1320
  # - print(*objects) -> nil
1317
1321
  # -->
1318
1322
  # Writes the given objects to the stream; returns `nil`. Appends the output
1319
- # record separator `$OUTPUT_RECORD_SEPARATOR` (`$\`), if it is not `nil`. See
1320
- # [Line IO](rdoc-ref:IO@Line+IO).
1323
+ # record separator <code>$OUTPUT_RECORD_SEPARATOR</code> (<code>$\</code>), if
1324
+ # it is not `nil`. See [Line IO](rdoc-ref:IO@Line+IO).
1321
1325
  #
1322
1326
  # With argument `objects` given, for each object:
1323
1327
  #
1324
1328
  # * Converts via its method `to_s` if not a string.
1325
1329
  # * Writes to the stream.
1326
1330
  # * If not the last object, writes the output field separator
1327
- # `$OUTPUT_FIELD_SEPARATOR` (`$,`) if it is not `nil`.
1331
+ # <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code>) if it is not `nil`.
1328
1332
  #
1329
1333
  # With default separators:
1330
1334
  #
@@ -1356,8 +1360,8 @@ class IO < Object
1356
1360
  #
1357
1361
  # "0,0.0,0/1,0+0i,zero,zero\n"
1358
1362
  #
1359
- # With no argument given, writes the content of `$_` (which is usually the most
1360
- # recent user input):
1363
+ # With no argument given, writes the content of <code>$_</code> (which is
1364
+ # usually the most recent user input):
1361
1365
  #
1362
1366
  # f = File.open('t.tmp', 'w+')
1363
1367
  # gets # Sets $_ to the most recent user input.
@@ -1373,7 +1377,7 @@ class IO < Object
1373
1377
  # Formats and writes `objects` to the stream.
1374
1378
  #
1375
1379
  # For details on `format_string`, see [Format
1376
- # Specifications](rdoc-ref:format_specifications.rdoc).
1380
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
1377
1381
  #
1378
1382
  def printf: (String format_string, *untyped objects) -> nil
1379
1383
 
@@ -1406,13 +1410,13 @@ class IO < Object
1406
1410
  # newline sequence. If called without arguments, writes a newline. See [Line
1407
1411
  # IO](rdoc-ref:IO@Line+IO).
1408
1412
  #
1409
- # Note that each added newline is the character `"\n"<//tt>, not the output
1410
- # record separator (<tt>$\`).
1413
+ # Note that each added newline is the character <code>"\n"<//tt>, not the output
1414
+ # record separator (<tt>$\</code>).
1411
1415
  #
1412
1416
  # Treatment for each object:
1413
1417
  #
1414
1418
  # * String: writes the string.
1415
- # * Neither string nor array: writes `object.to_s`.
1419
+ # * Neither string nor array: writes <code>object.to_s</code>.
1416
1420
  # * Array: writes each element of the array; arrays may be nested.
1417
1421
  #
1418
1422
  # To keep these examples brief, we define this helper method:
@@ -1443,6 +1447,61 @@ class IO < Object
1443
1447
  #
1444
1448
  def puts: (*untyped objects) -> nil
1445
1449
 
1450
+ # <!--
1451
+ # rdoc-file=io.c
1452
+ # - pread(maxlen, offset) -> string
1453
+ # - pread(maxlen, offset, out_string) -> string
1454
+ # -->
1455
+ # Behaves like IO#readpartial, except that it:
1456
+ #
1457
+ # * Reads at the given `offset` (in bytes).
1458
+ # * Disregards, and does not modify, the stream's position (see
1459
+ # [Position](rdoc-ref:IO@Position)).
1460
+ # * Bypasses any user space buffering in the stream.
1461
+ #
1462
+ # Because this method does not disturb the stream's state (its position, in
1463
+ # particular), `pread` allows multiple threads and processes to use the same IO
1464
+ # object for reading at various offsets.
1465
+ #
1466
+ # f = File.open('t.txt')
1467
+ # f.read # => "First line\nSecond line\n\nFourth line\nFifth line\n"
1468
+ # f.pos # => 52
1469
+ # # Read 12 bytes at offset 0.
1470
+ # f.pread(12, 0) # => "First line\n"
1471
+ # # Read 9 bytes at offset 8.
1472
+ # f.pread(9, 8) # => "ne\nSecon"
1473
+ # f.close
1474
+ #
1475
+ # Not available on some platforms.
1476
+ #
1477
+ def pread: (int maxlen, int offset, ?string out_string) -> String
1478
+
1479
+ # <!--
1480
+ # rdoc-file=io.c
1481
+ # - pwrite(object, offset) -> integer
1482
+ # -->
1483
+ # Behaves like IO#write, except that it:
1484
+ #
1485
+ # * Writes at the given `offset` (in bytes).
1486
+ # * Disregards, and does not modify, the stream's position (see
1487
+ # [Position](rdoc-ref:IO@Position)).
1488
+ # * Bypasses any user space buffering in the stream.
1489
+ #
1490
+ # Because this method does not disturb the stream's state (its position, in
1491
+ # particular), `pwrite` allows multiple threads and processes to use the same IO
1492
+ # object for writing at various offsets.
1493
+ #
1494
+ # f = File.open('t.tmp', 'w+')
1495
+ # # Write 6 bytes at offset 3.
1496
+ # f.pwrite('ABCDEF', 3) # => 6
1497
+ # f.rewind
1498
+ # f.read # => "\u0000\u0000\u0000ABCDEF"
1499
+ # f.close
1500
+ #
1501
+ # Not available on some platforms.
1502
+ #
1503
+ def pwrite: (_ToS object, int offset) -> Integer
1504
+
1446
1505
  # <!--
1447
1506
  # rdoc-file=io.c
1448
1507
  # - read(maxlen = nil, out_string = nil) -> new_string, out_string, or nil
@@ -1464,7 +1523,7 @@ class IO < Object
1464
1523
  # * `out_string` given: encoding of `out_string` not modified.
1465
1524
  # * `out_string` not given: ASCII-8BIT is used.
1466
1525
  #
1467
- # **Without Argument `out_string`**
1526
+ # <strong>Without Argument `out_string`</strong>
1468
1527
  #
1469
1528
  # When argument `out_string` is omitted, the returned value is a new string:
1470
1529
  #
@@ -1479,7 +1538,7 @@ class IO < Object
1479
1538
  #
1480
1539
  # If `maxlen` is zero, returns an empty string.
1481
1540
  #
1482
- # ** With Argument `out_string`**
1541
+ # <strong> With Argument `out_string`</strong>
1483
1542
  #
1484
1543
  # When argument `out_string` is given, the returned value is `out_string`, whose
1485
1544
  # content is replaced:
@@ -1565,8 +1624,8 @@ class IO < Object
1565
1624
  #
1566
1625
  # By specifying a keyword argument *exception* to `false`, you can indicate that
1567
1626
  # read_nonblock should not raise an IO::WaitReadable exception, but return the
1568
- # symbol `:wait_readable` instead. At EOF, it will return nil instead of raising
1569
- # EOFError.
1627
+ # symbol <code>:wait_readable</code> instead. At EOF, it will return nil instead
1628
+ # of raising EOFError.
1570
1629
  #
1571
1630
  def read_nonblock: (int len, ?string buf, ?exception: true) -> String
1572
1631
  | (int len, ?string buf, exception: false) -> (String | :wait_readable | nil)
@@ -1626,11 +1685,11 @@ class IO < Object
1626
1685
  # - readlines(limit, chomp: false) -> array
1627
1686
  # - readlines(sep, limit, chomp: false) -> array
1628
1687
  # -->
1629
- # Reads and returns all remaining line from the stream; does not modify `$_`.
1630
- # See [Line IO](rdoc-ref:IO@Line+IO).
1688
+ # Reads and returns all remaining line from the stream; does not modify
1689
+ # <code>$_</code>. See [Line IO](rdoc-ref:IO@Line+IO).
1631
1690
  #
1632
- # With no arguments given, returns lines as determined by line separator `$/`,
1633
- # or `nil` if none:
1691
+ # With no arguments given, returns lines as determined by line separator
1692
+ # <code>$/</code>, or `nil` if none:
1634
1693
  #
1635
1694
  # f = File.new('t.txt')
1636
1695
  # f.readlines
@@ -1836,8 +1895,8 @@ class IO < Object
1836
1895
  # Seeks to the position given by integer `offset` (see
1837
1896
  # [Position](rdoc-ref:IO@Position)) and constant `whence`, which is one of:
1838
1897
  #
1839
- # * `:CUR` or `IO::SEEK_CUR`: Repositions the stream to its current position
1840
- # plus the given `offset`:
1898
+ # * <code>:CUR</code> or <code>IO::SEEK_CUR</code>: Repositions the stream to
1899
+ # its current position plus the given `offset`:
1841
1900
  #
1842
1901
  # f = File.open('t.txt')
1843
1902
  # f.tell # => 0
@@ -1847,8 +1906,8 @@ class IO < Object
1847
1906
  # f.tell # => 10
1848
1907
  # f.close
1849
1908
  #
1850
- # * `:END` or `IO::SEEK_END`: Repositions the stream to its end plus the given
1851
- # `offset`:
1909
+ # * <code>:END</code> or <code>IO::SEEK_END</code>: Repositions the stream to
1910
+ # its end plus the given `offset`:
1852
1911
  #
1853
1912
  # f = File.open('t.txt')
1854
1913
  # f.tell # => 0
@@ -1860,7 +1919,8 @@ class IO < Object
1860
1919
  # f.tell # => 12
1861
1920
  # f.close
1862
1921
  #
1863
- # * `:SET` or `IO:SEEK_SET`: Repositions the stream to the given `offset`:
1922
+ # * <code>:SET</code> or <code>IO:SEEK_SET</code>: Repositions the stream to
1923
+ # the given `offset`:
1864
1924
  #
1865
1925
  # f = File.open('t.txt')
1866
1926
  # f.tell # => 0
@@ -1888,7 +1948,7 @@ class IO < Object
1888
1948
  # Argument `int_enc`, if given, must be an Encoding object or a String with the
1889
1949
  # encoding name; it is assigned as the encoding for the internal string.
1890
1950
  #
1891
- # Argument `'ext_enc:int_enc'`, if given, is a string containing two
1951
+ # Argument <code>'ext_enc:int_enc'</code>, if given, is a string containing two
1892
1952
  # colon-separated encoding names; corresponding Encoding objects are assigned as
1893
1953
  # the external and internal encodings for the stream.
1894
1954
  #
@@ -2258,11 +2318,11 @@ class IO < Object
2258
2318
  #
2259
2319
  # On some platforms such as Windows, write_nonblock is not supported according
2260
2320
  # to the kind of the IO object. In such cases, write_nonblock raises
2261
- # `Errno::EBADF`.
2321
+ # <code>Errno::EBADF</code>.
2262
2322
  #
2263
2323
  # By specifying a keyword argument *exception* to `false`, you can indicate that
2264
2324
  # write_nonblock should not raise an IO::WaitWritable exception, but return the
2265
- # symbol `:wait_writable` instead.
2325
+ # symbol <code>:wait_writable</code> instead.
2266
2326
  #
2267
2327
  def write_nonblock: (_ToS s, ?exception: true) -> Integer
2268
2328
  | (_ToS s, exception: false) -> (Integer | :wait_writable | nil)
@@ -2274,10 +2334,6 @@ class IO < Object
2274
2334
  # Behaves like IO.read, except that the stream is opened in binary mode with
2275
2335
  # ASCII-8BIT encoding.
2276
2336
  #
2277
- # When called from class IO (but not subclasses of IO), this method has
2278
- # potential security vulnerabilities if called with untrusted input; see
2279
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2280
- #
2281
2337
  def self.binread: (path name, ?Integer? length, ?Integer offset) -> String
2282
2338
 
2283
2339
  # <!--
@@ -2287,10 +2343,6 @@ class IO < Object
2287
2343
  # Behaves like IO.write, except that the stream is opened in binary mode with
2288
2344
  # ASCII-8BIT encoding.
2289
2345
  #
2290
- # When called from class IO (but not subclasses of IO), this method has
2291
- # potential security vulnerabilities if called with untrusted input; see
2292
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2293
- #
2294
2346
  def self.binwrite: (path name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
2295
2347
 
2296
2348
  # <!--
@@ -2304,15 +2356,15 @@ class IO < Object
2304
2356
  #
2305
2357
  # * The path to a readable file, from which source data is to be read.
2306
2358
  # * An IO-like object, opened for reading and capable of responding to
2307
- # method `:readpartial` or method `:read`.
2359
+ # method <code>:readpartial</code> or method <code>:read</code>.
2308
2360
  #
2309
2361
  # * The given `dst` must be one of the following:
2310
2362
  #
2311
2363
  # * The path to a writable file, to which data is to be written.
2312
2364
  # * An IO-like object, opened for writing and capable of responding to
2313
- # method `:write`.
2365
+ # method <code>:write</code>.
2314
2366
  #
2315
- # The examples here use file `t.txt` as source:
2367
+ # The examples here use file <code>t.txt</code> as source:
2316
2368
  #
2317
2369
  # File.read('t.txt')
2318
2370
  # # => "First line\nSecond line\n\nThird line\nFourth line\n"
@@ -2354,15 +2406,16 @@ class IO < Object
2354
2406
  # connected to a new stream `io`.
2355
2407
  #
2356
2408
  # This method has potential security vulnerabilities if called with untrusted
2357
- # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
2409
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
2358
2410
  #
2359
2411
  # If no block is given, returns the new stream, which depending on given `mode`
2360
2412
  # may be open for reading, writing, or both. The stream should be explicitly
2361
2413
  # closed (eventually) to avoid resource leaks.
2362
2414
  #
2363
2415
  # If a block is given, the stream is passed to the block (again, open for
2364
- # reading, writing, or both); when the block exits, the stream is closed, and
2365
- # the block's value is assigned to global variable `$?` and returned.
2416
+ # reading, writing, or both); when the block exits, the stream is closed, the
2417
+ # block's value is returned, and the global variable <code>$?</code> is set to
2418
+ # the child's exit status.
2366
2419
  #
2367
2420
  # Optional argument `mode` may be any valid IO mode. See [Access
2368
2421
  # Modes](rdoc-ref:File@Access+Modes).
@@ -2391,10 +2444,10 @@ class IO < Object
2391
2444
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2392
2445
  # * Options for Kernel#spawn.
2393
2446
  #
2394
- # **Forked \Process**
2447
+ # **Forked Process**
2395
2448
  #
2396
- # When argument `cmd` is the 1-character string `'-'`, causes the process to
2397
- # fork:
2449
+ # When argument `cmd` is the 1-character string <code>'-'</code>, causes the
2450
+ # process to fork:
2398
2451
  # IO.popen('-') do |pipe|
2399
2452
  # if pipe
2400
2453
  # $stderr.puts "In parent, child pid is #{pipe.pid}\n"
@@ -2412,8 +2465,8 @@ class IO < Object
2412
2465
  #
2413
2466
  # **Shell Subprocess**
2414
2467
  #
2415
- # When argument `cmd` is a single string (but not `'-'`), the program named
2416
- # `cmd` is run as a shell command:
2468
+ # When argument `cmd` is a single string (but not <code>'-'</code>), the program
2469
+ # named `cmd` is run as a shell command:
2417
2470
  #
2418
2471
  # IO.popen('uname') do |pipe|
2419
2472
  # pipe.readlines
@@ -2437,8 +2490,8 @@ class IO < Object
2437
2490
  #
2438
2491
  # **Program Subprocess**
2439
2492
  #
2440
- # When argument `cmd` is an array of strings, the program named `cmd[0]` is run
2441
- # with all elements of `cmd` as its arguments:
2493
+ # When argument `cmd` is an array of strings, the program named
2494
+ # <code>cmd[0]</code> is run with all elements of `cmd` as its arguments:
2442
2495
  #
2443
2496
  # IO.popen(['du', '..', '.']) do |pipe|
2444
2497
  # $stderr.puts pipe.readlines.size
@@ -2448,18 +2501,19 @@ class IO < Object
2448
2501
  #
2449
2502
  # 1111
2450
2503
  #
2451
- # **Program Subprocess with `argv0`**
2504
+ # <strong>Program Subprocess with `argv0`</strong>
2452
2505
  #
2453
2506
  # When argument `cmd` is an array whose first element is a 2-element string
2454
2507
  # array and whose remaining elements (if any) are strings:
2455
2508
  #
2456
- # * `cmd[0][0]` (the first string in the nested array) is the name of a
2457
- # program that is run.
2458
- # * `cmd[0][1]` (the second string in the nested array) is set as the
2459
- # program's `argv[0]`.
2460
- # * `cmd[1..-1]` (the strings in the outer array) are the program's arguments.
2509
+ # * <code>cmd[0][0]</code> (the first string in the nested array) is the name
2510
+ # of a program that is run.
2511
+ # * <code>cmd[0][1]</code> (the second string in the nested array) is set as
2512
+ # the program's <code>argv[0]</code>.
2513
+ # * <code>cmd[1..-1]</code> (the strings in the outer array) are the program's
2514
+ # arguments.
2461
2515
  #
2462
- # Example (sets `$0` to 'foo'):
2516
+ # Example (sets <code>$0</code> to 'foo'):
2463
2517
  #
2464
2518
  # IO.popen([['/bin/sh', 'foo'], '-c', 'echo $0']).read # => "foo\n"
2465
2519
  #
@@ -2503,10 +2557,10 @@ class IO < Object
2503
2557
  #
2504
2558
  # Raises exceptions that IO.pipe and Kernel.spawn raise.
2505
2559
  #
2506
- 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
2507
- | (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
2508
- | [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
2509
- | [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
2560
+ 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: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: bool, ?chdir: String) -> instance
2561
+ | (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: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: bool, ?chdir: String) -> instance
2562
+ | [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: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: bool, ?chdir: String) { (instance) -> X } -> X
2563
+ | [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: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: bool, ?chdir: String) { (instance) -> X } -> X
2510
2564
 
2511
2565
  # The command can be given as:
2512
2566
  #
@@ -2526,10 +2580,6 @@ class IO < Object
2526
2580
  # -->
2527
2581
  # Calls the block with each successive line read from the stream.
2528
2582
  #
2529
- # When called from class IO (but not subclasses of IO), this method has
2530
- # potential security vulnerabilities if called with untrusted input; see
2531
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2532
- #
2533
2583
  # The first argument must be a string that is the path to a file.
2534
2584
  #
2535
2585
  # With only argument `path` given, parses lines from the file at the given
@@ -2594,8 +2644,8 @@ class IO < Object
2594
2644
  #
2595
2645
  # Returns an Enumerator if no block is given.
2596
2646
  #
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
2598
- | (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) -> ::Enumerator[String, nil]
2647
+ def self.foreach: (path 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
2648
+ | (path 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) -> ::Enumerator[String, nil]
2599
2649
 
2600
2650
  # <!--
2601
2651
  # rdoc-file=io.c
@@ -2651,8 +2701,8 @@ class IO < Object
2651
2701
  # In the example below, the two processes close the ends of the pipe that they
2652
2702
  # are not using. This is not just a cosmetic nicety. The read end of a pipe will
2653
2703
  # not generate an end of file condition if there are any writers with the pipe
2654
- # still open. In the case of the parent process, the `rd.read` will never return
2655
- # if it does not first issue a `wr.close`:
2704
+ # still open. In the case of the parent process, the <code>rd.read</code> will
2705
+ # never return if it does not first issue a <code>wr.close</code>:
2656
2706
  #
2657
2707
  # rd, wr = IO.pipe
2658
2708
  #
@@ -2668,7 +2718,7 @@ class IO < Object
2668
2718
  # wr.close
2669
2719
  # end
2670
2720
  #
2671
- # *produces:*
2721
+ # <em>produces:</em>
2672
2722
  #
2673
2723
  # Sending message to parent
2674
2724
  # Parent got: <Hi Dad>
@@ -2683,10 +2733,6 @@ class IO < Object
2683
2733
  # Opens the stream, reads and returns some or all of its content, and closes the
2684
2734
  # stream; returns `nil` if no bytes were read.
2685
2735
  #
2686
- # When called from class IO (but not subclasses of IO), this method has
2687
- # potential security vulnerabilities if called with untrusted input; see
2688
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2689
- #
2690
2736
  # The first argument must be a string that is the path to a file.
2691
2737
  #
2692
2738
  # With only argument `path` given, reads in text mode and returns the entire
@@ -2726,10 +2772,6 @@ class IO < Object
2726
2772
  # -->
2727
2773
  # Returns an array of all lines read from the stream.
2728
2774
  #
2729
- # When called from class IO (but not subclasses of IO), this method has
2730
- # potential security vulnerabilities if called with untrusted input; see
2731
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2732
- #
2733
2775
  # The first argument must be a string that is the path to a file.
2734
2776
  #
2735
2777
  # With only argument `path` given, parses lines from the file at the given
@@ -2769,7 +2811,7 @@ class IO < Object
2769
2811
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2770
2812
  # * [Line Options](rdoc-ref:IO@Line+IO).
2771
2813
  #
2772
- 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]
2814
+ def self.readlines: (path 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]
2773
2815
 
2774
2816
  # <!--
2775
2817
  # rdoc-file=io.c
@@ -2785,7 +2827,9 @@ class IO < Object
2785
2827
  # IO objects.
2786
2828
  #
2787
2829
  # Argument `timeout` is a numeric value (such as integer or float) timeout
2788
- # interval in seconds.
2830
+ # interval in seconds. `timeout` can also be `nil` or
2831
+ # <code>Float::INFINITY</code>. `nil` and <code>Float::INFINITY</code> means no
2832
+ # timeout.
2789
2833
  #
2790
2834
  # The method monitors the IO objects given in all three arrays, waiting for some
2791
2835
  # to be ready; returns a 3-element array whose elements are:
@@ -2860,8 +2904,8 @@ class IO < Object
2860
2904
  #
2861
2905
  # The writability notified by select(2) doesn't show how many bytes are
2862
2906
  # writable. IO#write method blocks until given whole string is written. So,
2863
- # `IO#write(two or more bytes)` can block after writability is notified by
2864
- # IO.select. IO#write_nonblock is required to avoid the blocking.
2907
+ # <code>IO#write(two or more bytes)</code> can block after writability is
2908
+ # notified by IO.select. IO#write_nonblock is required to avoid the blocking.
2865
2909
  #
2866
2910
  # Blocking write (#write) can be emulated using #write_nonblock and IO.select as
2867
2911
  # follows: IO::WaitReadable should also be rescued for SSL renegotiation in
@@ -2950,10 +2994,6 @@ class IO < Object
2950
2994
  # Opens the stream, writes the given `data` to it, and closes the stream;
2951
2995
  # returns the number of bytes written.
2952
2996
  #
2953
- # When called from class IO (but not subclasses of IO), this method has
2954
- # potential security vulnerabilities if called with untrusted input; see
2955
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2956
- #
2957
2997
  # The first argument must be a string that is the path to a file.
2958
2998
  #
2959
2999
  # With only argument `path` given, writes the given `data` to the file at that
@@ -2976,7 +3016,7 @@ class IO < Object
2976
3016
  # File.read('t.tmp') # => "ab012f"
2977
3017
  #
2978
3018
  # If `offset` is outside the file content, the file is padded with null
2979
- # characters `"\u0000"`:
3019
+ # characters <code>"\u0000"</code>:
2980
3020
  #
2981
3021
  # IO.write('t.tmp', 'xyz', 10) # => 3
2982
3022
  # File.read('t.tmp') # => "ab012f\u0000\u0000\u0000\u0000xyz"
@@ -3015,7 +3055,8 @@ class IO < Object
3015
3055
  # Calls the block with each remaining line read from the stream; returns `self`.
3016
3056
  # Does nothing if already at end-of-stream; See [Line IO](rdoc-ref:IO@Line+IO).
3017
3057
  #
3018
- # With no arguments given, reads lines as determined by line separator `$/`:
3058
+ # With no arguments given, reads lines as determined by line separator
3059
+ # <code>$/</code>:
3019
3060
  #
3020
3061
  # f = File.new('t.txt')
3021
3062
  # f.each_line {|line| p line }
@@ -3117,7 +3158,8 @@ class IO < Object
3117
3158
  # Calls the block with each remaining line read from the stream; returns `self`.
3118
3159
  # Does nothing if already at end-of-stream; See [Line IO](rdoc-ref:IO@Line+IO).
3119
3160
  #
3120
- # With no arguments given, reads lines as determined by line separator `$/`:
3161
+ # With no arguments given, reads lines as determined by line separator
3162
+ # <code>$/</code>:
3121
3163
  #
3122
3164
  # f = File.new('t.txt')
3123
3165
  # f.each_line {|line| p line }
@@ -3404,3 +3446,9 @@ end
3404
3446
  #
3405
3447
  module IO::WaitWritable
3406
3448
  end
3449
+
3450
+ # <!-- rdoc-file=io.c -->
3451
+ # Can be raised by IO operations when IO#timeout= is set.
3452
+ #
3453
+ class IO::TimeoutError < IOError
3454
+ end