steep 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/exe/rbs +1 -1
  4. data/lib/steep/annotation_parser.rb +4 -4
  5. data/lib/steep/ast/buffer.rb +11 -7
  6. data/lib/steep/ast/builtin.rb +8 -0
  7. data/lib/steep/ast/types/factory.rb +55 -55
  8. data/lib/steep/drivers/check.rb +20 -4
  9. data/lib/steep/drivers/langserver.rb +6 -1
  10. data/lib/steep/drivers/vendor.rb +2 -2
  11. data/lib/steep/project/completion_provider.rb +5 -11
  12. data/lib/steep/project/dsl.rb +14 -0
  13. data/lib/steep/project/file.rb +42 -46
  14. data/lib/steep/project/hover_content.rb +11 -5
  15. data/lib/steep/project/options.rb +25 -3
  16. data/lib/steep/project/target.rb +10 -4
  17. data/lib/steep/signature/errors.rb +1 -1
  18. data/lib/steep/signature/validator.rb +8 -8
  19. data/lib/steep/source.rb +1 -1
  20. data/lib/steep/type_construction.rb +987 -711
  21. data/lib/steep/type_inference/constant_env.rb +1 -1
  22. data/lib/steep/type_inference/context.rb +7 -3
  23. data/lib/steep/type_inference/context_array.rb +111 -0
  24. data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
  25. data/lib/steep/type_inference/logic.rb +130 -0
  26. data/lib/steep/type_inference/type_env.rb +5 -69
  27. data/lib/steep/typing.rb +79 -22
  28. data/lib/steep/version.rb +1 -1
  29. data/lib/steep.rb +6 -1
  30. data/smoke/alias/Steepfile +1 -0
  31. data/smoke/and/Steepfile +1 -0
  32. data/smoke/array/Steepfile +1 -0
  33. data/smoke/array/b.rb +0 -2
  34. data/smoke/block/Steepfile +1 -0
  35. data/smoke/case/Steepfile +1 -0
  36. data/smoke/class/Steepfile +1 -0
  37. data/smoke/const/Steepfile +1 -0
  38. data/smoke/dstr/Steepfile +1 -0
  39. data/smoke/ensure/Steepfile +1 -0
  40. data/smoke/enumerator/Steepfile +1 -0
  41. data/smoke/extension/Steepfile +1 -0
  42. data/smoke/extension/c.rb +1 -0
  43. data/smoke/hash/Steepfile +1 -0
  44. data/smoke/hello/Steepfile +1 -0
  45. data/smoke/if/Steepfile +1 -0
  46. data/smoke/if/a.rb +1 -1
  47. data/smoke/implements/Steepfile +1 -0
  48. data/smoke/initialize/Steepfile +1 -0
  49. data/smoke/integer/Steepfile +1 -0
  50. data/smoke/interface/Steepfile +1 -0
  51. data/smoke/kwbegin/Steepfile +1 -0
  52. data/smoke/lambda/Steepfile +1 -0
  53. data/smoke/literal/Steepfile +1 -0
  54. data/smoke/map/Steepfile +1 -0
  55. data/smoke/method/Steepfile +1 -0
  56. data/smoke/module/Steepfile +1 -0
  57. data/smoke/regexp/Steepfile +1 -0
  58. data/smoke/regression/Steepfile +1 -0
  59. data/smoke/rescue/Steepfile +1 -0
  60. data/smoke/rescue/a.rb +1 -1
  61. data/smoke/self/Steepfile +1 -0
  62. data/smoke/skip/Steepfile +1 -0
  63. data/smoke/stdout/Steepfile +1 -0
  64. data/smoke/super/Steepfile +1 -0
  65. data/smoke/type_case/Steepfile +1 -0
  66. data/smoke/yield/Steepfile +1 -0
  67. data/steep.gemspec +1 -1
  68. data/vendor/ruby-signature/.gitignore +2 -2
  69. data/vendor/ruby-signature/README.md +2 -2
  70. data/vendor/ruby-signature/Rakefile +2 -2
  71. data/vendor/ruby-signature/bin/annotate-with-rdoc +14 -13
  72. data/vendor/ruby-signature/bin/console +1 -1
  73. data/vendor/ruby-signature/bin/sort +7 -6
  74. data/vendor/ruby-signature/bin/test_runner.rb +0 -1
  75. data/vendor/ruby-signature/docs/CONTRIBUTING.md +1 -1
  76. data/vendor/ruby-signature/docs/sigs.md +3 -3
  77. data/vendor/ruby-signature/docs/stdlib.md +1 -1
  78. data/vendor/ruby-signature/docs/syntax.md +9 -9
  79. data/vendor/ruby-signature/exe/rbs +5 -1
  80. data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +27 -0
  81. data/vendor/ruby-signature/lib/rbs/ast/comment.rb +27 -0
  82. data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +395 -0
  83. data/vendor/ruby-signature/lib/rbs/ast/members.rb +362 -0
  84. data/vendor/ruby-signature/lib/rbs/buffer.rb +50 -0
  85. data/vendor/ruby-signature/lib/rbs/builtin_names.rb +55 -0
  86. data/vendor/ruby-signature/lib/rbs/cli.rb +558 -0
  87. data/vendor/ruby-signature/lib/rbs/constant.rb +26 -0
  88. data/vendor/ruby-signature/lib/rbs/constant_table.rb +150 -0
  89. data/vendor/ruby-signature/lib/rbs/definition.rb +170 -0
  90. data/vendor/ruby-signature/lib/rbs/definition_builder.rb +919 -0
  91. data/vendor/ruby-signature/lib/rbs/environment.rb +281 -0
  92. data/vendor/ruby-signature/lib/rbs/environment_loader.rb +136 -0
  93. data/vendor/ruby-signature/lib/rbs/environment_walker.rb +124 -0
  94. data/vendor/ruby-signature/lib/rbs/errors.rb +187 -0
  95. data/vendor/ruby-signature/lib/rbs/location.rb +102 -0
  96. data/vendor/ruby-signature/lib/rbs/method_type.rb +123 -0
  97. data/vendor/ruby-signature/lib/rbs/namespace.rb +91 -0
  98. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.rb +21 -23
  99. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.y +18 -18
  100. data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +553 -0
  101. data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +587 -0
  102. data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +381 -0
  103. data/vendor/ruby-signature/lib/rbs/substitution.rb +46 -0
  104. data/vendor/ruby-signature/lib/rbs/test/errors.rb +61 -0
  105. data/vendor/ruby-signature/lib/rbs/test/hook.rb +294 -0
  106. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/test/setup.rb +7 -7
  107. data/vendor/ruby-signature/lib/rbs/test/spy.rb +325 -0
  108. data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +183 -0
  109. data/vendor/ruby-signature/lib/rbs/test/type_check.rb +254 -0
  110. data/vendor/ruby-signature/lib/rbs/test.rb +26 -0
  111. data/vendor/ruby-signature/lib/rbs/type_name.rb +70 -0
  112. data/vendor/ruby-signature/lib/rbs/types.rb +936 -0
  113. data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +138 -0
  114. data/vendor/ruby-signature/lib/rbs/vendorer.rb +47 -0
  115. data/vendor/ruby-signature/lib/rbs/version.rb +3 -0
  116. data/vendor/ruby-signature/lib/rbs/writer.rb +269 -0
  117. data/vendor/ruby-signature/lib/rbs.rb +64 -0
  118. data/vendor/ruby-signature/lib/ruby/signature.rb +4 -61
  119. data/vendor/ruby-signature/{ruby-signature.gemspec → rbs.gemspec} +4 -4
  120. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +58 -1
  121. data/vendor/ruby-signature/stdlib/base64/base64.rbs +69 -13
  122. data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +372 -0
  123. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +9 -0
  124. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +1 -7
  125. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +2 -1
  126. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +3 -2
  127. data/vendor/ruby-signature/stdlib/builtin/file.rbs +902 -302
  128. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +190 -68
  129. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +3 -6
  130. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +6 -4
  131. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +146 -120
  132. data/vendor/ruby-signature/stdlib/builtin/math.rbs +310 -7
  133. data/vendor/ruby-signature/stdlib/builtin/method.rbs +11 -8
  134. data/vendor/ruby-signature/stdlib/builtin/module.rbs +959 -103
  135. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +3 -0
  136. data/vendor/ruby-signature/stdlib/builtin/process.rbs +981 -108
  137. data/vendor/ruby-signature/stdlib/builtin/random.rbs +215 -41
  138. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +47 -0
  139. data/vendor/ruby-signature/stdlib/builtin/string.rbs +9 -2
  140. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +282 -11
  141. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +11 -13
  142. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +25 -29
  143. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +1 -1
  144. data/vendor/ruby-signature/stdlib/builtin/time.rbs +875 -567
  145. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +243 -44
  146. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +103 -109
  147. data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +62 -0
  148. data/vendor/ruby-signature/stdlib/csv/csv.rbs +773 -0
  149. data/vendor/ruby-signature/stdlib/erb/erb.rbs +375 -1
  150. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -4
  151. data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +247 -0
  152. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +1088 -16
  153. data/vendor/ruby-signature/stdlib/set/set.rbs +251 -27
  154. metadata +49 -44
  155. data/exe/ruby-signature +0 -3
  156. data/vendor/ruby-signature/exe/ruby-signature +0 -7
  157. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
  158. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
  159. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
  160. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
  161. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
  162. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
  163. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -555
  164. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
  165. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
  166. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
  167. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
  168. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
  169. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
  170. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
  171. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
  172. data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
  173. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
  174. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
  175. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -444
  176. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
  177. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
  178. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
  179. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
  180. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
  181. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -327
  182. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
  183. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
  184. data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
  185. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
  186. data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
  187. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
  188. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
  189. data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
  190. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
@@ -1,21 +1,1093 @@
1
+ # Pathname represents the name of a file or directory on the filesystem, but not
2
+ # the file itself.
3
+ #
4
+ # The pathname depends on the Operating System: Unix, Windows, etc. This library
5
+ # works with pathnames of local OS, however non-Unix pathnames are supported
6
+ # experimentally.
7
+ #
8
+ # A Pathname can be relative or absolute. It's not until you try to reference
9
+ # the file that it even matters whether the file exists or not.
10
+ #
11
+ # Pathname is immutable. It has no method for destructive update.
12
+ #
13
+ # The goal of this class is to manipulate file path information in a neater way
14
+ # than standard Ruby provides. The examples below demonstrate the difference.
15
+ #
16
+ # **All** functionality from File, FileTest, and some from Dir and FileUtils is
17
+ # included, in an unsurprising way. It is essentially a facade for all of
18
+ # these, and more.
19
+ #
20
+ # ## Examples
21
+ #
22
+ # ### Example 1: Using Pathname
23
+ #
24
+ # require 'pathname'
25
+ # pn = Pathname.new("/usr/bin/ruby")
26
+ # size = pn.size # 27662
27
+ # isdir = pn.directory? # false
28
+ # dir = pn.dirname # Pathname:/usr/bin
29
+ # base = pn.basename # Pathname:ruby
30
+ # dir, base = pn.split # [Pathname:/usr/bin, Pathname:ruby]
31
+ # data = pn.read
32
+ # pn.open { |f| _ }
33
+ # pn.each_line { |line| _ }
34
+ #
35
+ # ### Example 2: Using standard Ruby
36
+ #
37
+ # pn = "/usr/bin/ruby"
38
+ # size = File.size(pn) # 27662
39
+ # isdir = File.directory?(pn) # false
40
+ # dir = File.dirname(pn) # "/usr/bin"
41
+ # base = File.basename(pn) # "ruby"
42
+ # dir, base = File.split(pn) # ["/usr/bin", "ruby"]
43
+ # data = File.read(pn)
44
+ # File.open(pn) { |f| _ }
45
+ # File.foreach(pn) { |line| _ }
46
+ #
47
+ # ### Example 3: Special features
48
+ #
49
+ # p1 = Pathname.new("/usr/lib") # Pathname:/usr/lib
50
+ # p2 = p1 + "ruby/1.8" # Pathname:/usr/lib/ruby/1.8
51
+ # p3 = p1.parent # Pathname:/usr
52
+ # p4 = p2.relative_path_from(p3) # Pathname:lib/ruby/1.8
53
+ # pwd = Pathname.pwd # Pathname:/home/gavin
54
+ # pwd.absolute? # true
55
+ # p5 = Pathname.new "." # Pathname:.
56
+ # p5 = p5 + "music/../articles" # Pathname:music/../articles
57
+ # p5.cleanpath # Pathname:articles
58
+ # p5.realpath # Pathname:/home/gavin/articles
59
+ # p5.children # [Pathname:/home/gavin/articles/linux, ...]
60
+ #
61
+ # ## Breakdown of functionality
62
+ #
63
+ # ### Core methods
64
+ #
65
+ # These methods are effectively manipulating a String, because that's all a path
66
+ # is. None of these access the file system except for #mountpoint?, #children,
67
+ # #each_child, #realdirpath and #realpath.
68
+ #
69
+ # * +
70
+ # * #join
71
+ # * #parent
72
+ # * #root?
73
+ # * #absolute?
74
+ # * #relative?
75
+ # * #relative_path_from
76
+ # * #each_filename
77
+ # * #cleanpath
78
+ # * #realpath
79
+ # * #realdirpath
80
+ # * #children
81
+ # * #each_child
82
+ # * #mountpoint?
83
+ #
84
+ #
85
+ # ### File status predicate methods
86
+ #
87
+ # These methods are a facade for FileTest:
88
+ # * #blockdev?
89
+ # * #chardev?
90
+ # * #directory?
91
+ # * #executable?
92
+ # * #executable_real?
93
+ # * #exist?
94
+ # * #file?
95
+ # * #grpowned?
96
+ # * #owned?
97
+ # * #pipe?
98
+ # * #readable?
99
+ # * #world_readable?
100
+ # * #readable_real?
101
+ # * #setgid?
102
+ # * #setuid?
103
+ # * #size
104
+ # * #size?
105
+ # * #socket?
106
+ # * #sticky?
107
+ # * #symlink?
108
+ # * #writable?
109
+ # * #world_writable?
110
+ # * #writable_real?
111
+ # * #zero?
112
+ #
113
+ #
114
+ # ### File property and manipulation methods
115
+ #
116
+ # These methods are a facade for File:
117
+ # * #atime
118
+ # * #birthtime
119
+ # * #ctime
120
+ # * #mtime
121
+ # * #chmod(mode)
122
+ # * #lchmod(mode)
123
+ # * #chown(owner, group)
124
+ # * #lchown(owner, group)
125
+ # * #fnmatch(pattern, *args)
126
+ # * #fnmatch?(pattern, *args)
127
+ # * #ftype
128
+ # * #make_link(old)
129
+ # * #open(*args, &block)
130
+ # * #readlink
131
+ # * #rename(to)
132
+ # * #stat
133
+ # * #lstat
134
+ # * #make_symlink(old)
135
+ # * #truncate(length)
136
+ # * #utime(atime, mtime)
137
+ # * #basename(*args)
138
+ # * #dirname
139
+ # * #extname
140
+ # * #expand_path(*args)
141
+ # * #split
142
+ #
143
+ #
144
+ # ### Directory methods
145
+ #
146
+ # These methods are a facade for Dir:
147
+ # * Pathname.glob(*args)
148
+ # * Pathname.getwd / Pathname.pwd
149
+ # * #rmdir
150
+ # * #entries
151
+ # * #each_entry(&block)
152
+ # * #mkdir(*args)
153
+ # * #opendir(*args)
154
+ #
155
+ #
156
+ # ### IO
157
+ #
158
+ # These methods are a facade for IO:
159
+ # * #each_line(*args, &block)
160
+ # * #read(*args)
161
+ # * #binread(*args)
162
+ # * #readlines(*args)
163
+ # * #sysopen(*args)
164
+ #
165
+ #
166
+ # ### Utilities
167
+ #
168
+ # These methods are a mixture of Find, FileUtils, and others:
169
+ # * #find(&block)
170
+ # * #mkpath
171
+ # * #rmtree
172
+ # * #unlink / #delete
173
+ #
174
+ #
175
+ # ## Method documentation
176
+ #
177
+ # As the above section shows, most of the methods in Pathname are facades. The
178
+ # documentation for these methods generally just says, for instance, "See
179
+ # FileTest.writable?", as you should be familiar with the original method
180
+ # anyway, and its documentation (e.g. through `ri`) will contain more
181
+ # information. In some cases, a brief description will follow.
182
+ #
1
183
  class Pathname
2
- def self.glob: (Pathname, ?Integer) -> Array[Pathname]
3
- def `+`: (Pathname) -> Pathname
4
- | (String) -> Pathname
5
- def file?: -> bool
6
- def relative_path_from: (Pathname) -> Pathname
7
- def open: [X] (?String) { (IO) -> X } -> X
8
- def join: (String) -> self
9
- def realpath: -> self
10
- def directory?: -> bool
11
- def relative?: -> bool
12
- def cleanpath: -> self
13
- def read: -> String
14
- def mkpath: -> void
15
- def write: (String) -> void
16
- def sub_ext: (String) -> self
184
+ # Returns the current working directory as a Pathname.
185
+ #
186
+ # Pathname.getwd
187
+ # #=> #<Pathname:/home/zzak/projects/ruby>
188
+ #
189
+ # See Dir.getwd.
190
+ #
191
+ def self.getwd: () -> Pathname
192
+
193
+ # Returns or yields Pathname objects.
194
+ #
195
+ # Pathname.glob("lib/i*.rb")
196
+ # #=> [#<Pathname:lib/ipaddr.rb>, #<Pathname:lib/irb.rb>]
197
+ #
198
+ # See Dir.glob.
199
+ #
200
+ def self.glob: (String | Array[String] pattern, ?Integer flags) -> Array[Pathname]
201
+ | (String | Array[String] pattern, ?Integer flags) { (Pathname) -> untyped } -> nil
202
+
203
+ # Returns the current working directory as a Pathname.
204
+ #
205
+ # Pathname.getwd
206
+ # #=> #<Pathname:/home/zzak/projects/ruby>
207
+ #
208
+ # See Dir.getwd.
209
+ #
210
+ def self.pwd: () -> Pathname
211
+
212
+ public
213
+
214
+ # Appends a pathname fragment to `self` to produce a new Pathname object.
215
+ #
216
+ # p1 = Pathname.new("/usr") # Pathname:/usr
217
+ # p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
218
+ # p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
219
+ #
220
+ # # / is aliased to +.
221
+ # p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby
222
+ # p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd
223
+ #
224
+ # This method doesn't access the file system; it is pure string manipulation.
225
+ #
226
+ def +: (Pathname | String | _ToStr other) -> Pathname
227
+
228
+ alias / +
229
+
230
+ # Provides a case-sensitive comparison operator for pathnames.
231
+ #
232
+ # Pathname.new('/usr') <=> Pathname.new('/usr/bin')
233
+ # #=> -1
234
+ # Pathname.new('/usr/bin') <=> Pathname.new('/usr/bin')
235
+ # #=> 0
236
+ # Pathname.new('/usr/bin') <=> Pathname.new('/USR/BIN')
237
+ # #=> 1
238
+ #
239
+ # It will return `-1`, `0` or `1` depending on the value of the left argument
240
+ # relative to the right argument. Or it will return `nil` if the arguments are
241
+ # not comparable.
242
+ #
243
+ def <=>: (untyped other) -> Integer?
244
+
245
+ # Compare this pathname with `other`. The comparison is string-based. Be aware
246
+ # that two different paths (`foo.txt` and `./foo.txt`) can refer to the same
247
+ # file.
248
+ #
249
+ def ==: (untyped) -> bool
250
+
251
+ # Compare this pathname with `other`. The comparison is string-based. Be aware
252
+ # that two different paths (`foo.txt` and `./foo.txt`) can refer to the same
253
+ # file.
254
+ #
255
+ def ===: (untyped) -> bool
256
+
257
+ # Predicate method for testing whether a path is absolute.
258
+ #
259
+ # It returns `true` if the pathname begins with a slash.
260
+ #
261
+ # p = Pathname.new('/im/sure')
262
+ # p.absolute?
263
+ # #=> true
264
+ #
265
+ # p = Pathname.new('not/so/sure')
266
+ # p.absolute?
267
+ # #=> false
268
+ #
269
+ def absolute?: () -> bool
270
+
271
+ # Iterates over and yields a new Pathname object for each element in the given
272
+ # path in ascending order.
273
+ #
274
+ # Pathname.new('/path/to/some/file.rb').ascend {|v| p v}
275
+ # #<Pathname:/path/to/some/file.rb>
276
+ # #<Pathname:/path/to/some>
277
+ # #<Pathname:/path/to>
278
+ # #<Pathname:/path>
279
+ # #<Pathname:/>
280
+ #
281
+ # Pathname.new('path/to/some/file.rb').ascend {|v| p v}
282
+ # #<Pathname:path/to/some/file.rb>
283
+ # #<Pathname:path/to/some>
284
+ # #<Pathname:path/to>
285
+ # #<Pathname:path>
286
+ #
287
+ # Returns an Enumerator if no block was given.
288
+ #
289
+ # enum = Pathname.new("/usr/bin/ruby").ascend
290
+ # # ... do stuff ...
291
+ # enum.each { |e| ... }
292
+ # # yields Pathnames /usr/bin/ruby, /usr/bin, /usr, and /.
293
+ #
294
+ # It doesn't access the filesystem.
295
+ #
296
+ def ascend: () { (Pathname) -> untyped } -> nil
297
+ | () -> Enumerator[Pathname, nil]
298
+
299
+ # Returns the last access time for the file.
300
+ #
301
+ # See File.atime.
302
+ #
303
+ def atime: () -> Time
304
+
305
+ # Returns the last component of the path.
306
+ #
307
+ # See File.basename.
308
+ #
309
+ def basename: (?String | _ToStr suffix) -> Pathname
310
+
311
+ # Returns all the bytes from the file, or the first `N` if specified.
312
+ #
313
+ # See File.binread.
314
+ #
315
+ def binread: (?Integer length, ?Integer offset) -> String
316
+
317
+ # Writes `contents` to the file, opening it in binary mode.
318
+ #
319
+ # See File.binwrite.
320
+ #
321
+ def binwrite: (String, ?Integer offset,
322
+ ?mode: Integer | String,
323
+ ?flags: Integer,
324
+ ?external_encoding: Encoding | string,
325
+ ?internal_encoding: Encoding | string,
326
+ ?encoding: Encoding | string,
327
+ ?textmode: bool,
328
+ ?binmode: bool,
329
+ ?autoclose: bool,
330
+
331
+ # From String#encode
332
+ ?invalid: :replace ?,
333
+ ?undef: :replace ?,
334
+ ?replace: String,
335
+ ?fallback: Hash[String, String] | Proc | Method,
336
+ ?xml: :text | :attr,
337
+ ?universal_newline: true,
338
+ ?cr_newline: true,
339
+ ?crlf_newline: true,
340
+ ) -> Integer
341
+
342
+ # Returns the birth time for the file. If the platform doesn't have birthtime,
343
+ # raises NotImplementedError.
344
+ #
345
+ # See File.birthtime.
346
+ #
347
+ def birthtime: () -> Time
348
+
349
+ # See FileTest.blockdev?.
350
+ #
351
+ def blockdev?: () -> bool
352
+
353
+ # See FileTest.chardev?.
354
+ #
355
+ def chardev?: () -> bool
356
+
357
+ # Returns the children of the directory (files and subdirectories, not
358
+ # recursive) as an array of Pathname objects.
359
+ #
360
+ # By default, the returned pathnames will have enough information to access the
361
+ # files. If you set `with_directory` to `false`, then the returned pathnames
362
+ # will contain the filename only.
363
+ #
364
+ # For example:
365
+ # pn = Pathname("/usr/lib/ruby/1.8")
366
+ # pn.children
367
+ # # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
368
+ # Pathname:/usr/lib/ruby/1.8/Env.rb,
369
+ # Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
370
+ # pn.children(false)
371
+ # # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
372
+ #
373
+ # Note that the results never contain the entries `.` and `..` in the directory
374
+ # because they are not children.
375
+ #
376
+ def children: (?bool with_directory) -> untyped
377
+
378
+ # Changes file permissions.
379
+ #
380
+ # See File.chmod.
381
+ #
382
+ def chmod: (Integer mode_int) -> Integer
383
+
384
+ # Change owner and group of the file.
385
+ #
386
+ # See File.chown.
387
+ #
388
+ def chown: (Integer owner, Integer group) -> Integer
389
+
390
+ # Returns clean pathname of `self` with consecutive slashes and useless dots
391
+ # removed. The filesystem is not accessed.
392
+ #
393
+ # If `consider_symlink` is `true`, then a more conservative algorithm is used to
394
+ # avoid breaking symbolic linkages. This may retain more `..` entries than
395
+ # absolutely necessary, but without accessing the filesystem, this can't be
396
+ # avoided.
397
+ #
398
+ # See Pathname#realpath.
399
+ #
400
+ def cleanpath: (?bool consider_symlink) -> Pathname
401
+
402
+ # Returns the last change time, using directory information, not the file
403
+ # itself.
404
+ #
405
+ # See File.ctime.
406
+ #
407
+ def ctime: () -> Time
408
+
409
+ # Removes a file or directory, using File.unlink if `self` is a file, or
410
+ # Dir.unlink as necessary.
411
+ #
412
+ def delete: () -> Integer
413
+
414
+ # Iterates over and yields a new Pathname object for each element in the given
415
+ # path in descending order.
416
+ #
417
+ # Pathname.new('/path/to/some/file.rb').descend {|v| p v}
418
+ # #<Pathname:/>
419
+ # #<Pathname:/path>
420
+ # #<Pathname:/path/to>
421
+ # #<Pathname:/path/to/some>
422
+ # #<Pathname:/path/to/some/file.rb>
423
+ #
424
+ # Pathname.new('path/to/some/file.rb').descend {|v| p v}
425
+ # #<Pathname:path>
426
+ # #<Pathname:path/to>
427
+ # #<Pathname:path/to/some>
428
+ # #<Pathname:path/to/some/file.rb>
429
+ #
430
+ # Returns an Enumerator if no block was given.
431
+ #
432
+ # enum = Pathname.new("/usr/bin/ruby").descend
433
+ # # ... do stuff ...
434
+ # enum.each { |e| ... }
435
+ # # yields Pathnames /, /usr, /usr/bin, and /usr/bin/ruby.
436
+ #
437
+ # It doesn't access the filesystem.
438
+ #
439
+ def descend: () { (Pathname) -> untyped } -> nil
440
+ | () -> Enumerator[Pathname, nil]
441
+
442
+ # See FileTest.directory?.
443
+ #
444
+ def directory?: () -> bool
445
+
446
+ # Returns all but the last component of the path.
447
+ #
448
+ # See File.dirname.
449
+ #
450
+ def dirname: () -> Pathname
451
+
452
+ # Iterates over the children of the directory (files and subdirectories, not
453
+ # recursive).
454
+ #
455
+ # It yields Pathname object for each child.
456
+ #
457
+ # By default, the yielded pathnames will have enough information to access the
458
+ # files.
459
+ #
460
+ # If you set `with_directory` to `false`, then the returned pathnames will
461
+ # contain the filename only.
462
+ #
463
+ # Pathname("/usr/local").each_child {|f| p f }
464
+ # #=> #<Pathname:/usr/local/share>
465
+ # # #<Pathname:/usr/local/bin>
466
+ # # #<Pathname:/usr/local/games>
467
+ # # #<Pathname:/usr/local/lib>
468
+ # # #<Pathname:/usr/local/include>
469
+ # # #<Pathname:/usr/local/sbin>
470
+ # # #<Pathname:/usr/local/src>
471
+ # # #<Pathname:/usr/local/man>
472
+ #
473
+ # Pathname("/usr/local").each_child(false) {|f| p f }
474
+ # #=> #<Pathname:share>
475
+ # # #<Pathname:bin>
476
+ # # #<Pathname:games>
477
+ # # #<Pathname:lib>
478
+ # # #<Pathname:include>
479
+ # # #<Pathname:sbin>
480
+ # # #<Pathname:src>
481
+ # # #<Pathname:man>
482
+ #
483
+ # Note that the results never contain the entries `.` and `..` in the directory
484
+ # because they are not children.
485
+ #
486
+ # See Pathname#children
487
+ #
488
+ def each_child: (?bool with_directory) { (Pathname) -> void } -> Array[Pathname]
489
+ | (?bool with_directory) -> Enumerator[Pathname, Array[Pathname]]
490
+
491
+ # Iterates over the entries (files and subdirectories) in the directory,
492
+ # yielding a Pathname object for each entry.
493
+ #
494
+ def each_entry: () { (Pathname) -> untyped } -> nil
495
+
496
+ # Iterates over each component of the path.
497
+ #
498
+ # Pathname.new("/usr/bin/ruby").each_filename {|filename| ... }
499
+ # # yields "usr", "bin", and "ruby".
500
+ #
501
+ # Returns an Enumerator if no block was given.
502
+ #
503
+ # enum = Pathname.new("/usr/bin/ruby").each_filename
504
+ # # ... do stuff ...
505
+ # enum.each { |e| ... }
506
+ # # yields "usr", "bin", and "ruby".
507
+ #
508
+ def each_filename: () { (String) -> untyped } -> nil
509
+ | () -> Enumerator[String, nil]
510
+
511
+ # Iterates over each line in the file and yields a String object for each.
512
+ #
513
+ def each_line: (?String sep, ?Integer limit,
514
+ # open_args
515
+ ?mode: Integer | String,
516
+ ?flags: Integer,
517
+ ?external_encoding: Encoding | string,
518
+ ?internal_encoding: Encoding | string,
519
+ ?encoding: Encoding | string,
520
+ ?textmode: bool,
521
+ ?binmode: bool,
522
+ ?autoclose: bool,
523
+ # getline_args
524
+ ?chomp: bool,
525
+ ) { (String) -> untyped } -> nil
526
+ | (Integer limit,
527
+ # open_args
528
+ ?mode: Integer | String,
529
+ ?flags: Integer,
530
+ ?external_encoding: Encoding | string,
531
+ ?internal_encoding: Encoding | string,
532
+ ?encoding: Encoding | string,
533
+ ?textmode: bool,
534
+ ?binmode: bool,
535
+ ?autoclose: bool,
536
+ # getline_args
537
+ ?chomp: bool,
538
+ ) { (String) -> untyped } -> nil
539
+ | (?String sep, ?Integer limit,
540
+ # open_args
541
+ ?mode: Integer | String,
542
+ ?flags: Integer,
543
+ ?external_encoding: Encoding | string,
544
+ ?internal_encoding: Encoding | string,
545
+ ?encoding: Encoding | string,
546
+ ?textmode: bool,
547
+ ?binmode: bool,
548
+ ?autoclose: bool,
549
+ # getline_args
550
+ ?chomp: bool,
551
+ ) -> Enumerator[String, nil]
552
+ | (Integer limit,
553
+ # open_args
554
+ ?mode: Integer | String,
555
+ ?flags: Integer,
556
+ ?external_encoding: Encoding | string,
557
+ ?internal_encoding: Encoding | string,
558
+ ?encoding: Encoding | string,
559
+ ?textmode: bool,
560
+ ?binmode: bool,
561
+ ?autoclose: bool,
562
+ # getline_args
563
+ ?chomp: bool,
564
+ ) -> Enumerator[String, nil]
565
+
566
+ # Tests the file is empty.
567
+ #
568
+ # See Dir#empty? and FileTest.empty?.
569
+ #
570
+ def empty?: () -> bool
571
+
572
+ # Return the entries (files and subdirectories) in the directory, each as a
573
+ # Pathname object.
574
+ #
575
+ # The results contains just the names in the directory, without any trailing
576
+ # slashes or recursive look-up.
577
+ #
578
+ # pp Pathname.new('/usr/local').entries
579
+ # #=> [#<Pathname:share>,
580
+ # # #<Pathname:lib>,
581
+ # # #<Pathname:..>,
582
+ # # #<Pathname:include>,
583
+ # # #<Pathname:etc>,
584
+ # # #<Pathname:bin>,
585
+ # # #<Pathname:man>,
586
+ # # #<Pathname:games>,
587
+ # # #<Pathname:.>,
588
+ # # #<Pathname:sbin>,
589
+ # # #<Pathname:src>]
590
+ #
591
+ # The result may contain the current directory `#<Pathname:.>` and the parent
592
+ # directory `#<Pathname:..>`.
593
+ #
594
+ # If you don't want `.` and `..` and want directories, consider
595
+ # Pathname#children.
596
+ #
597
+ def entries: () -> Array[Pathname]
598
+
599
+ # Compare this pathname with `other`. The comparison is string-based. Be aware
600
+ # that two different paths (`foo.txt` and `./foo.txt`) can refer to the same
601
+ # file.
602
+ #
603
+ def eql?: (untyped) -> bool
604
+
605
+ # See FileTest.executable?.
606
+ #
607
+ def executable?: () -> bool
608
+
609
+ # See FileTest.executable_real?.
610
+ #
611
+ def executable_real?: () -> bool
612
+
613
+ # See FileTest.exist?.
614
+ #
615
+ def exist?: () -> bool
616
+
617
+ # Returns the absolute path for the file.
618
+ #
619
+ # See File.expand_path.
620
+ #
621
+ def expand_path: (?String dir) -> Pathname
622
+
623
+ # Returns the file's extension.
624
+ #
625
+ # See File.extname.
626
+ #
627
+ def extname: () -> String
628
+
629
+ # See FileTest.file?.
630
+ #
631
+ def file?: () -> bool
632
+
633
+ # Iterates over the directory tree in a depth first manner, yielding a Pathname
634
+ # for each file under "this" directory.
635
+ #
636
+ # Returns an Enumerator if no block is given.
637
+ #
638
+ # Since it is implemented by the standard library module Find, Find.prune can be
639
+ # used to control the traversal.
640
+ #
641
+ # If `self` is `.`, yielded pathnames begin with a filename in the current
642
+ # directory, not `./`.
643
+ #
644
+ # See Find.find
645
+ #
646
+ def find: (?ignore_error: bool) { (Pathname) -> untyped } -> nil
647
+ | (?ignore_error: bool) -> Enumerator[Pathname, nil]
648
+
649
+ # Return `true` if the receiver matches the given pattern.
650
+ #
651
+ # See File.fnmatch.
652
+ #
653
+ def fnmatch: (String pattern, ?Integer flags) -> bool
654
+
655
+ # Return `true` if the receiver matches the given pattern.
656
+ #
657
+ # See File.fnmatch.
658
+ #
659
+ alias fnmatch? fnmatch
660
+
661
+ # Freezes this Pathname.
662
+ #
663
+ # See Object.freeze.
664
+ #
665
+ def freeze: () -> Pathname
666
+
667
+ # Returns "type" of file ("file", "directory", etc).
668
+ #
669
+ # See File.ftype.
670
+ #
671
+ def ftype: () -> String
672
+
673
+ # Returns or yields Pathname objects.
674
+ #
675
+ # Pathname("ruby-2.4.2").glob("R*.md")
676
+ # #=> [#<Pathname:ruby-2.4.2/README.md>, #<Pathname:ruby-2.4.2/README.ja.md>]
677
+ #
678
+ # See Dir.glob. This method uses the `base` keyword argument of Dir.glob.
679
+ #
680
+ def glob: (String | Array[String] pattern, ?Integer flags) -> Array[Pathname]
681
+ | (String | Array[String] pattern, ?Integer flags) { (Pathname) -> untyped } -> nil
682
+
683
+ # See FileTest.grpowned?.
684
+ #
685
+ def grpowned?: () -> bool
686
+
687
+ def hash: () -> Integer
688
+
689
+ def inspect: () -> String
690
+
691
+ # Joins the given pathnames onto `self` to create a new Pathname object.
692
+ #
693
+ # path0 = Pathname.new("/usr") # Pathname:/usr
694
+ # path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
695
+ # # is the same as
696
+ # path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
697
+ # path0 == path1
698
+ # #=> true
699
+ #
700
+ def join: (*String | _ToStr | Pathname args) -> Pathname
701
+
702
+ # Same as Pathname.chmod, but does not follow symbolic links.
703
+ #
704
+ # See File.lchmod.
705
+ #
706
+ def lchmod: (Integer mode) -> Integer
707
+
708
+ # Same as Pathname.chown, but does not follow symbolic links.
709
+ #
710
+ # See File.lchown.
711
+ #
712
+ def lchown: (Integer owner, Integer group) -> Integer
713
+
714
+ # See File.lstat.
715
+ #
716
+ def lstat: () -> ::File::Stat
717
+
718
+ # Creates a hard link at *pathname*.
719
+ #
720
+ # See File.link.
721
+ #
722
+ def make_link: (String | Pathname | _ToStr old) -> Integer
723
+
724
+ # Creates a symbolic link.
725
+ #
726
+ # See File.symlink.
727
+ #
728
+ def make_symlink: (String | Pathname | _ToStr old) -> Integer
729
+
730
+ # Create the referenced directory.
731
+ #
732
+ # See Dir.mkdir.
733
+ #
734
+ def mkdir: (?Integer perm) -> Integer
735
+
736
+ # Creates a full path, including any intermediate directories that don't yet
737
+ # exist.
738
+ #
739
+ # See FileUtils.mkpath and FileUtils.mkdir_p
740
+ #
741
+ def mkpath: () -> nil
742
+
743
+ # Returns `true` if `self` points to a mountpoint.
744
+ #
745
+ def mountpoint?: () -> bool
746
+
747
+ # Returns the last modified time of the file.
748
+ #
749
+ # See File.mtime.
750
+ #
751
+ def mtime: () -> Time
752
+
753
+ # Opens the file for reading or writing.
754
+ #
755
+ # See File.open.
756
+ #
757
+ def open: (?String mode, ?Integer perm) -> File
758
+ | [T] (?String mode, ?Integer perm) { (File) -> T } -> T
759
+
760
+ # Opens the referenced directory.
761
+ #
762
+ # See Dir.open.
763
+ #
764
+ def opendir: () -> Dir
765
+ | [U] () { (Dir) -> U } -> U
766
+
767
+ # See FileTest.owned?.
768
+ #
769
+ def owned?: () -> bool
770
+
771
+ # Returns the parent directory.
772
+ #
773
+ # This is same as `self + '..'`.
774
+ #
775
+ def parent: () -> Pathname
776
+
777
+ # See FileTest.pipe?.
778
+ #
779
+ def pipe?: () -> bool
780
+
781
+ # Returns all data from the file, or the first `N` bytes if specified.
782
+ #
783
+ # See File.read.
784
+ #
785
+ def read: (?Integer length, ?Integer offset,
786
+ # open_args
787
+ ?mode: Integer | String,
788
+ ?flags: Integer,
789
+ ?external_encoding: Encoding | string,
790
+ ?internal_encoding: Encoding | string,
791
+ ?encoding: Encoding | string,
792
+ ?textmode: bool,
793
+ ?binmode: bool,
794
+ ?autoclose: bool,
795
+ ) -> String
796
+
797
+ # See FileTest.readable?.
798
+ #
799
+ def readable?: () -> bool
800
+
801
+ # See FileTest.readable_real?.
802
+ #
803
+ def readable_real?: () -> bool
804
+
805
+ # Returns all the lines from the file.
806
+ #
807
+ # See File.readlines.
808
+ #
809
+ def readlines: (?String sep, ?Integer limit,
810
+ # open_args
811
+ ?mode: Integer | String,
812
+ ?flags: Integer,
813
+ ?external_encoding: Encoding | string,
814
+ ?internal_encoding: Encoding | string,
815
+ ?encoding: Encoding | string,
816
+ ?textmode: bool,
817
+ ?binmode: bool,
818
+ ?autoclose: bool,
819
+ # getline_args
820
+ ?chomp: bool,
821
+ ) -> Array[String]
822
+ | (Integer limit,
823
+ # open_args
824
+ ?mode: Integer | String,
825
+ ?flags: Integer,
826
+ ?external_encoding: Encoding | string,
827
+ ?internal_encoding: Encoding | string,
828
+ ?encoding: Encoding | string,
829
+ ?textmode: bool,
830
+ ?binmode: bool,
831
+ ?autoclose: bool,
832
+ # getline_args
833
+ ?chomp: bool,
834
+ ) -> Array[String]
835
+
836
+ # Read symbolic link.
837
+ #
838
+ # See File.readlink.
839
+ #
840
+ def readlink: () -> untyped
841
+
842
+ # Returns the real (absolute) pathname of `self` in the actual filesystem.
843
+ #
844
+ # Does not contain symlinks or useless dots, `..` and `.`.
845
+ #
846
+ # The last component of the real pathname can be nonexistent.
847
+ #
848
+ def realdirpath: (?string | Pathname base_dir) -> Pathname
849
+
850
+ # Returns the real (absolute) pathname for `self` in the actual filesystem.
851
+ #
852
+ # Does not contain symlinks or useless dots, `..` and `.`.
853
+ #
854
+ # All components of the pathname must exist when this method is called.
855
+ #
856
+ def realpath: (?string | Pathname base_dir) -> Pathname
857
+
858
+ # The opposite of Pathname#absolute?
859
+ #
860
+ # It returns `false` if the pathname begins with a slash.
861
+ #
862
+ # p = Pathname.new('/im/sure')
863
+ # p.relative?
864
+ # #=> false
865
+ #
866
+ # p = Pathname.new('not/so/sure')
867
+ # p.relative?
868
+ # #=> true
869
+ #
870
+ def relative?: () -> bool
871
+
872
+ # Returns a relative path from the given `base_directory` to the receiver.
873
+ #
874
+ # If `self` is absolute, then `base_directory` must be absolute too.
875
+ #
876
+ # If `self` is relative, then `base_directory` must be relative too.
877
+ #
878
+ # This method doesn't access the filesystem. It assumes no symlinks.
879
+ #
880
+ # ArgumentError is raised when it cannot find a relative path.
881
+ #
882
+ def relative_path_from: (Pathname | string base_directory) -> Pathname
883
+
884
+ # Rename the file.
885
+ #
886
+ # See File.rename.
887
+ #
888
+ def rename: (Pathname | string new_name) -> 0
889
+
890
+ # Remove the referenced directory.
891
+ #
892
+ # See Dir.rmdir.
893
+ #
894
+ def rmdir: () -> 0
895
+
896
+ # Recursively deletes a directory, including all directories beneath it.
897
+ #
898
+ # See FileUtils.rm_r
899
+ #
900
+ def rmtree: () -> void
901
+
902
+ # Predicate method for root directories. Returns `true` if the pathname
903
+ # consists of consecutive slashes.
904
+ #
905
+ # It doesn't access the filesystem. So it may return `false` for some pathnames
906
+ # which points to roots such as `/usr/..`.
907
+ #
908
+ def root?: () -> bool
909
+
910
+ # See FileTest.setgid?.
911
+ #
912
+ def setgid?: () -> bool
913
+
914
+ # See FileTest.setuid?.
915
+ #
916
+ def setuid?: () -> bool
917
+
918
+ # See FileTest.size.
919
+ #
920
+ def size: () -> Integer
921
+
922
+ # See FileTest.size?.
923
+ #
924
+ def size?: () -> Integer?
925
+
926
+ # See FileTest.socket?.
927
+ #
928
+ def socket?: () -> untyped
929
+
930
+ # Returns the #dirname and the #basename in an Array.
931
+ #
932
+ # See File.split.
933
+ #
934
+ def split: () -> [Pathname, Pathname]
935
+
936
+ # Returns a File::Stat object.
937
+ #
938
+ # See File.stat.
939
+ #
940
+ def stat: () -> File::Stat
941
+
942
+ # See FileTest.sticky?.
943
+ #
944
+ def sticky?: () -> untyped
945
+
946
+ # Return a pathname which is substituted by String#sub.
947
+ #
948
+ # path1 = Pathname.new('/usr/bin/perl')
949
+ # path1.sub('perl', 'ruby')
950
+ # #=> #<Pathname:/usr/bin/ruby>
951
+ #
952
+ def sub: (Regexp | string pattern, string | Hash[String, String] replacement) -> Pathname
953
+ | (Regexp | string pattern) { (String match) -> string } -> Pathname
954
+
955
+ # Return a pathname with `repl` added as a suffix to the basename.
956
+ #
957
+ # If self has no extension part, `repl` is appended.
958
+ #
959
+ # Pathname.new('/usr/bin/shutdown').sub_ext('.rb')
960
+ # #=> #<Pathname:/usr/bin/shutdown.rb>
961
+ #
962
+ def sub_ext: (string replacement) -> Pathname
963
+
964
+ # See FileTest.symlink?.
965
+ #
966
+ def symlink?: () -> untyped
967
+
968
+ # See IO.sysopen.
969
+ #
970
+ def sysopen: (?String mode, ?Integer perm) -> Integer
971
+
972
+ # Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
973
+ #
974
+ def taint: () -> Pathname
975
+
976
+ # Return the path as a String.
977
+ #
978
+ # to_path is implemented so Pathname objects are usable with File.open, etc.
979
+ #
980
+ def to_path: () -> String
981
+
982
+ # Return the path as a String.
983
+ #
984
+ # to_path is implemented so Pathname objects are usable with File.open, etc.
985
+ #
986
+ alias to_s to_path
987
+
988
+ # Truncates the file to `length` bytes.
989
+ #
990
+ # See File.truncate.
991
+ #
992
+ def truncate: (Integer length) -> 0
993
+
994
+ # Removes a file or directory, using File.unlink if `self` is a file, or
995
+ # Dir.unlink as necessary.
996
+ #
997
+ def unlink: () -> Integer
998
+
999
+ # Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
1000
+ #
1001
+ def untaint: () -> Pathname
1002
+
1003
+ # Update the access and modification times of the file.
1004
+ #
1005
+ # See File.utime.
1006
+ #
1007
+ def utime: (Integer | Time atime, Integer | Time mtime) -> Integer
1008
+
1009
+ # See FileTest.world_readable?.
1010
+ #
1011
+ def world_readable?: () -> (Integer | nil)
1012
+
1013
+ # See FileTest.world_writable?.
1014
+ #
1015
+ def world_writable?: () -> (Integer | nil)
1016
+
1017
+ # See FileTest.writable?.
1018
+ #
1019
+ def writable?: () -> bool
1020
+
1021
+ # See FileTest.writable_real?.
1022
+ #
1023
+ def writable_real?: () -> bool
1024
+
1025
+ # Writes `contents` to the file.
1026
+ #
1027
+ # See File.write.
1028
+ #
1029
+ def write: (String content, ?Integer offset,
1030
+ # open_args
1031
+ ?mode: Integer | String,
1032
+ ?flags: Integer,
1033
+ ?external_encoding: Encoding | string,
1034
+ ?internal_encoding: Encoding | string,
1035
+ ?encoding: Encoding | string,
1036
+ ?textmode: bool,
1037
+ ?binmode: bool,
1038
+ ?autoclose: bool,
1039
+ ) -> Integer
1040
+
1041
+ # See FileTest.zero?.
1042
+ #
1043
+ def zero?: () -> bool
1044
+
1045
+ private
1046
+
1047
+ def add_trailing_separator: (untyped path) -> untyped
1048
+
1049
+ def chop_basename: (untyped path) -> untyped
1050
+
1051
+ def cleanpath_aggressive: () -> untyped
1052
+
1053
+ def cleanpath_conservative: () -> untyped
1054
+
1055
+ def del_trailing_separator: (untyped path) -> untyped
1056
+
1057
+ def has_trailing_separator?: (untyped path) -> untyped
1058
+
1059
+ # Create a Pathname object from the given String (or String-like object). If
1060
+ # `path` contains a NULL character (`\0`), an ArgumentError is raised.
1061
+ #
1062
+ def initialize: (string | Pathname) -> void
1063
+
1064
+ def plus: (untyped path1, untyped path2) -> untyped
1065
+
1066
+ def prepend_prefix: (untyped prefix, untyped relpath) -> untyped
1067
+
1068
+ def split_names: (untyped path) -> untyped
17
1069
  end
18
1070
 
1071
+ Pathname::SAME_PATHS: Proc
1072
+
1073
+ Pathname::SEPARATOR_LIST: String
1074
+
1075
+ Pathname::SEPARATOR_PAT: Regexp
1076
+
1077
+ Pathname::TO_PATH: Symbol
1078
+
19
1079
  extension Kernel (Pathname)
20
- def Pathname: (String) -> Pathname
1080
+ # Creates a new Pathname object from the given string, `path`, and returns
1081
+ # pathname object.
1082
+ #
1083
+ # In order to use this constructor, you must first require the Pathname standard
1084
+ # library extension.
1085
+ #
1086
+ # require 'pathname'
1087
+ # Pathname("/home/zzak")
1088
+ # #=> #<Pathname:/home/zzak>
1089
+ #
1090
+ # See also Pathname::new for more information.
1091
+ #
1092
+ def Pathname: (String | Pathname) -> Pathname
21
1093
  end