rbs 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -0
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +6 -1
  5. data/core/array.rbs +2866 -1086
  6. data/core/basic_object.rbs +150 -30
  7. data/core/binding.rbs +33 -0
  8. data/core/builtin.rbs +4 -4
  9. data/core/class.rbs +43 -5
  10. data/core/comparable.rbs +57 -0
  11. data/core/complex.rbs +170 -4
  12. data/core/constants.rbs +51 -0
  13. data/core/deprecated.rbs +7 -0
  14. data/core/dir.rbs +305 -20
  15. data/core/encoding.rbs +472 -77
  16. data/core/enumerable.rbs +2173 -234
  17. data/core/enumerator.rbs +448 -182
  18. data/core/env.rbs +448 -1
  19. data/core/errno.rbs +1 -10
  20. data/core/errors.rbs +152 -2
  21. data/core/exception.rbs +201 -127
  22. data/core/false_class.rbs +27 -0
  23. data/core/fiber.rbs +118 -37
  24. data/core/fiber_error.rbs +8 -9
  25. data/core/file.rbs +1059 -139
  26. data/core/file_test.rbs +287 -32
  27. data/core/float.rbs +776 -300
  28. data/core/gc.rbs +185 -34
  29. data/core/global_variables.rbs +5 -1
  30. data/core/hash.rbs +1582 -649
  31. data/core/integer.rbs +974 -204
  32. data/core/io/buffer.rbs +710 -0
  33. data/core/io/wait.rbs +29 -8
  34. data/core/io.rbs +2438 -417
  35. data/core/kernel.rbs +2315 -316
  36. data/core/marshal.rbs +37 -2
  37. data/core/match_data.rbs +123 -6
  38. data/core/math.rbs +126 -6
  39. data/core/method.rbs +226 -102
  40. data/core/module.rbs +421 -45
  41. data/core/nil_class.rbs +64 -0
  42. data/core/numeric.rbs +620 -142
  43. data/core/object.rbs +453 -81
  44. data/core/object_space.rbs +92 -2
  45. data/core/proc.rbs +482 -285
  46. data/core/process.rbs +443 -34
  47. data/core/ractor.rbs +232 -9
  48. data/core/random.rbs +151 -52
  49. data/core/range.rbs +885 -160
  50. data/core/rational.rbs +122 -6
  51. data/core/rb_config.rbs +14 -4
  52. data/core/refinement.rbs +44 -0
  53. data/core/regexp.rbs +156 -14
  54. data/core/ruby_vm.rbs +42 -3
  55. data/core/signal.rbs +78 -39
  56. data/core/string.rbs +2123 -567
  57. data/core/string_io.rbs +204 -0
  58. data/core/struct.rbs +283 -28
  59. data/core/symbol.rbs +304 -30
  60. data/core/thread.rbs +1288 -688
  61. data/core/thread_group.rbs +66 -10
  62. data/core/time.rbs +643 -217
  63. data/core/trace_point.rbs +100 -12
  64. data/core/true_class.rbs +24 -0
  65. data/core/unbound_method.rbs +73 -7
  66. data/core/warning.rbs +37 -12
  67. data/docs/CONTRIBUTING.md +40 -34
  68. data/docs/stdlib.md +3 -102
  69. data/lib/rbs/annotate/annotations.rb +197 -0
  70. data/lib/rbs/annotate/formatter.rb +80 -0
  71. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  72. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  73. data/lib/rbs/annotate.rb +6 -0
  74. data/lib/rbs/cli.rb +45 -1
  75. data/lib/rbs/definition_builder.rb +5 -1
  76. data/lib/rbs/location_aux.rb +12 -0
  77. data/lib/rbs/prototype/rb.rb +12 -0
  78. data/lib/rbs/version.rb +1 -1
  79. data/sig/annotate/annotations.rbs +102 -0
  80. data/sig/annotate/formatter.rbs +24 -0
  81. data/sig/annotate/rdoc_annotater.rbs +82 -0
  82. data/sig/annotate/rdoc_source.rbs +30 -0
  83. data/sig/cli.rbs +2 -0
  84. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  85. data/sig/location.rbs +6 -0
  86. data/sig/method_types.rbs +5 -1
  87. data/sig/polyfill.rbs +78 -0
  88. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  89. data/stdlib/abbrev/0/array.rbs +26 -0
  90. data/stdlib/base64/0/base64.rbs +31 -0
  91. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  92. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  93. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  94. data/stdlib/cgi/0/core.rbs +59 -0
  95. data/stdlib/coverage/0/coverage.rbs +164 -2
  96. data/stdlib/csv/0/csv.rbs +2862 -398
  97. data/stdlib/date/0/date.rbs +483 -25
  98. data/stdlib/date/0/date_time.rbs +187 -12
  99. data/stdlib/dbm/0/dbm.rbs +152 -17
  100. data/stdlib/digest/0/digest.rbs +146 -0
  101. data/stdlib/erb/0/erb.rbs +65 -245
  102. data/stdlib/fiber/0/fiber.rbs +73 -91
  103. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  104. data/stdlib/find/0/find.rbs +9 -0
  105. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  106. data/stdlib/io-console/0/io-console.rbs +227 -15
  107. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  108. data/stdlib/json/0/json.rbs +1146 -144
  109. data/stdlib/logger/0/formatter.rbs +24 -0
  110. data/stdlib/logger/0/log_device.rbs +64 -0
  111. data/stdlib/logger/0/logger.rbs +165 -13
  112. data/stdlib/logger/0/period.rbs +10 -0
  113. data/stdlib/logger/0/severity.rbs +26 -0
  114. data/stdlib/monitor/0/monitor.rbs +163 -0
  115. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  116. data/stdlib/net-http/0/net-http.rbs +1492 -683
  117. data/stdlib/nkf/0/nkf.rbs +372 -0
  118. data/stdlib/objspace/0/objspace.rbs +149 -90
  119. data/stdlib/openssl/0/openssl.rbs +8108 -71
  120. data/stdlib/optparse/0/optparse.rbs +487 -19
  121. data/stdlib/pathname/0/pathname.rbs +425 -124
  122. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  123. data/stdlib/prime/0/integer-extension.rbs +20 -2
  124. data/stdlib/prime/0/prime.rbs +88 -21
  125. data/stdlib/pstore/0/pstore.rbs +102 -0
  126. data/stdlib/pty/0/pty.rbs +64 -14
  127. data/stdlib/resolv/0/resolv.rbs +420 -31
  128. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  129. data/stdlib/rubygems/0/config_file.rbs +33 -1
  130. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  131. data/stdlib/rubygems/0/installer.rbs +13 -1
  132. data/stdlib/rubygems/0/path_support.rbs +4 -1
  133. data/stdlib/rubygems/0/platform.rbs +5 -1
  134. data/stdlib/rubygems/0/request_set.rbs +44 -2
  135. data/stdlib/rubygems/0/requirement.rbs +65 -2
  136. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  137. data/stdlib/rubygems/0/source_list.rbs +13 -0
  138. data/stdlib/rubygems/0/specification.rbs +21 -1
  139. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  140. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  141. data/stdlib/rubygems/0/version.rbs +60 -157
  142. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  143. data/stdlib/set/0/set.rbs +420 -106
  144. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  145. data/stdlib/singleton/0/singleton.rbs +20 -0
  146. data/stdlib/socket/0/addrinfo.rbs +210 -9
  147. data/stdlib/socket/0/basic_socket.rbs +103 -11
  148. data/stdlib/socket/0/ip_socket.rbs +31 -9
  149. data/stdlib/socket/0/socket.rbs +586 -38
  150. data/stdlib/socket/0/tcp_server.rbs +22 -2
  151. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  152. data/stdlib/socket/0/udp_socket.rbs +25 -2
  153. data/stdlib/socket/0/unix_server.rbs +22 -2
  154. data/stdlib/socket/0/unix_socket.rbs +45 -5
  155. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  156. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  157. data/stdlib/time/0/time.rbs +208 -116
  158. data/stdlib/timeout/0/timeout.rbs +10 -0
  159. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  160. data/stdlib/tsort/0/cyclic.rbs +1 -0
  161. data/stdlib/tsort/0/interfaces.rbs +1 -0
  162. data/stdlib/tsort/0/tsort.rbs +42 -0
  163. data/stdlib/uri/0/common.rbs +57 -8
  164. data/stdlib/uri/0/file.rbs +55 -109
  165. data/stdlib/uri/0/ftp.rbs +6 -3
  166. data/stdlib/uri/0/generic.rbs +556 -327
  167. data/stdlib/uri/0/http.rbs +26 -115
  168. data/stdlib/uri/0/https.rbs +8 -102
  169. data/stdlib/uri/0/ldap.rbs +143 -137
  170. data/stdlib/uri/0/ldaps.rbs +8 -102
  171. data/stdlib/uri/0/mailto.rbs +3 -0
  172. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  173. data/stdlib/uri/0/ws.rbs +6 -3
  174. data/stdlib/uri/0/wss.rbs +5 -3
  175. data/stdlib/yaml/0/dbm.rbs +151 -87
  176. data/stdlib/yaml/0/store.rbs +6 -0
  177. data/stdlib/zlib/0/zlib.rbs +90 -31
  178. metadata +17 -5
  179. data/lib/rbs/location.rb +0 -221
data/core/dir.rbs CHANGED
@@ -1,3 +1,4 @@
1
+ # <!-- rdoc-file=dir.rb -->
1
2
  # Objects of class Dir are directory streams representing directories in the
2
3
  # underlying file system. They provide a variety of ways to list directories and
3
4
  # their contents. See also File.
@@ -6,9 +7,148 @@
6
7
  # (`config.h` and `main.rb`), the parent directory (`..`), and the directory
7
8
  # itself (`.`).
8
9
  #
10
+ # ## What's Here
11
+ #
12
+ # First, what's elsewhere. Class Dir:
13
+ #
14
+ # * Inherits from [class
15
+ # Object](Object.html#class-Object-label-What-27s+Here).
16
+ # * Includes [module
17
+ # Enumerable](Enumerable.html#module-Enumerable-label-What-27s+Here), which
18
+ # provides dozens of additional methods.
19
+ #
20
+ #
21
+ # Here, class Dir provides methods that are useful for:
22
+ #
23
+ # * [Reading](#class-Dir-label-Reading)
24
+ # * [Setting](#class-Dir-label-Setting)
25
+ # * [Querying](#class-Dir-label-Querying)
26
+ # * [Iterating](#class-Dir-label-Iterating)
27
+ # * [Other](#class-Dir-label-Other)
28
+ #
29
+ #
30
+ # ### Reading
31
+ #
32
+ # #close
33
+ # : Closes the directory stream for `self`.
34
+ #
35
+ # #pos=
36
+ # : Sets the position in the directory stream for `self`.
37
+ #
38
+ # #read
39
+ # : Reads and returns the next entry in the directory stream for `self`.
40
+ #
41
+ # #rewind
42
+ # : Sets the position in the directory stream for `self` to the first
43
+ # entry.
44
+ #
45
+ # #seek
46
+ # : Sets the position in the directory stream for `self` the entry at the
47
+ # given offset.
48
+ #
49
+ #
50
+ #
51
+ # ### Setting
52
+ #
53
+ # ::chdir
54
+ # : Changes the working directory of the current process to the given
55
+ # directory.
56
+ #
57
+ # ::chroot
58
+ # : Changes the file-system root for the current process to the given
59
+ # directory.
60
+ #
61
+ #
62
+ #
63
+ # ### Querying
64
+ #
65
+ # ::[]
66
+ # : Same as ::glob without the ability to pass flags.
67
+ #
68
+ # ::children
69
+ # : Returns an array of names of the children (both files and directories)
70
+ # of the given directory, but not including `.` or `..`.
71
+ #
72
+ # ::empty?
73
+ # : Returns whether the given path is an empty directory.
74
+ #
75
+ # ::entries
76
+ # : Returns an array of names of the children (both files and directories)
77
+ # of the given directory, including `.` and `..`.
78
+ #
79
+ # ::exist?
80
+ # : Returns whether the given path is a directory.
81
+ #
82
+ # ::getwd (aliased as #pwd)
83
+ # : Returns the path to the current working directory.
84
+ #
85
+ # ::glob
86
+ # : Returns an array of file paths matching the given pattern and flags.
87
+ #
88
+ # ::home
89
+ # : Returns the home directory path for a given user or the current user.
90
+ #
91
+ # #children
92
+ # : Returns an array of names of the children (both files and directories)
93
+ # of `self`, but not including `.` or `..`.
94
+ #
95
+ # #fileno
96
+ # : Returns the integer file descriptor for `self`.
97
+ #
98
+ # #path (aliased as #to_path)
99
+ # : Returns the path used to create `self`.
100
+ #
101
+ # #tell (aliased as #pos)
102
+ # : Returns the integer position in the directory stream for `self`.
103
+ #
104
+ #
105
+ #
106
+ # ### Iterating
107
+ #
108
+ # ::each_child
109
+ # : Calls the given block with each entry in the given directory, but not
110
+ # including `.` or `..`.
111
+ #
112
+ # ::foreach
113
+ # : Calls the given block with each entryin the given directory, including
114
+ # `.` and `..`.
115
+ #
116
+ # #each
117
+ # : Calls the given block with each entry in `self`, including `.` and
118
+ # `..`.
119
+ #
120
+ # #each_child
121
+ # : Calls the given block with each entry in `self`, but not including `.`
122
+ # or `..`.
123
+ #
124
+ #
125
+ #
126
+ # ### Other
127
+ #
128
+ # ::mkdir
129
+ # : Creates a directory at the given path, with optional permissions.
130
+ #
131
+ # ::new
132
+ # : Returns a new Dir for the given path, with optional encoding.
133
+ #
134
+ # ::open
135
+ # : Same as ::new, but if a block is given, yields the Dir to the block,
136
+ # closing it upon block exit.
137
+ #
138
+ # ::unlink (aliased as ::delete and ::rmdir)
139
+ # : Removes the given directory.
140
+ #
141
+ # #inspect
142
+ # : Returns a string description of `self`.
143
+ #
9
144
  class Dir
10
145
  include Enumerable[String]
11
146
 
147
+ # <!--
148
+ # rdoc-file=dir.rb
149
+ # - Dir.new( string ) -> aDir
150
+ # - Dir.new( string, encoding: enc ) -> aDir
151
+ # -->
12
152
  # Returns a new directory object for the named directory.
13
153
  #
14
154
  # The optional *encoding* keyword argument specifies the encoding of the
@@ -16,10 +156,19 @@ class Dir
16
156
  #
17
157
  def initialize: (string, ?encoding: encoding | nil) -> void
18
158
 
19
- # Equivalent to calling `Dir.glob([string,...], 0)`.
159
+ # <!--
160
+ # rdoc-file=dir.rb
161
+ # - Dir[ string [, string ...] [, base: path] [, sort: true] ] -> array
162
+ # -->
163
+ # Equivalent to calling `Dir.glob([`*string,...*`], 0)`.
20
164
  #
21
165
  def self.[]: (*string patterns, ?base: string) ?{ (String path) -> void } -> Array[String]
22
166
 
167
+ # <!--
168
+ # rdoc-file=dir.c
169
+ # - Dir.chdir( [ string] ) -> 0
170
+ # - Dir.chdir( [ string] ) {| path | block } -> anObject
171
+ # -->
23
172
  # Changes the current working directory of the process to the given string. When
24
173
  # called without an argument, changes the directory to the value of the
25
174
  # environment variable `HOME`, or `LOGDIR`. SystemCallError (probably
@@ -30,7 +179,8 @@ class Dir
30
179
  # directory is restored when the block exits. The return value of `chdir` is the
31
180
  # value of the block. `chdir` blocks can be nested, but in a multi-threaded
32
181
  # program an error will be raised if a thread attempts to open a `chdir` block
33
- # while another thread has one open.
182
+ # while another thread has one open or a call to `chdir` without a block occurs
183
+ # inside a block passed to `chdir` (even in the same thread).
34
184
  #
35
185
  # Dir.chdir("/var/spool/mail")
36
186
  # puts Dir.pwd
@@ -54,6 +204,11 @@ class Dir
54
204
  def self.chdir: (?string) -> void
55
205
  | [U] (?string) { (String) -> U } -> U
56
206
 
207
+ # <!--
208
+ # rdoc-file=dir.c
209
+ # - Dir.children( dirname ) -> array
210
+ # - Dir.children( dirname, encoding: enc ) -> array
211
+ # -->
57
212
  # Returns an array containing all of the filenames except for "." and ".." in
58
213
  # the given directory. Will raise a SystemCallError if the named directory
59
214
  # doesn't exist.
@@ -65,17 +220,34 @@ class Dir
65
220
  #
66
221
  def self.children: (string dirname, ?encoding: string | Encoding | nil enc) -> Array[String]
67
222
 
223
+ # <!--
224
+ # rdoc-file=dir.c
225
+ # - Dir.chroot( string ) -> 0
226
+ # -->
68
227
  # Changes this process's idea of the file system root. Only a privileged process
69
228
  # may make this call. Not available on all platforms. On Unix systems, see
70
229
  # `chroot(2)` for more information.
71
230
  #
72
231
  def self.chroot: (string) -> void
73
232
 
233
+ # <!--
234
+ # rdoc-file=dir.c
235
+ # - Dir.delete( string ) -> 0
236
+ # - Dir.rmdir( string ) -> 0
237
+ # - Dir.unlink( string ) -> 0
238
+ # -->
74
239
  # Deletes the named directory. Raises a subclass of SystemCallError if the
75
240
  # directory isn't empty.
76
241
  #
77
242
  def self.delete: (string) -> void
78
243
 
244
+ # <!--
245
+ # rdoc-file=dir.c
246
+ # - Dir.each_child( dirname ) {| filename | block } -> nil
247
+ # - Dir.each_child( dirname, encoding: enc ) {| filename | block } -> nil
248
+ # - Dir.each_child( dirname ) -> an_enumerator
249
+ # - Dir.each_child( dirname, encoding: enc ) -> an_enumerator
250
+ # -->
79
251
  # Calls the block once for each entry except for "." and ".." in the named
80
252
  # directory, passing the filename of each entry as a parameter to the block.
81
253
  #
@@ -91,11 +263,20 @@ class Dir
91
263
  def self.each_child: (string dirname, ?encoding: string | Encoding | nil enc) -> Enumerator[String, void]
92
264
  | (string dirname, ?encoding: string | Encoding | nil enc) { (String filename) -> void } -> void
93
265
 
266
+ # <!--
267
+ # rdoc-file=dir.c
268
+ # - Dir.empty?(path_name) -> true or false
269
+ # -->
94
270
  # Returns `true` if the named file is an empty directory, `false` if it is not a
95
271
  # directory or non-empty.
96
272
  #
97
273
  def self.empty?: (string path_name) -> bool
98
274
 
275
+ # <!--
276
+ # rdoc-file=dir.c
277
+ # - Dir.entries( dirname ) -> array
278
+ # - Dir.entries( dirname, encoding: enc ) -> array
279
+ # -->
99
280
  # Returns an array containing all of the filenames in the given directory. Will
100
281
  # raise a SystemCallError if the named directory doesn't exist.
101
282
  #
@@ -106,14 +287,21 @@ class Dir
106
287
  #
107
288
  def self.entries: (string dirname, ?encoding: encoding | nil enc) -> ::Array[String]
108
289
 
290
+ # <!--
291
+ # rdoc-file=dir.c
292
+ # - Dir.exist?(file_name) -> true or false
293
+ # -->
109
294
  # Returns `true` if the named file is a directory, `false` otherwise.
110
295
  #
111
296
  def self.exist?: (string file) -> bool
112
297
 
113
- # Deprecated method. Don't use.
114
- #
115
- def self.exists?: (string file) -> bool
116
-
298
+ # <!--
299
+ # rdoc-file=dir.c
300
+ # - Dir.foreach( dirname ) {| filename | block } -> nil
301
+ # - Dir.foreach( dirname, encoding: enc ) {| filename | block } -> nil
302
+ # - Dir.foreach( dirname ) -> an_enumerator
303
+ # - Dir.foreach( dirname, encoding: enc ) -> an_enumerator
304
+ # -->
117
305
  # Calls the block once for each entry in the named directory, passing the
118
306
  # filename of each entry as a parameter to the block.
119
307
  #
@@ -130,6 +318,11 @@ class Dir
130
318
  #
131
319
  alias self.foreach self.each_child
132
320
 
321
+ # <!--
322
+ # rdoc-file=dir.c
323
+ # - Dir.getwd -> string
324
+ # - Dir.pwd -> string
325
+ # -->
133
326
  # Returns the path to the current working directory of this process as a string.
134
327
  #
135
328
  # Dir.chdir("/tmp") #=> 0
@@ -138,6 +331,11 @@ class Dir
138
331
  #
139
332
  def self.getwd: () -> String
140
333
 
334
+ # <!--
335
+ # rdoc-file=dir.rb
336
+ # - Dir.glob( pattern, [flags], [base: path] [, sort: true] ) -> array
337
+ # - Dir.glob( pattern, [flags], [base: path] [, sort: true] ) { |filename| block } -> nil
338
+ # -->
141
339
  # Expands `pattern`, which is a pattern string or an Array of pattern strings,
142
340
  # and returns an array containing the matching filenames. If a block is given,
143
341
  # calls the block once for each matching filename, passing the filename as a
@@ -148,14 +346,17 @@ class Dir
148
346
  # the results are not prefixed with the base directory name in this case, you
149
347
  # will need to prepend the base directory name if you want real paths.
150
348
  #
349
+ # The results which matched single wildcard or character set are sorted in
350
+ # binary ascending order, unless `false` is given as the optional `sort` keyword
351
+ # argument. The order of an Array of pattern strings and braces are preserved.
352
+ #
151
353
  # Note that the pattern is not a regexp, it's closer to a shell glob. See
152
354
  # File::fnmatch for the meaning of the `flags` parameter. Case sensitivity
153
- # depends on your system (File::FNM_CASEFOLD is ignored), as does the order in
154
- # which the results are returned.
355
+ # depends on your system (`File::FNM_CASEFOLD` is ignored).
155
356
  #
156
357
  # `*`
157
358
  # : Matches any file. Can be restricted by other values in the glob.
158
- # Equivalent to `/ .* /mx` in regexp.
359
+ # Equivalent to `/.*/mx` in regexp.
159
360
  #
160
361
  # `*`
161
362
  # : Matches all files
@@ -173,7 +374,8 @@ class Dir
173
374
  # flag or something like `"{*,.*}"`.
174
375
  #
175
376
  # `**`
176
- # : Matches directories recursively.
377
+ # : Matches directories recursively if followed by `/`. If this path segment
378
+ # contains any other characters, it is the same as the usual `*`.
177
379
  #
178
380
  # `?`
179
381
  # : Matches any one character. Equivalent to `/.{1}/` in regexp.
@@ -189,7 +391,7 @@ class Dir
189
391
  # Matching literals may be more than one character in length. More than two
190
392
  # literals may be specified.
191
393
  #
192
- # ` \\ `
394
+ # `\`
193
395
  # : Escapes the next metacharacter.
194
396
  #
195
397
  # Note that this means you cannot use backslash on windows as part of a
@@ -207,31 +409,36 @@ class Dir
207
409
  # Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"]
208
410
  # Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"]
209
411
  #
210
- # rbfiles = File.join("**", "*.rb")
211
- # Dir.glob(rbfiles) #=> ["main.rb",
412
+ # Dir.glob("**/*.rb") #=> ["main.rb",
212
413
  # # "lib/song.rb",
213
414
  # # "lib/song/karaoke.rb"]
214
415
  #
215
- # Dir.glob(rbfiles, base: "lib") #=> ["song.rb",
416
+ # Dir.glob("**/*.rb", base: "lib") #=> ["song.rb",
216
417
  # # "song/karaoke.rb"]
217
418
  #
218
- # libdirs = File.join("**", "lib")
219
- # Dir.glob(libdirs) #=> ["lib"]
419
+ # Dir.glob("**/lib") #=> ["lib"]
220
420
  #
221
- # librbfiles = File.join("**", "lib", "**", "*.rb")
222
- # Dir.glob(librbfiles) #=> ["lib/song.rb",
421
+ # Dir.glob("**/lib/**/*.rb") #=> ["lib/song.rb",
223
422
  # # "lib/song/karaoke.rb"]
224
423
  #
225
- # librbfiles = File.join("**", "lib", "*.rb")
226
- # Dir.glob(librbfiles) #=> ["lib/song.rb"]
424
+ # Dir.glob("**/lib/*.rb") #=> ["lib/song.rb"]
227
425
  #
228
426
  def self.glob: (string | ::Array[string] pattern, ?Integer flags, ?base: string) -> ::Array[String]
229
427
  | (string | ::Array[string] pattern, ?Integer flags, ?base: string) { (String) -> void } -> void
230
428
 
429
+ # <!--
430
+ # rdoc-file=dir.c
431
+ # - Dir.home() -> "/home/me"
432
+ # - Dir.home("root") -> "/root"
433
+ # -->
231
434
  # Returns the home directory of the current user or the named user if given.
232
435
  #
233
436
  def self.home: (?string user) -> String
234
437
 
438
+ # <!--
439
+ # rdoc-file=dir.c
440
+ # - Dir.mkdir( string [, integer] ) -> 0
441
+ # -->
235
442
  # Makes a new directory named by *string*, with permissions specified by the
236
443
  # optional parameter *anInteger*. The permissions may be modified by the value
237
444
  # of File::umask, and are ignored on NT. Raises a SystemCallError if the
@@ -242,6 +449,13 @@ class Dir
242
449
  #
243
450
  def self.mkdir: (string, ?Integer permissions) -> void
244
451
 
452
+ # <!--
453
+ # rdoc-file=dir.rb
454
+ # - Dir.open( string ) -> aDir
455
+ # - Dir.open( string, encoding: enc ) -> aDir
456
+ # - Dir.open( string ) {| aDir | block } -> anObject
457
+ # - Dir.open( string, encoding: enc ) {| aDir | block } -> anObject
458
+ # -->
245
459
  # The optional *encoding* keyword argument specifies the encoding of the
246
460
  # directory. If not specified, the filesystem encoding is used.
247
461
  #
@@ -252,6 +466,11 @@ class Dir
252
466
  def self.open: (string, ?encoding: encoding | nil) -> Dir
253
467
  | [U] (string, ?encoding: encoding | nil) { (Dir) -> U } -> U
254
468
 
469
+ # <!--
470
+ # rdoc-file=dir.c
471
+ # - Dir.getwd -> string
472
+ # - Dir.pwd -> string
473
+ # -->
255
474
  # Returns the path to the current working directory of this process as a string.
256
475
  #
257
476
  # Dir.chdir("/tmp") #=> 0
@@ -260,11 +479,23 @@ class Dir
260
479
  #
261
480
  def self.pwd: () -> String
262
481
 
482
+ # <!--
483
+ # rdoc-file=dir.c
484
+ # - Dir.delete( string ) -> 0
485
+ # - Dir.rmdir( string ) -> 0
486
+ # - Dir.unlink( string ) -> 0
487
+ # -->
263
488
  # Deletes the named directory. Raises a subclass of SystemCallError if the
264
489
  # directory isn't empty.
265
490
  #
266
491
  alias self.rmdir self.delete
267
492
 
493
+ # <!--
494
+ # rdoc-file=dir.c
495
+ # - Dir.delete( string ) -> 0
496
+ # - Dir.rmdir( string ) -> 0
497
+ # - Dir.unlink( string ) -> 0
498
+ # -->
268
499
  # Deletes the named directory. Raises a subclass of SystemCallError if the
269
500
  # directory isn't empty.
270
501
  #
@@ -272,6 +503,10 @@ class Dir
272
503
 
273
504
  public
274
505
 
506
+ # <!--
507
+ # rdoc-file=dir.c
508
+ # - dir.children -> array
509
+ # -->
275
510
  # Returns an array containing all of the filenames except for "." and ".." in
276
511
  # this directory.
277
512
  #
@@ -280,6 +515,10 @@ class Dir
280
515
  #
281
516
  def children: () -> Array[String]
282
517
 
518
+ # <!--
519
+ # rdoc-file=dir.c
520
+ # - dir.close -> nil
521
+ # -->
283
522
  # Closes the directory stream. Calling this method on closed Dir object is
284
523
  # ignored since Ruby 2.3.
285
524
  #
@@ -288,6 +527,11 @@ class Dir
288
527
  #
289
528
  def close: () -> void
290
529
 
530
+ # <!--
531
+ # rdoc-file=dir.c
532
+ # - dir.each { |filename| block } -> dir
533
+ # - dir.each -> an_enumerator
534
+ # -->
291
535
  # Calls the block once for each entry in this directory, passing the filename of
292
536
  # each entry as a parameter to the block.
293
537
  #
@@ -306,6 +550,11 @@ class Dir
306
550
  def each: () { (String) -> void } -> self
307
551
  | () -> ::Enumerator[String, self]
308
552
 
553
+ # <!--
554
+ # rdoc-file=dir.c
555
+ # - dir.each_child {| filename | block } -> dir
556
+ # - dir.each_child -> an_enumerator
557
+ # -->
309
558
  # Calls the block once for each entry except for "." and ".." in this directory,
310
559
  # passing the filename of each entry as a parameter to the block.
311
560
  #
@@ -322,6 +571,10 @@ class Dir
322
571
  def each_child: () { (String) -> void } -> self
323
572
  | () -> ::Enumerator[String, self]
324
573
 
574
+ # <!--
575
+ # rdoc-file=dir.c
576
+ # - dir.fileno -> integer
577
+ # -->
325
578
  # Returns the file descriptor used in *dir*.
326
579
  #
327
580
  # d = Dir.new("..")
@@ -333,10 +586,19 @@ class Dir
333
586
  #
334
587
  def fileno: () -> Integer
335
588
 
589
+ # <!--
590
+ # rdoc-file=dir.c
591
+ # - dir.inspect -> string
592
+ # -->
336
593
  # Return a string describing this Dir object.
337
594
  #
338
595
  def inspect: () -> String
339
596
 
597
+ # <!--
598
+ # rdoc-file=dir.c
599
+ # - dir.path -> string or nil
600
+ # - dir.to_path -> string or nil
601
+ # -->
340
602
  # Returns the path parameter passed to *dir*'s constructor.
341
603
  #
342
604
  # d = Dir.new("..")
@@ -344,6 +606,7 @@ class Dir
344
606
  #
345
607
  def path: () -> String?
346
608
 
609
+ # <!-- rdoc-file=dir.c -->
347
610
  # Returns the current position in *dir*. See also Dir#seek.
348
611
  #
349
612
  # d = Dir.new("testdir")
@@ -353,6 +616,10 @@ class Dir
353
616
  #
354
617
  def pos: () -> Integer
355
618
 
619
+ # <!--
620
+ # rdoc-file=dir.c
621
+ # - dir.pos = integer -> integer
622
+ # -->
356
623
  # Synonym for Dir#seek, but returns the position parameter.
357
624
  #
358
625
  # d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
@@ -364,6 +631,10 @@ class Dir
364
631
  #
365
632
  def pos=: (Integer pos) -> Integer
366
633
 
634
+ # <!--
635
+ # rdoc-file=dir.c
636
+ # - dir.read -> string or nil
637
+ # -->
367
638
  # Reads the next entry from *dir* and returns it as a string. Returns `nil` at
368
639
  # the end of the stream.
369
640
  #
@@ -374,6 +645,10 @@ class Dir
374
645
  #
375
646
  def read: () -> String?
376
647
 
648
+ # <!--
649
+ # rdoc-file=dir.c
650
+ # - dir.rewind -> dir
651
+ # -->
377
652
  # Repositions *dir* to the first entry.
378
653
  #
379
654
  # d = Dir.new("testdir")
@@ -383,6 +658,10 @@ class Dir
383
658
  #
384
659
  def rewind: () -> self
385
660
 
661
+ # <!--
662
+ # rdoc-file=dir.c
663
+ # - dir.seek( integer ) -> dir
664
+ # -->
386
665
  # Seeks to a particular location in *dir*. *integer* must be a value returned by
387
666
  # Dir#tell.
388
667
  #
@@ -395,6 +674,11 @@ class Dir
395
674
  #
396
675
  def seek: (Integer) -> self
397
676
 
677
+ # <!--
678
+ # rdoc-file=dir.c
679
+ # - dir.pos -> integer
680
+ # - dir.tell -> integer
681
+ # -->
398
682
  # Returns the current position in *dir*. See also Dir#seek.
399
683
  #
400
684
  # d = Dir.new("testdir")
@@ -404,6 +688,7 @@ class Dir
404
688
  #
405
689
  def tell: () -> Integer
406
690
 
691
+ # <!-- rdoc-file=dir.c -->
407
692
  # Returns the path parameter passed to *dir*'s constructor.
408
693
  #
409
694
  # d = Dir.new("..")