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/pathname.rbs ADDED
@@ -0,0 +1,1322 @@
1
+ # <!-- rdoc-file=lib/pathname.rb -->
2
+ # # pathname.rb
3
+ #
4
+ # Object-Oriented Pathname Class
5
+ #
6
+ # Author
7
+ # : Tanaka Akira <akr@m17n.org>
8
+ #
9
+ # Documentation
10
+ # : Author and Gavin Sinclair
11
+ #
12
+ #
13
+ # For documentation, see class Pathname.
14
+ #
15
+ # <!-- rdoc-file=pathname_builtin.rb -->
16
+ # Pathname represents the name of a file or directory on the filesystem, but not
17
+ # the file itself.
18
+ #
19
+ # The pathname depends on the Operating System: Unix, Windows, etc. This library
20
+ # works with pathnames of local OS, however non-Unix pathnames are supported
21
+ # experimentally.
22
+ #
23
+ # A Pathname can be relative or absolute. It's not until you try to reference
24
+ # the file that it even matters whether the file exists or not.
25
+ #
26
+ # Pathname is immutable. It has no method for destructive update.
27
+ #
28
+ # The goal of this class is to manipulate file path information in a neater way
29
+ # than standard Ruby provides. The examples below demonstrate the difference.
30
+ #
31
+ # **All** functionality from File, FileTest, and some from Dir and FileUtils is
32
+ # included, in an unsurprising way. It is essentially a facade for all of
33
+ # these, and more.
34
+ #
35
+ # ## Examples
36
+ #
37
+ # ### Example 1: Using Pathname
38
+ #
39
+ # require 'pathname'
40
+ # pn = Pathname.new("/usr/bin/ruby")
41
+ # size = pn.size # 27662
42
+ # isdir = pn.directory? # false
43
+ # dir = pn.dirname # Pathname:/usr/bin
44
+ # base = pn.basename # Pathname:ruby
45
+ # dir, base = pn.split # [Pathname:/usr/bin, Pathname:ruby]
46
+ # data = pn.read
47
+ # pn.open { |f| _ }
48
+ # pn.each_line { |line| _ }
49
+ #
50
+ # ### Example 2: Using standard Ruby
51
+ #
52
+ # pn = "/usr/bin/ruby"
53
+ # size = File.size(pn) # 27662
54
+ # isdir = File.directory?(pn) # false
55
+ # dir = File.dirname(pn) # "/usr/bin"
56
+ # base = File.basename(pn) # "ruby"
57
+ # dir, base = File.split(pn) # ["/usr/bin", "ruby"]
58
+ # data = File.read(pn)
59
+ # File.open(pn) { |f| _ }
60
+ # File.foreach(pn) { |line| _ }
61
+ #
62
+ # ### Example 3: Special features
63
+ #
64
+ # p1 = Pathname.new("/usr/lib") # Pathname:/usr/lib
65
+ # p2 = p1 + "ruby/1.8" # Pathname:/usr/lib/ruby/1.8
66
+ # p3 = p1.parent # Pathname:/usr
67
+ # p4 = p2.relative_path_from(p3) # Pathname:lib/ruby/1.8
68
+ # pwd = Pathname.pwd # Pathname:/home/gavin
69
+ # pwd.absolute? # true
70
+ # p5 = Pathname.new "." # Pathname:.
71
+ # p5 = p5 + "music/../articles" # Pathname:music/../articles
72
+ # p5.cleanpath # Pathname:articles
73
+ # p5.realpath # Pathname:/home/gavin/articles
74
+ # p5.children # [Pathname:/home/gavin/articles/linux, ...]
75
+ #
76
+ # ## Breakdown of functionality
77
+ #
78
+ # ### Core methods
79
+ #
80
+ # These methods are effectively manipulating a String, because that's all a path
81
+ # is. None of these access the file system except for #mountpoint?, #children,
82
+ # #each_child, #realdirpath and #realpath.
83
+ #
84
+ # * +
85
+ # * #join
86
+ # * #parent
87
+ # * #root?
88
+ # * #absolute?
89
+ # * #relative?
90
+ # * #relative_path_from
91
+ # * #each_filename
92
+ # * #cleanpath
93
+ # * #realpath
94
+ # * #realdirpath
95
+ # * #children
96
+ # * #each_child
97
+ # * #mountpoint?
98
+ #
99
+ # ### File status predicate methods
100
+ #
101
+ # These methods are a facade for FileTest:
102
+ # * #blockdev?
103
+ # * #chardev?
104
+ # * #directory?
105
+ # * #executable?
106
+ # * #executable_real?
107
+ # * #exist?
108
+ # * #file?
109
+ # * #grpowned?
110
+ # * #owned?
111
+ # * #pipe?
112
+ # * #readable?
113
+ # * #world_readable?
114
+ # * #readable_real?
115
+ # * #setgid?
116
+ # * #setuid?
117
+ # * #size
118
+ # * #size?
119
+ # * #socket?
120
+ # * #sticky?
121
+ # * #symlink?
122
+ # * #writable?
123
+ # * #world_writable?
124
+ # * #writable_real?
125
+ # * #zero?
126
+ #
127
+ # ### File property and manipulation methods
128
+ #
129
+ # These methods are a facade for File:
130
+ # * #each_line(*args, &block)
131
+ # * #read(*args)
132
+ # * #binread(*args)
133
+ # * #readlines(*args)
134
+ # * #sysopen(*args)
135
+ # * #write(*args)
136
+ # * #binwrite(*args)
137
+ # * #atime
138
+ # * #birthtime
139
+ # * #ctime
140
+ # * #mtime
141
+ # * #chmod(mode)
142
+ # * #lchmod(mode)
143
+ # * #chown(owner, group)
144
+ # * #lchown(owner, group)
145
+ # * #fnmatch(pattern, *args)
146
+ # * #fnmatch?(pattern, *args)
147
+ # * #ftype
148
+ # * #make_link(old)
149
+ # * #open(*args, &block)
150
+ # * #readlink
151
+ # * #rename(to)
152
+ # * #stat
153
+ # * #lstat
154
+ # * #make_symlink(old)
155
+ # * #truncate(length)
156
+ # * #utime(atime, mtime)
157
+ # * #lutime(atime, mtime)
158
+ # * #basename(*args)
159
+ # * #dirname
160
+ # * #extname
161
+ # * #expand_path(*args)
162
+ # * #split
163
+ #
164
+ # ### Directory methods
165
+ #
166
+ # These methods are a facade for Dir:
167
+ # * Pathname.glob(*args)
168
+ # * Pathname.getwd / Pathname.pwd
169
+ # * #rmdir
170
+ # * #entries
171
+ # * #each_entry(&block)
172
+ # * #mkdir(*args)
173
+ # * #opendir(*args)
174
+ #
175
+ # ### Utilities
176
+ #
177
+ # These methods are a mixture of Find, FileUtils, and others:
178
+ # * #find(&block)
179
+ # * #mkpath
180
+ # * #rmtree
181
+ # * #unlink / #delete
182
+ #
183
+ # ## Method documentation
184
+ #
185
+ # As the above section shows, most of the methods in Pathname are facades. The
186
+ # documentation for these methods generally just says, for instance, "See
187
+ # FileTest.writable?", as you should be familiar with the original method
188
+ # anyway, and its documentation (e.g. through `ri`) will contain more
189
+ # information. In some cases, a brief description will follow.
190
+ #
191
+ class Pathname
192
+ # <!--
193
+ # rdoc-file=pathname_builtin.rb
194
+ # - getwd()
195
+ # -->
196
+ # See <code>Dir.getwd</code>. Returns the current working directory as a
197
+ # Pathname.
198
+ #
199
+ def self.getwd: () -> Pathname
200
+
201
+ # <!--
202
+ # rdoc-file=pathname_builtin.rb
203
+ # - glob(*args, **kwargs) { |pathname| ... }
204
+ # -->
205
+ # See <code>Dir.glob</code>. Returns or yields Pathname objects.
206
+ #
207
+ def self.glob: (String | Array[String] pattern, ?Integer flags) -> Array[Pathname]
208
+ | (String | Array[String] pattern, ?Integer flags) { (Pathname) -> untyped } -> nil
209
+
210
+ # <!--
211
+ # rdoc-file=pathname_builtin.rb
212
+ # - pwd()
213
+ # -->
214
+ #
215
+ def self.pwd: () -> Pathname
216
+
217
+ # <!--
218
+ # rdoc-file=pathname_builtin.rb
219
+ # - +(other)
220
+ # -->
221
+ # Appends a pathname fragment to `self` to produce a new Pathname object. Since
222
+ # `other` is considered as a path relative to `self`, if `other` is an absolute
223
+ # path, the new Pathname object is created from just `other`.
224
+ #
225
+ # p1 = Pathname.new("/usr") # Pathname:/usr
226
+ # p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
227
+ # p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
228
+ #
229
+ # # / is aliased to +.
230
+ # p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby
231
+ # p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd
232
+ #
233
+ # This method doesn't access the file system; it is pure string manipulation.
234
+ #
235
+ def +: (Pathname | String | _ToStr other) -> Pathname
236
+
237
+ # <!--
238
+ # rdoc-file=pathname_builtin.rb
239
+ # - /(other)
240
+ # -->
241
+ #
242
+ alias / +
243
+
244
+ # <!--
245
+ # rdoc-file=pathname.c
246
+ # - <=>(p1)
247
+ # -->
248
+ # Provides a case-sensitive comparison operator for pathnames.
249
+ #
250
+ # Pathname.new('/usr') <=> Pathname.new('/usr/bin')
251
+ # #=> -1
252
+ # Pathname.new('/usr/bin') <=> Pathname.new('/usr/bin')
253
+ # #=> 0
254
+ # Pathname.new('/usr/bin') <=> Pathname.new('/USR/BIN')
255
+ # #=> 1
256
+ #
257
+ # It will return <code>-1</code>, `0` or `1` depending on the value of the left
258
+ # argument relative to the right argument. Or it will return `nil` if the
259
+ # arguments are not comparable.
260
+ #
261
+ def <=>: (Pathname other) -> Integer
262
+ | (untyped other) -> nil
263
+
264
+ # <!--
265
+ # rdoc-file=pathname_builtin.rb
266
+ # - ==(other)
267
+ # -->
268
+ # Compare this pathname with `other`. The comparison is string-based. Be aware
269
+ # that two different paths (<code>foo.txt</code> and <code>./foo.txt</code>) can
270
+ # refer to the same file.
271
+ #
272
+ def ==: (untyped) -> bool
273
+
274
+ # <!--
275
+ # rdoc-file=pathname_builtin.rb
276
+ # - ===(other)
277
+ # -->
278
+ #
279
+ def ===: (untyped) -> bool
280
+
281
+ # <!--
282
+ # rdoc-file=pathname_builtin.rb
283
+ # - absolute?()
284
+ # -->
285
+ # Predicate method for testing whether a path is absolute.
286
+ #
287
+ # It returns `true` if the pathname begins with a slash.
288
+ #
289
+ # p = Pathname.new('/im/sure')
290
+ # p.absolute?
291
+ # #=> true
292
+ #
293
+ # p = Pathname.new('not/so/sure')
294
+ # p.absolute?
295
+ # #=> false
296
+ #
297
+ def absolute?: () -> bool
298
+
299
+ # <!--
300
+ # rdoc-file=pathname_builtin.rb
301
+ # - ascend() { |self| ... }
302
+ # -->
303
+ # Iterates over and yields a new Pathname object for each element in the given
304
+ # path in ascending order.
305
+ #
306
+ # Pathname.new('/path/to/some/file.rb').ascend {|v| p v}
307
+ # #<Pathname:/path/to/some/file.rb>
308
+ # #<Pathname:/path/to/some>
309
+ # #<Pathname:/path/to>
310
+ # #<Pathname:/path>
311
+ # #<Pathname:/>
312
+ #
313
+ # Pathname.new('path/to/some/file.rb').ascend {|v| p v}
314
+ # #<Pathname:path/to/some/file.rb>
315
+ # #<Pathname:path/to/some>
316
+ # #<Pathname:path/to>
317
+ # #<Pathname:path>
318
+ #
319
+ # Returns an Enumerator if no block was given.
320
+ #
321
+ # enum = Pathname.new("/usr/bin/ruby").ascend
322
+ # # ... do stuff ...
323
+ # enum.each { |e| ... }
324
+ # # yields Pathnames /usr/bin/ruby, /usr/bin, /usr, and /.
325
+ #
326
+ # It doesn't access the filesystem.
327
+ #
328
+ def ascend: () { (Pathname) -> untyped } -> nil
329
+ | () -> Enumerator[Pathname, nil]
330
+
331
+ # <!--
332
+ # rdoc-file=pathname_builtin.rb
333
+ # - atime()
334
+ # -->
335
+ # See <code>File.atime</code>. Returns last access time.
336
+ #
337
+ def atime: () -> Time
338
+
339
+ # <!--
340
+ # rdoc-file=pathname_builtin.rb
341
+ # - basename(...)
342
+ # -->
343
+ # See <code>File.basename</code>. Returns the last component of the path.
344
+ #
345
+ def basename: (?String | _ToStr suffix) -> Pathname
346
+
347
+ # <!--
348
+ # rdoc-file=pathname_builtin.rb
349
+ # - binread(...)
350
+ # -->
351
+ # See <code>File.binread</code>. Returns all the bytes from the file, or the
352
+ # first `N` if specified.
353
+ #
354
+ def binread: (?Integer length, ?Integer offset) -> String
355
+
356
+ # <!--
357
+ # rdoc-file=pathname_builtin.rb
358
+ # - binwrite(...)
359
+ # -->
360
+ # Writes `contents` to the file, opening it in binary mode.
361
+ #
362
+ # See File.binwrite.
363
+ #
364
+ def binwrite: (String, ?Integer offset, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?invalid: :replace ?, ?undef: :replace ?, ?replace: String, ?fallback: Hash[String, String] | Proc | Method, ?xml: :text | :attr, ?universal_newline: true, ?cr_newline: true, ?crlf_newline: true) -> Integer
365
+
366
+ # <!--
367
+ # rdoc-file=pathname_builtin.rb
368
+ # - birthtime()
369
+ # -->
370
+ # Returns the birth time for the file. If the platform doesn't have birthtime,
371
+ # raises NotImplementedError.
372
+ #
373
+ # See File.birthtime.
374
+ #
375
+ def birthtime: () -> Time
376
+
377
+ # <!--
378
+ # rdoc-file=pathname_builtin.rb
379
+ # - blockdev?()
380
+ # -->
381
+ # See <code>FileTest.blockdev?</code>.
382
+ #
383
+ def blockdev?: () -> bool
384
+
385
+ # <!--
386
+ # rdoc-file=pathname_builtin.rb
387
+ # - chardev?()
388
+ # -->
389
+ # See <code>FileTest.chardev?</code>.
390
+ #
391
+ def chardev?: () -> bool
392
+
393
+ # <!--
394
+ # rdoc-file=pathname_builtin.rb
395
+ # - children(with_directory=true)
396
+ # -->
397
+ # Returns the children of the directory (files and subdirectories, not
398
+ # recursive) as an array of Pathname objects.
399
+ #
400
+ # By default, the returned pathnames will have enough information to access the
401
+ # files. If you set `with_directory` to `false`, then the returned pathnames
402
+ # will contain the filename only.
403
+ #
404
+ # For example:
405
+ # pn = Pathname("/usr/lib/ruby/1.8")
406
+ # pn.children
407
+ # # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
408
+ # Pathname:/usr/lib/ruby/1.8/Env.rb,
409
+ # Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
410
+ # pn.children(false)
411
+ # # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
412
+ #
413
+ # Note that the results never contain the entries <code>.</code> and
414
+ # <code>..</code> in the directory because they are not children.
415
+ #
416
+ def children: (?boolish with_directory) -> Array[Pathname]
417
+
418
+ # <!--
419
+ # rdoc-file=pathname_builtin.rb
420
+ # - chmod(mode)
421
+ # -->
422
+ # See <code>File.chmod</code>. Changes permissions.
423
+ #
424
+ def chmod: (Integer mode_int) -> Integer
425
+
426
+ # <!--
427
+ # rdoc-file=pathname_builtin.rb
428
+ # - chown(owner, group)
429
+ # -->
430
+ # See <code>File.chown</code>. Change owner and group of file.
431
+ #
432
+ def chown: (Integer owner, Integer group) -> Integer
433
+
434
+ # <!--
435
+ # rdoc-file=pathname_builtin.rb
436
+ # - cleanpath(consider_symlink=false)
437
+ # -->
438
+ # Returns clean pathname of `self` with consecutive slashes and useless dots
439
+ # removed. The filesystem is not accessed.
440
+ #
441
+ # If `consider_symlink` is `true`, then a more conservative algorithm is used to
442
+ # avoid breaking symbolic linkages. This may retain more <code>..</code>
443
+ # entries than absolutely necessary, but without accessing the filesystem, this
444
+ # can't be avoided.
445
+ #
446
+ # See Pathname#realpath.
447
+ #
448
+ def cleanpath: (?boolish consider_symlink) -> Pathname
449
+
450
+ # <!--
451
+ # rdoc-file=pathname_builtin.rb
452
+ # - ctime()
453
+ # -->
454
+ # See <code>File.ctime</code>. Returns last (directory entry, not file) change
455
+ # time.
456
+ #
457
+ def ctime: () -> Time
458
+
459
+ # <!--
460
+ # rdoc-file=pathname_builtin.rb
461
+ # - delete()
462
+ # -->
463
+ #
464
+ def delete: () -> Integer
465
+
466
+ # <!--
467
+ # rdoc-file=pathname_builtin.rb
468
+ # - descend() { |v| ... }
469
+ # -->
470
+ # Iterates over and yields a new Pathname object for each element in the given
471
+ # path in descending order.
472
+ #
473
+ # Pathname.new('/path/to/some/file.rb').descend {|v| p v}
474
+ # #<Pathname:/>
475
+ # #<Pathname:/path>
476
+ # #<Pathname:/path/to>
477
+ # #<Pathname:/path/to/some>
478
+ # #<Pathname:/path/to/some/file.rb>
479
+ #
480
+ # Pathname.new('path/to/some/file.rb').descend {|v| p v}
481
+ # #<Pathname:path>
482
+ # #<Pathname:path/to>
483
+ # #<Pathname:path/to/some>
484
+ # #<Pathname:path/to/some/file.rb>
485
+ #
486
+ # Returns an Enumerator if no block was given.
487
+ #
488
+ # enum = Pathname.new("/usr/bin/ruby").descend
489
+ # # ... do stuff ...
490
+ # enum.each { |e| ... }
491
+ # # yields Pathnames /, /usr, /usr/bin, and /usr/bin/ruby.
492
+ #
493
+ # It doesn't access the filesystem.
494
+ #
495
+ def descend: () { (Pathname) -> untyped } -> nil
496
+ | () -> Enumerator[Pathname, nil]
497
+
498
+ # <!--
499
+ # rdoc-file=pathname_builtin.rb
500
+ # - directory?()
501
+ # -->
502
+ # See <code>FileTest.directory?</code>.
503
+ #
504
+ def directory?: () -> bool
505
+
506
+ # <!--
507
+ # rdoc-file=pathname_builtin.rb
508
+ # - dirname()
509
+ # -->
510
+ # See <code>File.dirname</code>. Returns all but the last component of the
511
+ # path.
512
+ #
513
+ def dirname: () -> Pathname
514
+
515
+ # <!--
516
+ # rdoc-file=pathname_builtin.rb
517
+ # - each_child(with_directory=true, &b)
518
+ # -->
519
+ # Iterates over the children of the directory (files and subdirectories, not
520
+ # recursive).
521
+ #
522
+ # It yields Pathname object for each child.
523
+ #
524
+ # By default, the yielded pathnames will have enough information to access the
525
+ # files.
526
+ #
527
+ # If you set `with_directory` to `false`, then the returned pathnames will
528
+ # contain the filename only.
529
+ #
530
+ # Pathname("/usr/local").each_child {|f| p f }
531
+ # #=> #<Pathname:/usr/local/share>
532
+ # # #<Pathname:/usr/local/bin>
533
+ # # #<Pathname:/usr/local/games>
534
+ # # #<Pathname:/usr/local/lib>
535
+ # # #<Pathname:/usr/local/include>
536
+ # # #<Pathname:/usr/local/sbin>
537
+ # # #<Pathname:/usr/local/src>
538
+ # # #<Pathname:/usr/local/man>
539
+ #
540
+ # Pathname("/usr/local").each_child(false) {|f| p f }
541
+ # #=> #<Pathname:share>
542
+ # # #<Pathname:bin>
543
+ # # #<Pathname:games>
544
+ # # #<Pathname:lib>
545
+ # # #<Pathname:include>
546
+ # # #<Pathname:sbin>
547
+ # # #<Pathname:src>
548
+ # # #<Pathname:man>
549
+ #
550
+ # Note that the results never contain the entries <code>.</code> and
551
+ # <code>..</code> in the directory because they are not children.
552
+ #
553
+ # See Pathname#children
554
+ #
555
+ def each_child: (?boolish with_directory) { (Pathname) -> void } -> Array[Pathname]
556
+ | (?boolish with_directory) -> Enumerator[Pathname, Array[Pathname]]
557
+
558
+ # <!--
559
+ # rdoc-file=pathname_builtin.rb
560
+ # - each_entry() { |pathname| ... }
561
+ # -->
562
+ # Iterates over the entries (files and subdirectories) in the directory. It
563
+ # yields a Pathname object for each entry.
564
+ #
565
+ # This method has existed since 1.8.1.
566
+ #
567
+ def each_entry: () { (Pathname) -> untyped } -> nil
568
+
569
+ # <!--
570
+ # rdoc-file=pathname_builtin.rb
571
+ # - each_filename() { |filename| ... }
572
+ # -->
573
+ # Iterates over each component of the path.
574
+ #
575
+ # Pathname.new("/usr/bin/ruby").each_filename {|filename| ... }
576
+ # # yields "usr", "bin", and "ruby".
577
+ #
578
+ # Returns an Enumerator if no block was given.
579
+ #
580
+ # enum = Pathname.new("/usr/bin/ruby").each_filename
581
+ # # ... do stuff ...
582
+ # enum.each { |e| ... }
583
+ # # yields "usr", "bin", and "ruby".
584
+ #
585
+ def each_filename: () { (String) -> untyped } -> nil
586
+ | () -> Enumerator[String, nil]
587
+
588
+ # <!--
589
+ # rdoc-file=pathname_builtin.rb
590
+ # - each_line(...) { |line| ... }
591
+ # -->
592
+ # #each_line iterates over the line in the file. It yields a String object for
593
+ # each line.
594
+ #
595
+ # This method has existed since 1.8.1.
596
+ #
597
+ def each_line: (?String sep, ?Integer limit, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?chomp: boolish) { (String) -> untyped } -> nil
598
+ | (Integer limit, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?chomp: boolish) { (String) -> untyped } -> nil
599
+ | (?String sep, ?Integer limit, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?chomp: boolish) -> Enumerator[String, nil]
600
+ | (Integer limit, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?chomp: boolish) -> Enumerator[String, nil]
601
+
602
+ # <!--
603
+ # rdoc-file=pathname_builtin.rb
604
+ # - empty?()
605
+ # -->
606
+ # Tests the file is empty.
607
+ #
608
+ # See Dir#empty? and FileTest.empty?.
609
+ #
610
+ def empty?: () -> bool
611
+
612
+ # <!--
613
+ # rdoc-file=pathname_builtin.rb
614
+ # - entries()
615
+ # -->
616
+ # Return the entries (files and subdirectories) in the directory, each as a
617
+ # Pathname object.
618
+ #
619
+ def entries: () -> Array[Pathname]
620
+
621
+ # <!--
622
+ # rdoc-file=pathname_builtin.rb
623
+ # - eql?(other)
624
+ # -->
625
+ #
626
+ def eql?: (untyped) -> bool
627
+
628
+ # <!--
629
+ # rdoc-file=pathname_builtin.rb
630
+ # - executable?()
631
+ # -->
632
+ # See <code>FileTest.executable?</code>.
633
+ #
634
+ def executable?: () -> bool
635
+
636
+ # <!--
637
+ # rdoc-file=pathname_builtin.rb
638
+ # - executable_real?()
639
+ # -->
640
+ # See <code>FileTest.executable_real?</code>.
641
+ #
642
+ def executable_real?: () -> bool
643
+
644
+ # <!--
645
+ # rdoc-file=pathname_builtin.rb
646
+ # - exist?()
647
+ # -->
648
+ # See <code>FileTest.exist?</code>.
649
+ #
650
+ def exist?: () -> bool
651
+
652
+ # <!--
653
+ # rdoc-file=pathname_builtin.rb
654
+ # - expand_path(...)
655
+ # -->
656
+ # See <code>File.expand_path</code>.
657
+ #
658
+ def expand_path: (?String dir) -> Pathname
659
+
660
+ # <!--
661
+ # rdoc-file=pathname_builtin.rb
662
+ # - extname()
663
+ # -->
664
+ # See <code>File.extname</code>. Returns the file's extension.
665
+ #
666
+ def extname: () -> String
667
+
668
+ # <!--
669
+ # rdoc-file=pathname_builtin.rb
670
+ # - file?()
671
+ # -->
672
+ # See <code>FileTest.file?</code>.
673
+ #
674
+ def file?: () -> bool
675
+
676
+ # <!--
677
+ # rdoc-file=pathname_builtin.rb
678
+ # - fnmatch(pattern, ...)
679
+ # -->
680
+ # See <code>File.fnmatch</code>. Return `true` if the receiver matches the
681
+ # given pattern.
682
+ #
683
+ def fnmatch: (String pattern, ?Integer flags) -> bool
684
+
685
+ # <!--
686
+ # rdoc-file=pathname_builtin.rb
687
+ # - fnmatch?(pattern, ...)
688
+ # -->
689
+ # See <code>File.fnmatch?</code> (same as #fnmatch).
690
+ #
691
+ alias fnmatch? fnmatch
692
+
693
+ # <!--
694
+ # rdoc-file=pathname_builtin.rb
695
+ # - freeze()
696
+ # -->
697
+ # Freze self.
698
+ #
699
+ def freeze: () -> Pathname
700
+
701
+ # <!--
702
+ # rdoc-file=pathname_builtin.rb
703
+ # - ftype()
704
+ # -->
705
+ # See <code>File.ftype</code>. Returns "type" of file ("file", "directory",
706
+ # etc).
707
+ #
708
+ def ftype: () -> String
709
+
710
+ # <!--
711
+ # rdoc-file=pathname_builtin.rb
712
+ # - glob(*args, **kwargs) { |pathname| ... }
713
+ # -->
714
+ # Returns or yields Pathname objects.
715
+ #
716
+ # Pathname("ruby-2.4.2").glob("R*.md")
717
+ # #=> [#<Pathname:ruby-2.4.2/README.md>, #<Pathname:ruby-2.4.2/README.ja.md>]
718
+ #
719
+ # See Dir.glob. This method uses the `base` keyword argument of Dir.glob.
720
+ #
721
+ def glob: (String | Array[String] pattern, ?Integer flags) -> Array[Pathname]
722
+ | (String | Array[String] pattern, ?Integer flags) { (Pathname) -> untyped } -> nil
723
+
724
+ # <!--
725
+ # rdoc-file=pathname_builtin.rb
726
+ # - grpowned?()
727
+ # -->
728
+ # See <code>FileTest.grpowned?</code>.
729
+ #
730
+ def grpowned?: () -> bool
731
+
732
+ def hash: () -> Integer
733
+
734
+ def inspect: () -> String
735
+
736
+ # <!--
737
+ # rdoc-file=pathname_builtin.rb
738
+ # - join(*args)
739
+ # -->
740
+ # Joins the given pathnames onto `self` to create a new Pathname object. This is
741
+ # effectively the same as using Pathname#+ to append `self` and all arguments
742
+ # sequentially.
743
+ #
744
+ # path0 = Pathname.new("/usr") # Pathname:/usr
745
+ # path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
746
+ # # is the same as
747
+ # path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
748
+ # path0 == path1
749
+ # #=> true
750
+ #
751
+ def join: (*String | _ToStr | Pathname args) -> Pathname
752
+
753
+ # <!--
754
+ # rdoc-file=pathname_builtin.rb
755
+ # - lchmod(mode)
756
+ # -->
757
+ # See <code>File.lchmod</code>.
758
+ #
759
+ def lchmod: (Integer mode) -> Integer
760
+
761
+ # <!--
762
+ # rdoc-file=pathname_builtin.rb
763
+ # - lchown(owner, group)
764
+ # -->
765
+ # See <code>File.lchown</code>.
766
+ #
767
+ def lchown: (Integer owner, Integer group) -> Integer
768
+
769
+ # <!--
770
+ # rdoc-file=pathname_builtin.rb
771
+ # - lstat()
772
+ # -->
773
+ # See <code>File.lstat</code>.
774
+ #
775
+ def lstat: () -> ::File::Stat
776
+
777
+ # <!--
778
+ # rdoc-file=pathname_builtin.rb
779
+ # - lutime(atime, mtime)
780
+ # -->
781
+ # Update the access and modification times of the file.
782
+ #
783
+ # Same as Pathname#utime, but does not follow symbolic links.
784
+ #
785
+ # See File.lutime.
786
+ #
787
+ def lutime: (Time | Numeric atime, Time | Numeric mtime) -> Integer
788
+
789
+ # <!--
790
+ # rdoc-file=pathname_builtin.rb
791
+ # - make_link(old)
792
+ # -->
793
+ # See <code>File.link</code>. Creates a hard link.
794
+ #
795
+ def make_link: (String | Pathname | _ToStr old) -> Integer
796
+
797
+ # <!--
798
+ # rdoc-file=pathname_builtin.rb
799
+ # - make_symlink(old)
800
+ # -->
801
+ # See <code>File.symlink</code>. Creates a symbolic link.
802
+ #
803
+ def make_symlink: (String | Pathname | _ToStr old) -> Integer
804
+
805
+ # <!--
806
+ # rdoc-file=pathname_builtin.rb
807
+ # - mkdir(...)
808
+ # -->
809
+ # See <code>Dir.mkdir</code>. Create the referenced directory.
810
+ #
811
+ def mkdir: (?Integer perm) -> Integer
812
+
813
+ # <!--
814
+ # rdoc-file=pathname_builtin.rb
815
+ # - mkpath(mode: nil)
816
+ # -->
817
+ # Creates a full path, including any intermediate directories that don't yet
818
+ # exist.
819
+ #
820
+ # See FileUtils.mkpath and FileUtils.mkdir_p
821
+ #
822
+ def mkpath: () -> self
823
+
824
+ # <!--
825
+ # rdoc-file=pathname_builtin.rb
826
+ # - mountpoint?()
827
+ # -->
828
+ # Returns `true` if `self` points to a mountpoint.
829
+ #
830
+ def mountpoint?: () -> bool
831
+
832
+ # <!--
833
+ # rdoc-file=pathname_builtin.rb
834
+ # - mtime()
835
+ # -->
836
+ # See <code>File.mtime</code>. Returns last modification time.
837
+ #
838
+ def mtime: () -> Time
839
+
840
+ # <!--
841
+ # rdoc-file=pathname_builtin.rb
842
+ # - open(...) { |file| ... }
843
+ # -->
844
+ # See <code>File.open</code>. Opens the file for reading or writing.
845
+ #
846
+ def open: (
847
+ ?string | int mode,
848
+ ?int perm,
849
+ # open options
850
+ ?flags: Integer,
851
+ ?external_encoding: encoding,
852
+ ?internal_encoding: encoding,
853
+ ?encoding: encoding,
854
+ ?textmode: boolish,
855
+ ?binmode: boolish,
856
+ ?autoclose: boolish,
857
+ ?path: path,
858
+ # encoding options
859
+ ?invalid: :replace | nil,
860
+ ?undef: :replace | nil,
861
+ ?replace: String | nil,
862
+ ?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
863
+ ?xml: :text | :attr | nil,
864
+ ?cr_newline: bool,
865
+ ?crlf_newline: bool,
866
+ ?universal_newline: bool
867
+ ) -> File
868
+ | [T] (
869
+ ?string | int mode,
870
+ ?int perm,
871
+ # open options
872
+ ?mode: Integer | String,
873
+ ?flags: Integer,
874
+ ?external_encoding: encoding,
875
+ ?internal_encoding: encoding,
876
+ ?encoding: encoding,
877
+ ?textmode: boolish,
878
+ ?binmode: boolish,
879
+ ?autoclose: boolish,
880
+ ?path: path,
881
+ # encoding options
882
+ ?invalid: :replace | nil,
883
+ ?undef: :replace | nil,
884
+ ?replace: String | nil,
885
+ ?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
886
+ ?xml: :text | :attr | nil,
887
+ ?cr_newline: bool,
888
+ ?crlf_newline: bool,
889
+ ?universal_newline: bool
890
+ ) { (File) -> T } -> T
891
+
892
+ # <!--
893
+ # rdoc-file=pathname_builtin.rb
894
+ # - opendir() { |dir| ... }
895
+ # -->
896
+ # See <code>Dir.open</code>.
897
+ #
898
+ def opendir: () -> Dir
899
+ | [U] () { (Dir) -> U } -> U
900
+
901
+ # <!--
902
+ # rdoc-file=pathname_builtin.rb
903
+ # - owned?()
904
+ # -->
905
+ # See <code>FileTest.owned?</code>.
906
+ #
907
+ def owned?: () -> bool
908
+
909
+ # <!--
910
+ # rdoc-file=pathname_builtin.rb
911
+ # - parent()
912
+ # -->
913
+ # Returns the parent directory.
914
+ #
915
+ # This is same as <code>self + '..'</code>.
916
+ #
917
+ def parent: () -> Pathname
918
+
919
+ # <!--
920
+ # rdoc-file=pathname_builtin.rb
921
+ # - pipe?()
922
+ # -->
923
+ # See <code>FileTest.pipe?</code>.
924
+ #
925
+ def pipe?: () -> bool
926
+
927
+ # <!--
928
+ # rdoc-file=pathname_builtin.rb
929
+ # - read(...)
930
+ # -->
931
+ # See <code>File.read</code>. Returns all data from the file, or the first `N`
932
+ # bytes if specified.
933
+ #
934
+ def read: (?Integer length, ?Integer offset, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish) -> String
935
+
936
+ # <!--
937
+ # rdoc-file=pathname_builtin.rb
938
+ # - readable?()
939
+ # -->
940
+ # See <code>FileTest.readable?</code>.
941
+ #
942
+ def readable?: () -> bool
943
+
944
+ # <!--
945
+ # rdoc-file=pathname_builtin.rb
946
+ # - readable_real?()
947
+ # -->
948
+ # See <code>FileTest.readable_real?</code>.
949
+ #
950
+ def readable_real?: () -> bool
951
+
952
+ # <!--
953
+ # rdoc-file=pathname_builtin.rb
954
+ # - readlines(...)
955
+ # -->
956
+ # See <code>File.readlines</code>. Returns all the lines from the file.
957
+ #
958
+ def readlines: (?String sep, ?Integer limit, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?chomp: boolish) -> Array[String]
959
+ | (Integer limit, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?chomp: boolish) -> Array[String]
960
+
961
+ # <!--
962
+ # rdoc-file=pathname_builtin.rb
963
+ # - readlink()
964
+ # -->
965
+ # See <code>File.readlink</code>. Read symbolic link.
966
+ #
967
+ def readlink: () -> untyped
968
+
969
+ # <!--
970
+ # rdoc-file=pathname_builtin.rb
971
+ # - realdirpath(...)
972
+ # -->
973
+ # Returns the real (absolute) pathname of `self` in the actual filesystem.
974
+ #
975
+ # Does not contain symlinks or useless dots, <code>..</code> and <code>.</code>.
976
+ #
977
+ # The last component of the real pathname can be nonexistent.
978
+ #
979
+ def realdirpath: (?string | Pathname base_dir) -> Pathname
980
+
981
+ # <!--
982
+ # rdoc-file=pathname_builtin.rb
983
+ # - realpath(...)
984
+ # -->
985
+ # Returns the real (absolute) pathname for `self` in the actual filesystem.
986
+ #
987
+ # Does not contain symlinks or useless dots, <code>..</code> and <code>.</code>.
988
+ #
989
+ # All components of the pathname must exist when this method is called.
990
+ #
991
+ def realpath: (?string | Pathname base_dir) -> Pathname
992
+
993
+ # <!--
994
+ # rdoc-file=pathname_builtin.rb
995
+ # - relative?()
996
+ # -->
997
+ # The opposite of Pathname#absolute?
998
+ #
999
+ # It returns `false` if the pathname begins with a slash.
1000
+ #
1001
+ # p = Pathname.new('/im/sure')
1002
+ # p.relative?
1003
+ # #=> false
1004
+ #
1005
+ # p = Pathname.new('not/so/sure')
1006
+ # p.relative?
1007
+ # #=> true
1008
+ #
1009
+ def relative?: () -> bool
1010
+
1011
+ # <!--
1012
+ # rdoc-file=pathname_builtin.rb
1013
+ # - relative_path_from(base_directory)
1014
+ # -->
1015
+ # Returns a relative path from the given `base_directory` to the receiver.
1016
+ #
1017
+ # If `self` is absolute, then `base_directory` must be absolute too.
1018
+ #
1019
+ # If `self` is relative, then `base_directory` must be relative too.
1020
+ #
1021
+ # This method doesn't access the filesystem. It assumes no symlinks.
1022
+ #
1023
+ # ArgumentError is raised when it cannot find a relative path.
1024
+ #
1025
+ # Note that this method does not handle situations where the case sensitivity of
1026
+ # the filesystem in use differs from the operating system default.
1027
+ #
1028
+ def relative_path_from: (Pathname | string base_directory) -> Pathname
1029
+
1030
+ # <!--
1031
+ # rdoc-file=pathname_builtin.rb
1032
+ # - rename(to)
1033
+ # -->
1034
+ # See <code>File.rename</code>. Rename the file.
1035
+ #
1036
+ def rename: (Pathname | string new_name) -> 0
1037
+
1038
+ # <!--
1039
+ # rdoc-file=pathname_builtin.rb
1040
+ # - rmdir()
1041
+ # -->
1042
+ # See <code>Dir.rmdir</code>. Remove the referenced directory.
1043
+ #
1044
+ def rmdir: () -> 0
1045
+
1046
+ # <!--
1047
+ # rdoc-file=pathname_builtin.rb
1048
+ # - root?()
1049
+ # -->
1050
+ # Predicate method for root directories. Returns `true` if the pathname
1051
+ # consists of consecutive slashes.
1052
+ #
1053
+ # It doesn't access the filesystem. So it may return `false` for some pathnames
1054
+ # which points to roots such as <code>/usr/..</code>.
1055
+ #
1056
+ def root?: () -> bool
1057
+
1058
+ # <!--
1059
+ # rdoc-file=pathname_builtin.rb
1060
+ # - setgid?()
1061
+ # -->
1062
+ # See <code>FileTest.setgid?</code>.
1063
+ #
1064
+ def setgid?: () -> bool
1065
+
1066
+ # <!--
1067
+ # rdoc-file=pathname_builtin.rb
1068
+ # - setuid?()
1069
+ # -->
1070
+ # See <code>FileTest.setuid?</code>.
1071
+ #
1072
+ def setuid?: () -> bool
1073
+
1074
+ # <!--
1075
+ # rdoc-file=pathname_builtin.rb
1076
+ # - size()
1077
+ # -->
1078
+ # See <code>FileTest.size</code>.
1079
+ #
1080
+ def size: () -> Integer
1081
+
1082
+ # <!--
1083
+ # rdoc-file=pathname_builtin.rb
1084
+ # - size?()
1085
+ # -->
1086
+ # See <code>FileTest.size?</code>.
1087
+ #
1088
+ def size?: () -> Integer?
1089
+
1090
+ # <!--
1091
+ # rdoc-file=pathname_builtin.rb
1092
+ # - socket?()
1093
+ # -->
1094
+ # See <code>FileTest.socket?</code>.
1095
+ #
1096
+ def socket?: () -> untyped
1097
+
1098
+ # <!--
1099
+ # rdoc-file=pathname_builtin.rb
1100
+ # - split()
1101
+ # -->
1102
+ # See <code>File.split</code>. Returns the #dirname and the #basename in an
1103
+ # Array.
1104
+ #
1105
+ def split: () -> [ Pathname, Pathname ]
1106
+
1107
+ # <!--
1108
+ # rdoc-file=pathname_builtin.rb
1109
+ # - stat()
1110
+ # -->
1111
+ # See <code>File.stat</code>. Returns a <code>File::Stat</code> object.
1112
+ #
1113
+ def stat: () -> File::Stat
1114
+
1115
+ # <!--
1116
+ # rdoc-file=pathname_builtin.rb
1117
+ # - sticky?()
1118
+ # -->
1119
+ # See <code>FileTest.sticky?</code>.
1120
+ #
1121
+ def sticky?: () -> untyped
1122
+
1123
+ # <!--
1124
+ # rdoc-file=pathname.c
1125
+ # - sub(*args)
1126
+ # -->
1127
+ # Return a pathname which is substituted by String#sub.
1128
+ #
1129
+ # path1 = Pathname.new('/usr/bin/perl')
1130
+ # path1.sub('perl', 'ruby')
1131
+ # #=> #<Pathname:/usr/bin/ruby>
1132
+ #
1133
+ def sub: (Regexp | string pattern, string | Hash[String, String] replacement) -> Pathname
1134
+ | (Regexp | string pattern) { (String match) -> string } -> Pathname
1135
+
1136
+ # <!--
1137
+ # rdoc-file=pathname_builtin.rb
1138
+ # - sub_ext(repl)
1139
+ # -->
1140
+ # Return a pathname with `repl` added as a suffix to the basename.
1141
+ #
1142
+ # If self has no extension part, `repl` is appended.
1143
+ #
1144
+ # Pathname.new('/usr/bin/shutdown').sub_ext('.rb')
1145
+ # #=> #<Pathname:/usr/bin/shutdown.rb>
1146
+ #
1147
+ def sub_ext: (string replacement) -> Pathname
1148
+
1149
+ # <!--
1150
+ # rdoc-file=pathname_builtin.rb
1151
+ # - symlink?()
1152
+ # -->
1153
+ # See <code>FileTest.symlink?</code>.
1154
+ #
1155
+ def symlink?: () -> untyped
1156
+
1157
+ # <!--
1158
+ # rdoc-file=pathname_builtin.rb
1159
+ # - sysopen(...)
1160
+ # -->
1161
+ # See <code>File.sysopen</code>.
1162
+ #
1163
+ def sysopen: (?String mode, ?Integer perm) -> Integer
1164
+
1165
+ # <!--
1166
+ # rdoc-file=ext/pathname/pathname.c
1167
+ # - pathname.taint -> obj
1168
+ # -->
1169
+ # Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
1170
+ #
1171
+ def taint: () -> Pathname
1172
+
1173
+ # <!-- rdoc-file=pathname_builtin.rb -->
1174
+ # to_path is implemented so Pathname objects are usable with File.open, etc.
1175
+ #
1176
+ def to_path: () -> String
1177
+
1178
+ # <!--
1179
+ # rdoc-file=pathname_builtin.rb
1180
+ # - to_s()
1181
+ # -->
1182
+ # Return the path as a String.
1183
+ #
1184
+ alias to_s to_path
1185
+
1186
+ # <!--
1187
+ # rdoc-file=pathname_builtin.rb
1188
+ # - truncate(length)
1189
+ # -->
1190
+ # See <code>File.truncate</code>. Truncate the file to `length` bytes.
1191
+ #
1192
+ def truncate: (Integer length) -> 0
1193
+
1194
+ # <!--
1195
+ # rdoc-file=pathname_builtin.rb
1196
+ # - unlink()
1197
+ # -->
1198
+ # Removes a file or directory, using <code>File.unlink</code> or
1199
+ # <code>Dir.unlink</code> as necessary.
1200
+ #
1201
+ def unlink: () -> Integer
1202
+
1203
+ # <!--
1204
+ # rdoc-file=ext/pathname/pathname.c
1205
+ # - pathname.untaint -> obj
1206
+ # -->
1207
+ # Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
1208
+ #
1209
+ def untaint: () -> Pathname
1210
+
1211
+ # <!--
1212
+ # rdoc-file=pathname_builtin.rb
1213
+ # - utime(atime, mtime)
1214
+ # -->
1215
+ # See <code>File.utime</code>. Update the access and modification times.
1216
+ #
1217
+ def utime: (Integer | Time atime, Integer | Time mtime) -> Integer
1218
+
1219
+ # <!--
1220
+ # rdoc-file=pathname_builtin.rb
1221
+ # - world_readable?()
1222
+ # -->
1223
+ # See <code>FileTest.world_readable?</code>.
1224
+ #
1225
+ def world_readable?: () -> (Integer | nil)
1226
+
1227
+ # <!--
1228
+ # rdoc-file=pathname_builtin.rb
1229
+ # - world_writable?()
1230
+ # -->
1231
+ # See <code>FileTest.world_writable?</code>.
1232
+ #
1233
+ def world_writable?: () -> (Integer | nil)
1234
+
1235
+ # <!--
1236
+ # rdoc-file=pathname_builtin.rb
1237
+ # - writable?()
1238
+ # -->
1239
+ # See <code>FileTest.writable?</code>.
1240
+ #
1241
+ def writable?: () -> bool
1242
+
1243
+ # <!--
1244
+ # rdoc-file=pathname_builtin.rb
1245
+ # - writable_real?()
1246
+ # -->
1247
+ # See <code>FileTest.writable_real?</code>.
1248
+ #
1249
+ def writable_real?: () -> bool
1250
+
1251
+ # <!--
1252
+ # rdoc-file=pathname_builtin.rb
1253
+ # - write(...)
1254
+ # -->
1255
+ # Writes `contents` to the file. See <code>File.write</code>.
1256
+ #
1257
+ def write: (String content, ?Integer offset, ?mode: Integer | String, ?flags: Integer, ?external_encoding: encoding, ?internal_encoding: encoding, ?encoding: encoding, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish) -> Integer
1258
+
1259
+ # <!--
1260
+ # rdoc-file=pathname_builtin.rb
1261
+ # - zero?()
1262
+ # -->
1263
+ # See <code>FileTest.zero?</code>.
1264
+ #
1265
+ def zero?: () -> bool
1266
+
1267
+ private
1268
+
1269
+ def add_trailing_separator: (untyped path) -> untyped
1270
+
1271
+ def chop_basename: (untyped path) -> untyped
1272
+
1273
+ def cleanpath_aggressive: () -> untyped
1274
+
1275
+ def cleanpath_conservative: () -> untyped
1276
+
1277
+ def del_trailing_separator: (untyped path) -> untyped
1278
+
1279
+ def has_trailing_separator?: (untyped path) -> untyped
1280
+
1281
+ # <!--
1282
+ # rdoc-file=pathname_builtin.rb
1283
+ # - new(path)
1284
+ # -->
1285
+ # Create a Pathname object from the given String (or String-like object). If
1286
+ # `path` contains a NUL character (<code>\0</code>), an ArgumentError is raised.
1287
+ #
1288
+ def initialize: (string | Pathname) -> void
1289
+
1290
+ def plus: (untyped path1, untyped path2) -> untyped
1291
+
1292
+ def prepend_prefix: (untyped prefix, untyped relpath) -> untyped
1293
+
1294
+ def split_names: (untyped path) -> untyped
1295
+
1296
+ SAME_PATHS: Proc
1297
+
1298
+ # <!-- rdoc-file=pathname_builtin.rb -->
1299
+ # Separator list string.
1300
+ #
1301
+ SEPARATOR_LIST: String
1302
+
1303
+ # <!-- rdoc-file=pathname_builtin.rb -->
1304
+ # Regexp that matches a separator.
1305
+ #
1306
+ SEPARATOR_PAT: Regexp
1307
+
1308
+ TO_PATH: Symbol
1309
+ end
1310
+
1311
+ %a{annotate:rdoc:skip}
1312
+ module Kernel
1313
+ private
1314
+
1315
+ # <!--
1316
+ # rdoc-file=pathname_builtin.rb
1317
+ # - Pathname(path)
1318
+ # -->
1319
+ # Creates a Pathname object.
1320
+ #
1321
+ def self?.Pathname: (string | Pathname) -> Pathname
1322
+ end