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/file.rbs CHANGED
@@ -2,7 +2,7 @@
2
2
  # A File object is a representation of a file in the underlying platform.
3
3
  #
4
4
  # Class File extends module FileTest, supporting such singleton methods as
5
- # `File.exist?`.
5
+ # <code>File.exist?</code>.
6
6
  #
7
7
  # ## About the Examples
8
8
  #
@@ -93,8 +93,8 @@
93
93
  # | 'a+' | Anywhere | 0 | End only | End |
94
94
  # |------|----------|----------|----------|-----------|
95
95
  #
96
- # Note that modes `'r'` and `'r+'` are not allowed for a non-existent file
97
- # (exception raised).
96
+ # Note that modes <code>'r'</code> and <code>'r+'</code> are not allowed for a
97
+ # non-existent file (exception raised).
98
98
  #
99
99
  # In the tables:
100
100
  #
@@ -108,7 +108,7 @@
108
108
  #
109
109
  # ##### Read/Write Modes for Existing File
110
110
  #
111
- # * `'r'`:
111
+ # * <code>'r'</code>:
112
112
  #
113
113
  # * File is not initially truncated:
114
114
  #
@@ -137,7 +137,7 @@
137
137
  #
138
138
  # f.write('foo') # Raises IOError.
139
139
  #
140
- # * `'w'`:
140
+ # * <code>'w'</code>:
141
141
  #
142
142
  # * File is initially truncated:
143
143
  #
@@ -191,7 +191,7 @@
191
191
  #
192
192
  # f.read # Raises IOError.
193
193
  #
194
- # * `'a'`:
194
+ # * <code>'a'</code>:
195
195
  #
196
196
  # * File is not initially truncated:
197
197
  #
@@ -223,7 +223,7 @@
223
223
  #
224
224
  # f.read # Raises IOError.
225
225
  #
226
- # * `'r+'`:
226
+ # * <code>'r+'</code>:
227
227
  #
228
228
  # * File is not initially truncated:
229
229
  #
@@ -278,7 +278,7 @@
278
278
  # File.read(path)
279
279
  # # => "WWWst lineXXXecond line\nFourth line\nFifth YYYe\n\u0000\u0000ZZZ"
280
280
  #
281
- # * `'a+'`:
281
+ # * <code>'a+'</code>:
282
282
  #
283
283
  # * File is not initially truncated:
284
284
  #
@@ -319,10 +319,10 @@
319
319
  #
320
320
  # ##### Read/Write Modes for File To Be Created
321
321
  #
322
- # Note that modes `'r'` and `'r+'` are not allowed for a non-existent file
323
- # (exception raised).
322
+ # Note that modes <code>'r'</code> and <code>'r+'</code> are not allowed for a
323
+ # non-existent file (exception raised).
324
324
  #
325
- # * `'w'`:
325
+ # * <code>'w'</code>:
326
326
  #
327
327
  # * File's initial write position is 0:
328
328
  #
@@ -372,7 +372,7 @@
372
372
  #
373
373
  # f.read # Raises IOError.
374
374
  #
375
- # * `'a'`:
375
+ # * <code>'a'</code>:
376
376
  #
377
377
  # * File's initial write position is 0:
378
378
  #
@@ -399,7 +399,7 @@
399
399
  #
400
400
  # f.read # Raises IOError.
401
401
  #
402
- # * `'w+'`:
402
+ # * <code>'w+'</code>:
403
403
  #
404
404
  # * File's initial position is 0:
405
405
  #
@@ -463,7 +463,7 @@
463
463
  # f.read
464
464
  # # => "bah"
465
465
  #
466
- # * `'a+'`:
466
+ # * <code>'a+'</code>:
467
467
  #
468
468
  # * File's initial write position is 0:
469
469
  #
@@ -506,12 +506,13 @@
506
506
  # To specify whether data is to be treated as text or as binary data, either of
507
507
  # the following may be suffixed to any of the string read/write modes above:
508
508
  #
509
- # * `'t'`: Text data; sets the default external encoding to `Encoding::UTF_8`;
510
- # on Windows, enables conversion between EOL and CRLF and enables
511
- # interpreting `0x1A` as an end-of-file marker.
512
- # * `'b'`: Binary data; sets the default external encoding to
513
- # `Encoding::ASCII_8BIT`; on Windows, suppresses conversion between EOL and
514
- # CRLF and disables interpreting `0x1A` as an end-of-file marker.
509
+ # * <code>'t'</code>: Text data; sets the default external encoding to
510
+ # <code>Encoding::UTF_8</code>; on Windows, enables conversion between EOL
511
+ # and CRLF and enables interpreting `0x1A` as an end-of-file marker.
512
+ # * <code>'b'</code>: Binary data; sets the default external encoding to
513
+ # <code>Encoding::ASCII_8BIT</code>; on Windows, suppresses conversion
514
+ # between EOL and CRLF and disables interpreting `0x1A` as an end-of-file
515
+ # marker.
515
516
  #
516
517
  # If neither is given, the stream defaults to text data.
517
518
  #
@@ -530,8 +531,8 @@
530
531
  #
531
532
  # The following may be suffixed to any writable string mode above:
532
533
  #
533
- # * `'x'`: Creates the file if it does not exist; raises an exception if the
534
- # file exists.
534
+ # * <code>'x'</code>: Creates the file if it does not exist; raises an
535
+ # exception if the file exists.
535
536
  #
536
537
  # Example:
537
538
  #
@@ -546,12 +547,12 @@
546
547
  # ### Integer Access Modes
547
548
  #
548
549
  # When mode is an integer it must be one or more of the following constants,
549
- # which may be combined by the bitwise OR operator `|`:
550
+ # which may be combined by the bitwise OR operator <code>|</code>:
550
551
  #
551
- # * `File::RDONLY`: Open for reading only.
552
- # * `File::WRONLY`: Open for writing only.
553
- # * `File::RDWR`: Open for reading and writing.
554
- # * `File::APPEND`: Open for appending only.
552
+ # * <code>File::RDONLY</code>: Open for reading only.
553
+ # * <code>File::WRONLY</code>: Open for writing only.
554
+ # * <code>File::RDWR</code>: Open for reading and writing.
555
+ # * <code>File::APPEND</code>: Open for appending only.
555
556
  #
556
557
  # Examples:
557
558
  #
@@ -565,19 +566,19 @@
565
566
  #
566
567
  # These constants may also be ORed into the integer mode:
567
568
  #
568
- # * `File::CREAT`: Create file if it does not exist.
569
- # * `File::EXCL`: Raise an exception if `File::CREAT` is given and the file
570
- # exists.
569
+ # * <code>File::CREAT</code>: Create file if it does not exist.
570
+ # * <code>File::EXCL</code>: Raise an exception if <code>File::CREAT</code> is
571
+ # given and the file exists.
571
572
  #
572
573
  # ### Data Mode Specified as an Integer
573
574
  #
574
575
  # Data mode cannot be specified as an integer. When the stream access mode is
575
576
  # given as an integer, the data mode is always text, never binary.
576
577
  #
577
- # Note that although there is a constant `File::BINARY`, setting its value in an
578
- # integer stream mode has no effect; this is because, as documented in
579
- # File::Constants, the `File::BINARY` value disables line code conversion, but
580
- # does not change the external encoding.
578
+ # Note that although there is a constant <code>File::BINARY</code>, setting its
579
+ # value in an integer stream mode has no effect; this is because, as documented
580
+ # in File::Constants, the <code>File::BINARY</code> value disables line code
581
+ # conversion, but does not change the external encoding.
581
582
  #
582
583
  # ### Encodings
583
584
  #
@@ -608,14 +609,14 @@
608
609
  # internal to external encoding. For further details about transcoding input and
609
610
  # output, see [Encodings](rdoc-ref:encodings.rdoc@Encodings).
610
611
  #
611
- # If the external encoding is `'BOM|UTF-8'`, `'BOM|UTF-16LE'` or
612
- # `'BOM|UTF16-BE'`, Ruby checks for a Unicode BOM in the input document to help
613
- # determine the encoding. For UTF-16 encodings the file open mode must be
614
- # binary. If the BOM is found, it is stripped and the external encoding from the
615
- # BOM is used.
612
+ # If the external encoding is <code>'BOM|UTF-8'</code>,
613
+ # <code>'BOM|UTF-16LE'</code> or <code>'BOM|UTF16-BE'</code>, Ruby checks for a
614
+ # Unicode BOM in the input document to help determine the encoding. For UTF-16
615
+ # encodings the file open mode must be binary. If the BOM is found, it is
616
+ # stripped and the external encoding from the BOM is used.
616
617
  #
617
- # Note that the BOM-style encoding option is case insensitive, so `'bom|utf-8'`
618
- # is also valid.
618
+ # Note that the BOM-style encoding option is case insensitive, so
619
+ # <code>'bom|utf-8'</code> is also valid.
619
620
  #
620
621
  # ## File Permissions
621
622
  #
@@ -669,7 +670,7 @@
669
670
  #
670
671
  # Various constants for use in File and IO methods may be found in module
671
672
  # File::Constants; an array of their names is returned by
672
- # `File::Constants.constants`.
673
+ # <code>File::Constants.constants</code>.
673
674
  #
674
675
  # ## What's Here
675
676
  #
@@ -705,7 +706,7 @@
705
706
  # * ::basename: Returns the last component of the given file path.
706
707
  # * ::dirname: Returns all but the last component of the given file path.
707
708
  # * ::expand_path: Returns the absolute file path for the given path,
708
- # expanding `~` for a home directory.
709
+ # expanding <code>~</code> for a home directory.
709
710
  # * ::extname: Returns the file extension for the given file path.
710
711
  # * ::fnmatch? (aliased as ::fnmatch): Returns whether the given file path
711
712
  # matches the given pattern.
@@ -847,7 +848,30 @@ class File < IO
847
848
  # * [Open Options](rdoc-ref:IO@Open+Options).
848
849
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
849
850
  #
850
- def initialize: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> void
851
+ def initialize: (
852
+ path | int file_name,
853
+ ?string | int mode,
854
+ ?int perm,
855
+ # open options
856
+ ?mode: Integer | String,
857
+ ?flags: Integer,
858
+ ?external_encoding: encoding,
859
+ ?internal_encoding: encoding,
860
+ ?encoding: encoding,
861
+ ?textmode: boolish,
862
+ ?binmode: boolish,
863
+ ?autoclose: boolish,
864
+ ?path: path,
865
+ # encoding options
866
+ ?invalid: :replace | nil,
867
+ ?undef: :replace | nil,
868
+ ?replace: String | nil,
869
+ ?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
870
+ ?xml: :text | :attr | nil,
871
+ ?cr_newline: bool,
872
+ ?crlf_newline: bool,
873
+ ?universal_newline: bool
874
+ ) -> void
851
875
 
852
876
  # <!--
853
877
  # rdoc-file=file.c
@@ -856,12 +880,12 @@ class File < IO
856
880
  # Converts a pathname to an absolute pathname. Relative paths are referenced
857
881
  # from the current working directory of the process unless *dir_string* is
858
882
  # given, in which case it will be used as the starting point. If the given
859
- # pathname starts with a ```~`'' it is NOT expanded, it is treated as a normal
860
- # directory name.
883
+ # pathname starts with a ``<code>~</code>'' it is NOT expanded, it is treated as
884
+ # a normal directory name.
861
885
  #
862
886
  # File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
863
887
  #
864
- def self.absolute_path: (string | _ToPath file_name, ?string | _ToPath dir_string) -> String
888
+ def self.absolute_path: (path file_name, ?path dir_string) -> String
865
889
 
866
890
  # <!--
867
891
  # rdoc-file=file.c
@@ -871,7 +895,7 @@ class File < IO
871
895
  #
872
896
  # File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
873
897
  #
874
- def self.absolute_path?: (string | _ToPath file_name) -> bool
898
+ def self.absolute_path?: (path file_name) -> bool
875
899
 
876
900
  # <!--
877
901
  # rdoc-file=file.c
@@ -883,7 +907,7 @@ class File < IO
883
907
  #
884
908
  # File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
885
909
  #
886
- def self.atime: (string | _ToPath | IO file_name) -> Time
910
+ def self.atime: (path | IO file_name) -> Time
887
911
 
888
912
  # <!--
889
913
  # rdoc-file=file.c
@@ -899,7 +923,7 @@ class File < IO
899
923
  # File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
900
924
  # File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby"
901
925
  #
902
- def self.basename: (string | _ToPath file_name, ?string suffix) -> String
926
+ def self.basename: (path file_name, ?string suffix) -> String
903
927
 
904
928
  # <!--
905
929
  # rdoc-file=file.c
@@ -913,7 +937,7 @@ class File < IO
913
937
  #
914
938
  # If the platform doesn't have birthtime, raises NotImplementedError.
915
939
  #
916
- def self.birthtime: (string | _ToPath | IO file_name) -> Time
940
+ def self.birthtime: (path | IO file_name) -> Time
917
941
 
918
942
  # <!--
919
943
  # rdoc-file=file.c
@@ -924,7 +948,7 @@ class File < IO
924
948
  # File.blockdev?('/dev/sda1') # => true
925
949
  # File.blockdev?(File.new('t.tmp')) # => false
926
950
  #
927
- def self.blockdev?: (string | _ToPath | IO file_name) -> bool
951
+ def self.blockdev?: (path | IO file_name) -> bool
928
952
 
929
953
  # <!--
930
954
  # rdoc-file=file.c
@@ -935,7 +959,7 @@ class File < IO
935
959
  # File.chardev?($stdin) # => true
936
960
  # File.chardev?('t.txt') # => false
937
961
  #
938
- def self.chardev?: (string | _ToPath | IO file_name) -> bool
962
+ def self.chardev?: (path | IO file_name) -> bool
939
963
 
940
964
  # <!--
941
965
  # rdoc-file=file.c
@@ -943,12 +967,12 @@ class File < IO
943
967
  # -->
944
968
  # Changes permission bits on the named file(s) to the bit pattern represented by
945
969
  # *mode_int*. Actual effects are operating system dependent (see the beginning
946
- # of this section). On Unix systems, see `chmod(2)` for details. Returns the
947
- # number of files processed.
970
+ # of this section). On Unix systems, see <code>chmod(2)</code> for details.
971
+ # Returns the number of files processed.
948
972
  #
949
973
  # File.chmod(0644, "testfile", "out") #=> 2
950
974
  #
951
- def self.chmod: (int mode, *string | _ToPath file_name) -> Integer
975
+ def self.chmod: (int mode, *path file_name) -> Integer
952
976
 
953
977
  # <!--
954
978
  # rdoc-file=file.c
@@ -962,7 +986,7 @@ class File < IO
962
986
  #
963
987
  # File.chown(nil, 100, "testfile")
964
988
  #
965
- def self.chown: (int? owner, int? group, *string | _ToPath file_name) -> Integer
989
+ def self.chown: (int? owner, int? group, *path file_name) -> Integer
966
990
 
967
991
  # <!--
968
992
  # rdoc-file=file.c
@@ -977,7 +1001,7 @@ class File < IO
977
1001
  #
978
1002
  # File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
979
1003
  #
980
- def self.ctime: (string | _ToPath | IO file_name) -> Time
1004
+ def self.ctime: (path | IO file_name) -> Time
981
1005
 
982
1006
  # <!--
983
1007
  # rdoc-file=file.c
@@ -986,9 +1010,9 @@ class File < IO
986
1010
  # -->
987
1011
  # Deletes the named files, returning the number of names passed as arguments.
988
1012
  # Raises an exception on any error. Since the underlying implementation relies
989
- # on the `unlink(2)` system call, the type of exception raised depends on its
990
- # error type (see https://linux.die.net/man/2/unlink) and has the form of e.g.
991
- # Errno::ENOENT.
1013
+ # on the <code>unlink(2)</code> system call, the type of exception raised
1014
+ # depends on its error type (see https://linux.die.net/man/2/unlink) and has the
1015
+ # form of e.g. Errno::ENOENT.
992
1016
  #
993
1017
  # See also Dir::rmdir.
994
1018
  #
@@ -1010,7 +1034,7 @@ class File < IO
1010
1034
  #
1011
1035
  # Argument `path` can be an IO object.
1012
1036
  #
1013
- def self.directory?: (string | _ToPath | IO path) -> bool
1037
+ def self.directory?: (path | IO path) -> bool
1014
1038
 
1015
1039
  # <!--
1016
1040
  # rdoc-file=file.c
@@ -1028,7 +1052,7 @@ class File < IO
1028
1052
  # File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby"
1029
1053
  # File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/"
1030
1054
  #
1031
- def self.dirname: (string | _ToPath file_name, ?Integer level) -> String
1055
+ def self.dirname: (path file_name, ?Integer level) -> String
1032
1056
 
1033
1057
  # <!--
1034
1058
  # rdoc-file=file.c
@@ -1054,7 +1078,7 @@ class File < IO
1054
1078
  # Note that some OS-level security features may cause this to return true even
1055
1079
  # though the file is not executable by the effective user/group.
1056
1080
  #
1057
- def self.executable?: (string | _ToPath file_name) -> bool
1081
+ def self.executable?: (path file_name) -> bool
1058
1082
 
1059
1083
  # <!--
1060
1084
  # rdoc-file=file.c
@@ -1070,7 +1094,7 @@ class File < IO
1070
1094
  # Note that some OS-level security features may cause this to return true even
1071
1095
  # though the file is not executable by the real user/group.
1072
1096
  #
1073
- def self.executable_real?: (string | _ToPath file_name) -> bool
1097
+ def self.executable_real?: (path file_name) -> bool
1074
1098
 
1075
1099
  # <!--
1076
1100
  # rdoc-file=file.c
@@ -1082,7 +1106,7 @@ class File < IO
1082
1106
  #
1083
1107
  # "file exists" means that stat() or fstat() system call is successful.
1084
1108
  #
1085
- def self.exist?: (string | _ToPath | IO file_name) -> bool
1109
+ def self.exist?: (path | IO file_name) -> bool
1086
1110
 
1087
1111
  # <!--
1088
1112
  # rdoc-file=file.c
@@ -1091,9 +1115,9 @@ class File < IO
1091
1115
  # Converts a pathname to an absolute pathname. Relative paths are referenced
1092
1116
  # from the current working directory of the process unless `dir_string` is
1093
1117
  # given, in which case it will be used as the starting point. The given pathname
1094
- # may start with a ```~`'', which expands to the process owner's home directory
1095
- # (the environment variable `HOME` must be set correctly). ```~`*user*'' expands
1096
- # to the named user's home directory.
1118
+ # may start with a ``<code>~</code>'', which expands to the process owner's home
1119
+ # directory (the environment variable `HOME` must be set correctly).
1120
+ # ``<code>~</code>*user*'' expands to the named user's home directory.
1097
1121
  #
1098
1122
  # File.expand_path("~oracle/bin") #=> "/home/oracle/bin"
1099
1123
  #
@@ -1107,9 +1131,9 @@ class File < IO
1107
1131
  # #=> ".../path/to/project/lib/mygem.rb"
1108
1132
  #
1109
1133
  # So first it resolves the parent of __FILE__, that is bin/, then go to the
1110
- # parent, the root of the project and appends `lib/mygem.rb`.
1134
+ # parent, the root of the project and appends <code>lib/mygem.rb</code>.
1111
1135
  #
1112
- def self.expand_path: (string | _ToPath file_name, ?string | _ToPath dir_string) -> String
1136
+ def self.expand_path: (path file_name, ?path dir_string) -> String
1113
1137
 
1114
1138
  # <!--
1115
1139
  # rdoc-file=file.c
@@ -1135,7 +1159,7 @@ class File < IO
1135
1159
  # File.extname(".profile") #=> ""
1136
1160
  # File.extname(".profile.sh") #=> ".sh"
1137
1161
  #
1138
- def self.extname: (string | _ToPath path) -> String
1162
+ def self.extname: (path path) -> String
1139
1163
 
1140
1164
  # <!--
1141
1165
  # rdoc-file=file.c
@@ -1148,7 +1172,7 @@ class File < IO
1148
1172
  # If the `file` argument is a symbolic link, it will resolve the symbolic link
1149
1173
  # and use the file referenced by the link.
1150
1174
  #
1151
- def self.file?: (string | _ToPath | IO file) -> bool
1175
+ def self.file?: (path | IO file) -> bool
1152
1176
 
1153
1177
  # <!--
1154
1178
  # rdoc-file=dir.rb
@@ -1159,48 +1183,48 @@ class File < IO
1159
1183
  # regular expression; instead it follows rules similar to shell filename
1160
1184
  # globbing. It may contain the following metacharacters:
1161
1185
  #
1162
- # `*`
1186
+ # <code>*</code>
1163
1187
  # : Matches any file. Can be restricted by other values in the glob.
1164
- # Equivalent to `/.*/x` in regexp.
1188
+ # Equivalent to <code>/.*/x</code> in regexp.
1165
1189
  #
1166
- # `*`
1190
+ # <code>*</code>
1167
1191
  # : Matches all regular files
1168
1192
  #
1169
- # `c*`
1193
+ # <code>c*</code>
1170
1194
  # : Matches all files beginning with `c`
1171
1195
  #
1172
- # `*c`
1196
+ # <code>*c</code>
1173
1197
  # : Matches all files ending with `c`
1174
1198
  #
1175
- # `*c*`
1199
+ # <code>*c*</code>
1176
1200
  # : Matches all files that have `c` in them (including at the beginning or
1177
1201
  # end).
1178
1202
  #
1179
1203
  #
1180
- # To match hidden files (that start with a `.`) set the File::FNM_DOTMATCH
1181
- # flag.
1204
+ # To match hidden files (that start with a <code>.</code>) set the
1205
+ # File::FNM_DOTMATCH flag.
1182
1206
  #
1183
1207
  #
1184
- # `**`
1208
+ # <code>**</code>
1185
1209
  # : Matches directories recursively or files expansively.
1186
1210
  #
1187
1211
  #
1188
- # `?`
1189
- # : Matches any one character. Equivalent to `/.{1}/` in regexp.
1212
+ # <code>?</code>
1213
+ # : Matches any one character. Equivalent to <code>/.{1}/</code> in regexp.
1190
1214
  #
1191
1215
  #
1192
- # `[set]`
1216
+ # <code>[set]</code>
1193
1217
  # : Matches any one character in `set`. Behaves exactly like character sets
1194
- # in Regexp, including set negation (`[^a-z]`).
1218
+ # in Regexp, including set negation (<code>[^a-z]</code>).
1195
1219
  #
1196
1220
  #
1197
- # `\`
1221
+ # <code>\</code>
1198
1222
  # : Escapes the next metacharacter.
1199
1223
  #
1200
1224
  #
1201
- # `{a,b}`
1225
+ # <code>{a,b}</code>
1202
1226
  # : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
1203
- # Behaves like a Regexp union (`(?:a|b)`).
1227
+ # Behaves like a Regexp union (<code>(?:a|b)</code>).
1204
1228
  #
1205
1229
  #
1206
1230
  # `flags` is a bitwise OR of the `FNM_XXX` constants. The same glob pattern and
@@ -1252,7 +1276,7 @@ class File < IO
1252
1276
  # File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
1253
1277
  # File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
1254
1278
  #
1255
- def self.fnmatch: (string pattern, string | _ToPath path, ?int flags) -> bool
1279
+ def self.fnmatch: (string pattern, path path, ?int flags) -> bool
1256
1280
 
1257
1281
  # <!--
1258
1282
  # rdoc-file=dir.rb
@@ -1273,7 +1297,7 @@ class File < IO
1273
1297
  # File.ftype("/dev/tty") #=> "characterSpecial"
1274
1298
  # File.ftype("/tmp/.X11-unix/X0") #=> "socket"
1275
1299
  #
1276
- def self.ftype: (string | _ToPath file_name) -> String
1300
+ def self.ftype: (path file_name) -> String
1277
1301
 
1278
1302
  # <!--
1279
1303
  # rdoc-file=file.c
@@ -1284,7 +1308,7 @@ class File < IO
1284
1308
  #
1285
1309
  # *file_name* can be an IO object.
1286
1310
  #
1287
- def self.grpowned?: (string | _ToPath | IO file_name) -> bool
1311
+ def self.grpowned?: (path | IO file_name) -> bool
1288
1312
 
1289
1313
  # <!--
1290
1314
  # rdoc-file=file.c
@@ -1304,13 +1328,13 @@ class File < IO
1304
1328
  # open("d", "w") {}
1305
1329
  # p File.identical?("a", "d") #=> false
1306
1330
  #
1307
- def self.identical?: (string | _ToPath | IO file_1, string | _ToPath | IO file_2) -> bool
1331
+ def self.identical?: (path | IO file_1, path | IO file_2) -> bool
1308
1332
 
1309
1333
  # <!--
1310
1334
  # rdoc-file=file.c
1311
1335
  # - File.join(string, ...) -> string
1312
1336
  # -->
1313
- # Returns a new string formed by joining the strings using `"/"`.
1337
+ # Returns a new string formed by joining the strings using <code>"/"</code>.
1314
1338
  #
1315
1339
  # File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
1316
1340
  #
@@ -1324,7 +1348,7 @@ class File < IO
1324
1348
  # change the permissions associated with the link, not the file referenced by
1325
1349
  # the link). Often not available.
1326
1350
  #
1327
- def self.lchmod: (int mode, *string | _ToPath file_name) -> Integer
1351
+ def self.lchmod: (int mode, *path file_name) -> Integer
1328
1352
 
1329
1353
  # <!--
1330
1354
  # rdoc-file=file.c
@@ -1334,7 +1358,7 @@ class File < IO
1334
1358
  # change the owner associated with the link, not the file referenced by the
1335
1359
  # link). Often not available. Returns number of files in the argument list.
1336
1360
  #
1337
- def self.lchown: (int? owner, int? group, *string | _ToPath file_name) -> Integer
1361
+ def self.lchown: (int? owner, int? group, *path file_name) -> Integer
1338
1362
 
1339
1363
  # <!--
1340
1364
  # rdoc-file=file.c
@@ -1347,7 +1371,7 @@ class File < IO
1347
1371
  # File.link("testfile", ".testfile") #=> 0
1348
1372
  # IO.readlines(".testfile")[0] #=> "This is line one\n"
1349
1373
  #
1350
- def self.link: (string | _ToPath old_name, string | _ToPath new_name) -> 0
1374
+ def self.link: (path old_name, path new_name) -> 0
1351
1375
 
1352
1376
  # <!--
1353
1377
  # rdoc-file=file.c
@@ -1360,7 +1384,7 @@ class File < IO
1360
1384
  # File.stat('symlink').size # => 47
1361
1385
  # File.lstat('symlink').size # => 5
1362
1386
  #
1363
- def self.lstat: (string | _ToPath file_name) -> File::Stat
1387
+ def self.lstat: (path file_name) -> File::Stat
1364
1388
 
1365
1389
  # <!--
1366
1390
  # rdoc-file=file.c
@@ -1371,7 +1395,7 @@ class File < IO
1371
1395
  # opposed to its referent; for the inverse behavior, see File.utime. Returns the
1372
1396
  # number of file names in the argument list.
1373
1397
  #
1374
- def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *string | _ToPath file_name) -> Integer
1398
+ def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
1375
1399
 
1376
1400
  # <!--
1377
1401
  # rdoc-file=file.c
@@ -1381,7 +1405,7 @@ class File < IO
1381
1405
  # FIFO's permissions. It is modified by the process's umask in the usual way:
1382
1406
  # the permissions of the created file are (mode & ~umask).
1383
1407
  #
1384
- def self.mkfifo: (string | _ToPath file_name, ?int mode) -> 0
1408
+ def self.mkfifo: (path file_name, ?int mode) -> 0
1385
1409
 
1386
1410
  # <!--
1387
1411
  # rdoc-file=file.c
@@ -1393,7 +1417,7 @@ class File < IO
1393
1417
  #
1394
1418
  # File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
1395
1419
  #
1396
- def self.mtime: (string | _ToPath | IO file_name) -> Time
1420
+ def self.mtime: (path | IO file_name) -> Time
1397
1421
 
1398
1422
  # <!--
1399
1423
  # rdoc-file=io.c
@@ -1407,19 +1431,65 @@ class File < IO
1407
1431
  # With a block given, calls the block with the File object and returns the
1408
1432
  # block's value.
1409
1433
  #
1410
- def self.open: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> instance
1411
- | [T] (string | _ToPath | int file_name, ?string | int mode, ?int perm) { (File) -> T } -> T
1434
+ def self.open: (
1435
+ path | int file_name,
1436
+ ?string | int mode,
1437
+ ?int perm,
1438
+ # open options
1439
+ ?mode: Integer | String,
1440
+ ?flags: Integer,
1441
+ ?external_encoding: encoding,
1442
+ ?internal_encoding: encoding,
1443
+ ?encoding: encoding,
1444
+ ?textmode: boolish,
1445
+ ?binmode: boolish,
1446
+ ?autoclose: boolish,
1447
+ ?path: path,
1448
+ # encoding options
1449
+ ?invalid: :replace | nil,
1450
+ ?undef: :replace | nil,
1451
+ ?replace: String | nil,
1452
+ ?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
1453
+ ?xml: :text | :attr | nil,
1454
+ ?cr_newline: bool,
1455
+ ?crlf_newline: bool,
1456
+ ?universal_newline: bool
1457
+ ) -> instance
1458
+ | [T] (
1459
+ path | int file_name,
1460
+ ?string | int mode,
1461
+ ?int perm,
1462
+ # open options
1463
+ ?mode: Integer | String,
1464
+ ?flags: Integer,
1465
+ ?external_encoding: encoding,
1466
+ ?internal_encoding: encoding,
1467
+ ?encoding: encoding,
1468
+ ?textmode: boolish,
1469
+ ?binmode: boolish,
1470
+ ?autoclose: boolish,
1471
+ ?path: path,
1472
+ # encoding options
1473
+ ?invalid: :replace | nil,
1474
+ ?undef: :replace | nil,
1475
+ ?replace: String | nil,
1476
+ ?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
1477
+ ?xml: :text | :attr | nil,
1478
+ ?cr_newline: bool,
1479
+ ?crlf_newline: bool,
1480
+ ?universal_newline: bool
1481
+ ) { (File) -> T } -> T
1412
1482
 
1413
1483
  # <!--
1414
1484
  # rdoc-file=file.c
1415
1485
  # - File.owned?(file_name) -> true or false
1416
1486
  # -->
1417
- # Returns `true` if the named file exists and the effective used id of the
1487
+ # Returns `true` if the named file exists and the effective user id of the
1418
1488
  # calling process is the owner of the file.
1419
1489
  #
1420
1490
  # *file_name* can be an IO object.
1421
1491
  #
1422
- def self.owned?: (string | _ToPath | IO file_name) -> bool
1492
+ def self.owned?: (path | IO file_name) -> bool
1423
1493
 
1424
1494
  # <!--
1425
1495
  # rdoc-file=file.c
@@ -1427,10 +1497,27 @@ class File < IO
1427
1497
  # -->
1428
1498
  # Returns the string representation of the path
1429
1499
  #
1430
- # File.path(File::NULL) #=> "/dev/null"
1431
- # File.path(Pathname.new("/tmp")) #=> "/tmp"
1500
+ # File.path(File::NULL) #=> "/dev/null"
1501
+ # File.path(Pathname.new("/tmp")) #=> "/tmp"
1502
+ #
1503
+ # If `path` is not a String:
1504
+ #
1505
+ # 1. If it has the `to_path` method, that method will be called to coerce to a
1506
+ # String.
1507
+ #
1508
+ # 2. Otherwise, or if the coerced result is not a String too, the standard
1509
+ # coersion using `to_str` method will take place on that object. (See also
1510
+ # String.try_convert)
1511
+ #
1512
+ # The coerced string must satisfy the following conditions:
1513
+ #
1514
+ # 1. It must be in an ASCII-compatible encoding; otherwise, an
1515
+ # Encoding::CompatibilityError is raised.
1432
1516
  #
1433
- def self.path: (string | _ToPath path) -> String
1517
+ # 2. It must not contain the NUL character (<code>\0</code>); otherwise, an
1518
+ # ArgumentError is raised.
1519
+ #
1520
+ def self.path: (path path) -> String
1434
1521
 
1435
1522
  # <!--
1436
1523
  # rdoc-file=file.c
@@ -1442,7 +1529,7 @@ class File < IO
1442
1529
  # File.pipe?('tmp/fifo') # => true
1443
1530
  # File.pipe?('t.txt') # => false
1444
1531
  #
1445
- def self.pipe?: (string | _ToPath | IO file_name) -> bool
1532
+ def self.pipe?: (path | IO file_name) -> bool
1446
1533
 
1447
1534
  # <!--
1448
1535
  # rdoc-file=file.c
@@ -1454,7 +1541,7 @@ class File < IO
1454
1541
  # Note that some OS-level security features may cause this to return true even
1455
1542
  # though the file is not readable by the effective user/group.
1456
1543
  #
1457
- def self.readable?: (string | _ToPath file_name) -> bool
1544
+ def self.readable?: (path file_name) -> bool
1458
1545
 
1459
1546
  # <!--
1460
1547
  # rdoc-file=file.c
@@ -1466,7 +1553,7 @@ class File < IO
1466
1553
  # Note that some OS-level security features may cause this to return true even
1467
1554
  # though the file is not readable by the real user/group.
1468
1555
  #
1469
- def self.readable_real?: (string | _ToPath file_name) -> bool
1556
+ def self.readable_real?: (path file_name) -> bool
1470
1557
 
1471
1558
  # <!--
1472
1559
  # rdoc-file=file.c
@@ -1478,7 +1565,7 @@ class File < IO
1478
1565
  # File.symlink("testfile", "link2test") #=> 0
1479
1566
  # File.readlink("link2test") #=> "testfile"
1480
1567
  #
1481
- def self.readlink: (string | _ToPath link_name) -> String
1568
+ def self.readlink: (path link_name) -> String
1482
1569
 
1483
1570
  # <!--
1484
1571
  # rdoc-file=file.c
@@ -1492,7 +1579,7 @@ class File < IO
1492
1579
  #
1493
1580
  # The last component of the real pathname can be nonexistent.
1494
1581
  #
1495
- def self.realdirpath: (string | _ToPath pathname, ?string | _ToPath dir_string) -> String
1582
+ def self.realdirpath: (path pathname, ?path dir_string) -> String
1496
1583
 
1497
1584
  # <!--
1498
1585
  # rdoc-file=file.c
@@ -1506,7 +1593,7 @@ class File < IO
1506
1593
  #
1507
1594
  # All components of the pathname must exist when this method is called.
1508
1595
  #
1509
- def self.realpath: (string | _ToPath pathname, ?string | _ToPath dir_string) -> String
1596
+ def self.realpath: (path pathname, ?path dir_string) -> String
1510
1597
 
1511
1598
  # <!--
1512
1599
  # rdoc-file=file.c
@@ -1517,7 +1604,7 @@ class File < IO
1517
1604
  #
1518
1605
  # File.rename("afile", "afile.bak") #=> 0
1519
1606
  #
1520
- def self.rename: (string | _ToPath old_name, string | _ToPath new_name) -> 0
1607
+ def self.rename: (path old_name, path new_name) -> 0
1521
1608
 
1522
1609
  # <!--
1523
1610
  # rdoc-file=file.c
@@ -1527,7 +1614,7 @@ class File < IO
1527
1614
  #
1528
1615
  # *file_name* can be an IO object.
1529
1616
  #
1530
- def self.setgid?: (string | _ToPath | IO file_name) -> bool
1617
+ def self.setgid?: (path | IO file_name) -> bool
1531
1618
 
1532
1619
  # <!--
1533
1620
  # rdoc-file=file.c
@@ -1537,7 +1624,7 @@ class File < IO
1537
1624
  #
1538
1625
  # *file_name* can be an IO object.
1539
1626
  #
1540
- def self.setuid?: (string | _ToPath | IO file_name) -> bool
1627
+ def self.setuid?: (path | IO file_name) -> bool
1541
1628
 
1542
1629
  # <!--
1543
1630
  # rdoc-file=file.c
@@ -1547,7 +1634,7 @@ class File < IO
1547
1634
  #
1548
1635
  # *file_name* can be an IO object.
1549
1636
  #
1550
- def self.size: (string | _ToPath | IO file_name) -> Integer
1637
+ def self.size: (path | IO file_name) -> Integer
1551
1638
 
1552
1639
  # <!--
1553
1640
  # rdoc-file=file.c
@@ -1558,7 +1645,7 @@ class File < IO
1558
1645
  #
1559
1646
  # *file_name* can be an IO object.
1560
1647
  #
1561
- def self.size?: (string | _ToPath | IO file_name) -> Integer?
1648
+ def self.size?: (path | IO file_name) -> Integer?
1562
1649
 
1563
1650
  # <!--
1564
1651
  # rdoc-file=file.c
@@ -1570,7 +1657,7 @@ class File < IO
1570
1657
  # File.socket?(Socket.new(:INET, :STREAM)) # => true
1571
1658
  # File.socket?(File.new('t.txt')) # => false
1572
1659
  #
1573
- def self.socket?: (string | _ToPath | IO file_name) -> bool
1660
+ def self.socket?: (path | IO file_name) -> bool
1574
1661
 
1575
1662
  # <!--
1576
1663
  # rdoc-file=file.c
@@ -1581,7 +1668,7 @@ class File < IO
1581
1668
  #
1582
1669
  # File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
1583
1670
  #
1584
- def self.split: (string | _ToPath file_name) -> [ String, String ]
1671
+ def self.split: (path file_name) -> [ String, String ]
1585
1672
 
1586
1673
  # <!--
1587
1674
  # rdoc-file=file.c
@@ -1591,7 +1678,7 @@ class File < IO
1591
1678
  #
1592
1679
  # File.stat('t.txt').class # => File::Stat
1593
1680
  #
1594
- def self.stat: (string | _ToPath file_name) -> File::Stat
1681
+ def self.stat: (path file_name) -> File::Stat
1595
1682
 
1596
1683
  # <!--
1597
1684
  # rdoc-file=file.c
@@ -1601,7 +1688,7 @@ class File < IO
1601
1688
  #
1602
1689
  # *file_name* can be an IO object.
1603
1690
  #
1604
- def self.sticky?: (string | _ToPath | IO file_name) -> bool
1691
+ def self.sticky?: (path | IO file_name) -> bool
1605
1692
 
1606
1693
  # <!--
1607
1694
  # rdoc-file=file.c
@@ -1613,7 +1700,7 @@ class File < IO
1613
1700
  #
1614
1701
  # File.symlink("testfile", "link2test") #=> 0
1615
1702
  #
1616
- def self.symlink: (string | _ToPath old_name, string | _ToPath new_name) -> 0
1703
+ def self.symlink: (path old_name, path new_name) -> 0
1617
1704
 
1618
1705
  # <!--
1619
1706
  # rdoc-file=file.c
@@ -1625,7 +1712,7 @@ class File < IO
1625
1712
  # File.symlink?('symlink') # => true
1626
1713
  # File.symlink?('t.txt') # => false
1627
1714
  #
1628
- def self.symlink?: (string | _ToPath file_name) -> bool
1715
+ def self.symlink?: (path file_name) -> bool
1629
1716
 
1630
1717
  # <!--
1631
1718
  # rdoc-file=file.c
@@ -1640,7 +1727,7 @@ class File < IO
1640
1727
  # File.truncate("out", 5) #=> 0
1641
1728
  # File.size("out") #=> 5
1642
1729
  #
1643
- def self.truncate: (string | _ToPath file_name, int length) -> 0
1730
+ def self.truncate: (path file_name, int length) -> 0
1644
1731
 
1645
1732
  # <!--
1646
1733
  # rdoc-file=file.c
@@ -1664,13 +1751,13 @@ class File < IO
1664
1751
  # -->
1665
1752
  # Deletes the named files, returning the number of names passed as arguments.
1666
1753
  # Raises an exception on any error. Since the underlying implementation relies
1667
- # on the `unlink(2)` system call, the type of exception raised depends on its
1668
- # error type (see https://linux.die.net/man/2/unlink) and has the form of e.g.
1669
- # Errno::ENOENT.
1754
+ # on the <code>unlink(2)</code> system call, the type of exception raised
1755
+ # depends on its error type (see https://linux.die.net/man/2/unlink) and has the
1756
+ # form of e.g. Errno::ENOENT.
1670
1757
  #
1671
1758
  # See also Dir::rmdir.
1672
1759
  #
1673
- def self.unlink: (*string | _ToPath file_name) -> Integer
1760
+ def self.unlink: (*path file_name) -> Integer
1674
1761
 
1675
1762
  # <!--
1676
1763
  # rdoc-file=file.c
@@ -1681,7 +1768,7 @@ class File < IO
1681
1768
  # than the link itself; for the inverse behavior see File.lutime. Returns the
1682
1769
  # number of file names in the argument list.
1683
1770
  #
1684
- def self.utime: (Time | Numeric atime, Time | Numeric mtime, *string | _ToPath file_name) -> Integer
1771
+ def self.utime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
1685
1772
 
1686
1773
  # <!--
1687
1774
  # rdoc-file=file.c
@@ -1689,7 +1776,7 @@ class File < IO
1689
1776
  # -->
1690
1777
  # If *file_name* is readable by others, returns an integer representing the file
1691
1778
  # permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
1692
- # bits is platform dependent; on Unix systems, see `stat(2)`.
1779
+ # bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
1693
1780
  #
1694
1781
  # *file_name* can be an IO object.
1695
1782
  #
@@ -1697,7 +1784,7 @@ class File < IO
1697
1784
  # m = File.world_readable?("/etc/passwd")
1698
1785
  # sprintf("%o", m) #=> "644"
1699
1786
  #
1700
- def self.world_readable?: (string | _ToPath | IO file_name) -> Integer?
1787
+ def self.world_readable?: (path | IO file_name) -> Integer?
1701
1788
 
1702
1789
  # <!--
1703
1790
  # rdoc-file=file.c
@@ -1705,7 +1792,7 @@ class File < IO
1705
1792
  # -->
1706
1793
  # If *file_name* is writable by others, returns an integer representing the file
1707
1794
  # permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
1708
- # bits is platform dependent; on Unix systems, see `stat(2)`.
1795
+ # bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
1709
1796
  #
1710
1797
  # *file_name* can be an IO object.
1711
1798
  #
@@ -1713,7 +1800,7 @@ class File < IO
1713
1800
  # m = File.world_writable?("/tmp")
1714
1801
  # sprintf("%o", m) #=> "777"
1715
1802
  #
1716
- def self.world_writable?: (string | _ToPath | IO file_name) -> Integer?
1803
+ def self.world_writable?: (path | IO file_name) -> Integer?
1717
1804
 
1718
1805
  # <!--
1719
1806
  # rdoc-file=file.c
@@ -1725,7 +1812,7 @@ class File < IO
1725
1812
  # Note that some OS-level security features may cause this to return true even
1726
1813
  # though the file is not writable by the effective user/group.
1727
1814
  #
1728
- def self.writable?: (string | _ToPath file_name) -> bool
1815
+ def self.writable?: (path file_name) -> bool
1729
1816
 
1730
1817
  # <!--
1731
1818
  # rdoc-file=file.c
@@ -1737,7 +1824,7 @@ class File < IO
1737
1824
  # Note that some OS-level security features may cause this to return true even
1738
1825
  # though the file is not writable by the real user/group.
1739
1826
  #
1740
- def self.writable_real?: (string | _ToPath file_name) -> bool
1827
+ def self.writable_real?: (path file_name) -> bool
1741
1828
 
1742
1829
  # <!--
1743
1830
  # rdoc-file=file.c
@@ -1747,7 +1834,7 @@ class File < IO
1747
1834
  #
1748
1835
  # *file_name* can be an IO object.
1749
1836
  #
1750
- def self.zero?: (string | _ToPath | IO file_name) -> bool
1837
+ def self.zero?: (path | IO file_name) -> bool
1751
1838
 
1752
1839
  # <!--
1753
1840
  # rdoc-file=file.c
@@ -1778,7 +1865,8 @@ class File < IO
1778
1865
  # -->
1779
1866
  # Changes permission bits on *file* to the bit pattern represented by
1780
1867
  # *mode_int*. Actual effects are platform dependent; on Unix systems, see
1781
- # `chmod(2)` for details. Follows symbolic links. Also see File#lchmod.
1868
+ # <code>chmod(2)</code> for details. Follows symbolic links. Also see
1869
+ # File#lchmod.
1782
1870
  #
1783
1871
  # f = File.new("out", "w");
1784
1872
  # f.chmod(0644) #=> 0
@@ -1816,18 +1904,18 @@ class File < IO
1816
1904
  # rdoc-file=file.c
1817
1905
  # - flock(locking_constant) -> 0 or false
1818
1906
  # -->
1819
- # Locks or unlocks file `self` according to the given `locking_constant`,
1907
+ # Locks or unlocks file +self+ according to the given `locking_constant`,
1820
1908
  # a bitwise OR of the values in the table below.
1821
1909
  # Not available on all platforms.
1822
- # Returns `false` if `File::LOCK_NB` is specified and the operation would have
1823
- # blocked;
1910
+ # Returns `false` if <code>File::LOCK_NB</code> is specified and the operation
1911
+ # would have blocked;
1824
1912
  # otherwise returns `0`.
1825
- # Constant | Lock | Effect
1826
- # ---------------|------------|--------------------------------------------------------------------------------------------------------------
1827
- # +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
1828
- # +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <tt>|</tt>.
1829
- # +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
1830
- # +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
1913
+ # Constant | Lock | Effect
1914
+ # ---------------|------------|------------------------------------------------------------------------------------------------------------------
1915
+ # +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
1916
+ # +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <code>|</code>.
1917
+ # +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
1918
+ # +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
1831
1919
  # Example:
1832
1920
  # # Update a counter using an exclusive lock.
1833
1921
  # # Don't use File::WRONLY because it truncates the file.
@@ -1953,7 +2041,7 @@ File::SEPARATOR: String
1953
2041
  File::Separator: String
1954
2042
 
1955
2043
  # <!-- rdoc-file=file.c -->
1956
- # Module `File::Constants` defines file-related constants.
2044
+ # Module <code>File::Constants</code> defines file-related constants.
1957
2045
  #
1958
2046
  # There are two families of constants here:
1959
2047
  #
@@ -2217,14 +2305,14 @@ File::Separator: String
2217
2305
  #
2218
2306
  # #### File::FNM_DOTMATCH
2219
2307
  #
2220
- # Flag File::FNM_DOTMATCH makes the `'*'` pattern match a filename starting with
2221
- # `'.'`.
2308
+ # Flag File::FNM_DOTMATCH makes the <code>'*'</code> pattern match a filename
2309
+ # starting with <code>'.'</code>.
2222
2310
  #
2223
2311
  # #### File::FNM_EXTGLOB
2224
2312
  #
2225
- # Flag File::FNM_EXTGLOB enables pattern `'{*a*,*b*}'`, which matches pattern
2226
- # '*a*' and pattern '*b*'; behaves like a [regexp union](rdoc-ref:Regexp.union)
2227
- # (e.g., `'(?:*a*|*b*)'`):
2313
+ # Flag File::FNM_EXTGLOB enables pattern <code>'{_a_,_b_}'</code>, which matches
2314
+ # pattern '*a*' and pattern '*b*'; behaves like a [regexp
2315
+ # union](rdoc-ref:Regexp.union) (e.g., <code>'(?:_a_|_b_)'</code>):
2228
2316
  #
2229
2317
  # pattern = '{LEGAL,BSDL}'
2230
2318
  # Dir.glob(pattern) # => ["LEGAL", "BSDL"]
@@ -2233,12 +2321,13 @@ File::Separator: String
2233
2321
  #
2234
2322
  # #### File::FNM_NOESCAPE
2235
2323
  #
2236
- # Flag File::FNM_NOESCAPE disables `'\'` escaping.
2324
+ # Flag File::FNM_NOESCAPE disables <code>'\'</code> escaping.
2237
2325
  #
2238
2326
  # #### File::FNM_PATHNAME
2239
2327
  #
2240
- # Flag File::FNM_PATHNAME specifies that patterns `'*'` and `'?'` do not match
2241
- # the directory separator (the value of constant File::SEPARATOR).
2328
+ # Flag File::FNM_PATHNAME specifies that patterns <code>'*'</code> and
2329
+ # <code>'?'</code> do not match the directory separator (the value of constant
2330
+ # File::SEPARATOR).
2242
2331
  #
2243
2332
  # #### File::FNM_SHORTNAME
2244
2333
  #
@@ -2257,8 +2346,8 @@ File::Separator: String
2257
2346
  #
2258
2347
  # Flag File::NULL contains the string value of the null device:
2259
2348
  #
2260
- # * On a Unix-like OS, `'/dev/null'`.
2261
- # * On Windows, `'NUL'`.
2349
+ # * On a Unix-like OS, <code>'/dev/null'</code>.
2350
+ # * On Windows, <code>'NUL'</code>.
2262
2351
  #
2263
2352
  module File::Constants
2264
2353
  end
@@ -2429,10 +2518,8 @@ class File::Stat < Object
2429
2518
 
2430
2519
  # <!--
2431
2520
  # rdoc-file=file.c
2432
- # - new(p1)
2521
+ # - File::Stat.new(file_name) -> stat
2433
2522
  # -->
2434
- # File::Stat.new(file_name) -> stat
2435
- #
2436
2523
  # Create a File::Stat object for the given file name (raising an exception if
2437
2524
  # the file doesn't exist).
2438
2525
  #
@@ -2440,16 +2527,31 @@ class File::Stat < Object
2440
2527
 
2441
2528
  # <!--
2442
2529
  # rdoc-file=file.c
2443
- # - stat <=> other_stat -> -1, 0, 1, nil
2530
+ # - self <=> other -> -1, 0, 1, or nil
2444
2531
  # -->
2445
- # Compares File::Stat objects by comparing their respective modification times.
2532
+ # Compares `self` and `other`, by comparing their modification times; that is,
2533
+ # by comparing <code>self.mtime</code> and <code>other.mtime</code>.
2534
+ #
2535
+ # Returns:
2536
+ #
2537
+ # * <code>-1</code>, if <code>self.mtime</code> is earlier.
2538
+ # * `0`, if the two values are equal.
2539
+ # * `1`, if <code>self.mtime</code> is later.
2540
+ # * `nil`, if `other` is not a File::Stat object.
2541
+ #
2542
+ # Examples:
2446
2543
  #
2447
- # `nil` is returned if `other_stat` is not a File::Stat object
2544
+ # stat0 = File.stat('README.md')
2545
+ # stat1 = File.stat('NEWS.md')
2546
+ # stat0.mtime # => 2025-12-20 15:33:05.6972341 -0600
2547
+ # stat1.mtime # => 2025-12-20 16:02:08.2672945 -0600
2548
+ # stat0 <=> stat1 # => -1
2549
+ # stat0 <=> stat0.dup # => 0
2550
+ # stat1 <=> stat0 # => 1
2551
+ # stat0 <=> :foo # => nil
2448
2552
  #
2449
- # f1 = File.new("f1", "w")
2450
- # sleep 1
2451
- # f2 = File.new("f2", "w")
2452
- # f1.stat <=> f2.stat #=> -1
2553
+ # Class File::Stat includes module Comparable, each of whose methods uses
2554
+ # File::Stat#<=> for comparison.
2453
2555
  #
2454
2556
  def <=>: (File::Stat other) -> Integer
2455
2557
  | (untyped) -> nil
@@ -2558,7 +2660,7 @@ class File::Stat < Object
2558
2660
  # rdoc-file=file.c
2559
2661
  # - stat.dev_major -> integer
2560
2662
  # -->
2561
- # Returns the major part of `File_Stat#dev` or `nil`.
2663
+ # Returns the major part of <code>File_Stat#dev</code> or `nil`.
2562
2664
  #
2563
2665
  # File.stat("/dev/fd1").dev_major #=> 2
2564
2666
  # File.stat("/dev/tty").dev_major #=> 5
@@ -2569,7 +2671,7 @@ class File::Stat < Object
2569
2671
  # rdoc-file=file.c
2570
2672
  # - stat.dev_minor -> integer
2571
2673
  # -->
2572
- # Returns the minor part of `File_Stat#dev` or `nil`.
2674
+ # Returns the minor part of <code>File_Stat#dev</code> or `nil`.
2573
2675
  #
2574
2676
  # File.stat("/dev/fd1").dev_minor #=> 1
2575
2677
  # File.stat("/dev/tty").dev_minor #=> 0
@@ -2603,7 +2705,8 @@ class File::Stat < Object
2603
2705
  # rdoc-file=file.c
2604
2706
  # - stat.executable_real? -> true or false
2605
2707
  # -->
2606
- # Same as `executable?`, but tests using the real owner of the process.
2708
+ # Same as <code>executable?</code>, but tests using the real owner of the
2709
+ # process.
2607
2710
  #
2608
2711
  def executable_real?: () -> bool
2609
2712
 
@@ -2683,7 +2786,7 @@ class File::Stat < Object
2683
2786
  # - stat.mode -> integer
2684
2787
  # -->
2685
2788
  # Returns an integer representing the permission bits of *stat*. The meaning of
2686
- # the bits is platform dependent; on Unix systems, see `stat(2)`.
2789
+ # the bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
2687
2790
  #
2688
2791
  # File.chmod(0644, "testfile") #=> 1
2689
2792
  # s = File.stat("testfile")
@@ -2750,7 +2853,7 @@ class File::Stat < Object
2750
2853
  # rdoc-file=file.c
2751
2854
  # - stat.rdev_major -> integer
2752
2855
  # -->
2753
- # Returns the major part of `File_Stat#rdev` or `nil`.
2856
+ # Returns the major part of <code>File_Stat#rdev</code> or `nil`.
2754
2857
  #
2755
2858
  # File.stat("/dev/fd1").rdev_major #=> 2
2756
2859
  # File.stat("/dev/tty").rdev_major #=> 5
@@ -2761,7 +2864,7 @@ class File::Stat < Object
2761
2864
  # rdoc-file=file.c
2762
2865
  # - stat.rdev_minor -> integer
2763
2866
  # -->
2764
- # Returns the minor part of `File_Stat#rdev` or `nil`.
2867
+ # Returns the minor part of <code>File_Stat#rdev</code> or `nil`.
2765
2868
  #
2766
2869
  # File.stat("/dev/fd1").rdev_minor #=> 1
2767
2870
  # File.stat("/dev/tty").rdev_minor #=> 0
@@ -2884,7 +2987,7 @@ class File::Stat < Object
2884
2987
  # -->
2885
2988
  # If *stat* is readable by others, returns an integer representing the file
2886
2989
  # permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
2887
- # platform dependent; on Unix systems, see `stat(2)`.
2990
+ # platform dependent; on Unix systems, see <code>stat(2)</code>.
2888
2991
  #
2889
2992
  # m = File.stat("/etc/passwd").world_readable? #=> 420
2890
2993
  # sprintf("%o", m) #=> "644"
@@ -2897,7 +3000,7 @@ class File::Stat < Object
2897
3000
  # -->
2898
3001
  # If *stat* is writable by others, returns an integer representing the file
2899
3002
  # permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
2900
- # platform dependent; on Unix systems, see `stat(2)`.
3003
+ # platform dependent; on Unix systems, see <code>stat(2)</code>.
2901
3004
  #
2902
3005
  # m = File.stat("/tmp").world_writable? #=> 511
2903
3006
  # sprintf("%o", m) #=> "777"