rbs 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +15 -0
- data/BSDL +22 -0
- data/CHANGELOG.md +9 -0
- data/COPYING +56 -0
- data/Gemfile +6 -0
- data/README.md +93 -0
- data/Rakefile +142 -0
- data/bin/annotate-with-rdoc +157 -0
- data/bin/console +14 -0
- data/bin/query-rdoc +103 -0
- data/bin/setup +10 -0
- data/bin/sort +89 -0
- data/bin/test_runner.rb +16 -0
- data/docs/CONTRIBUTING.md +97 -0
- data/docs/sigs.md +148 -0
- data/docs/stdlib.md +152 -0
- data/docs/syntax.md +528 -0
- data/exe/rbs +7 -0
- data/lib/rbs.rb +64 -0
- data/lib/rbs/ast/annotation.rb +27 -0
- data/lib/rbs/ast/comment.rb +27 -0
- data/lib/rbs/ast/declarations.rb +395 -0
- data/lib/rbs/ast/members.rb +362 -0
- data/lib/rbs/buffer.rb +50 -0
- data/lib/rbs/builtin_names.rb +55 -0
- data/lib/rbs/cli.rb +558 -0
- data/lib/rbs/constant.rb +26 -0
- data/lib/rbs/constant_table.rb +150 -0
- data/lib/rbs/definition.rb +170 -0
- data/lib/rbs/definition_builder.rb +919 -0
- data/lib/rbs/environment.rb +281 -0
- data/lib/rbs/environment_loader.rb +136 -0
- data/lib/rbs/environment_walker.rb +124 -0
- data/lib/rbs/errors.rb +187 -0
- data/lib/rbs/location.rb +102 -0
- data/lib/rbs/method_type.rb +123 -0
- data/lib/rbs/namespace.rb +91 -0
- data/lib/rbs/parser.y +1344 -0
- data/lib/rbs/prototype/rb.rb +553 -0
- data/lib/rbs/prototype/rbi.rb +587 -0
- data/lib/rbs/prototype/runtime.rb +381 -0
- data/lib/rbs/substitution.rb +46 -0
- data/lib/rbs/test.rb +26 -0
- data/lib/rbs/test/errors.rb +61 -0
- data/lib/rbs/test/hook.rb +294 -0
- data/lib/rbs/test/setup.rb +58 -0
- data/lib/rbs/test/spy.rb +325 -0
- data/lib/rbs/test/test_helper.rb +183 -0
- data/lib/rbs/test/type_check.rb +254 -0
- data/lib/rbs/type_name.rb +70 -0
- data/lib/rbs/types.rb +936 -0
- data/lib/rbs/variance_calculator.rb +138 -0
- data/lib/rbs/vendorer.rb +47 -0
- data/lib/rbs/version.rb +3 -0
- data/lib/rbs/writer.rb +269 -0
- data/lib/ruby/signature.rb +7 -0
- data/rbs.gemspec +46 -0
- data/stdlib/abbrev/abbrev.rbs +60 -0
- data/stdlib/base64/base64.rbs +71 -0
- data/stdlib/benchmark/benchmark.rbs +372 -0
- data/stdlib/builtin/array.rbs +1997 -0
- data/stdlib/builtin/basic_object.rbs +280 -0
- data/stdlib/builtin/binding.rbs +177 -0
- data/stdlib/builtin/builtin.rbs +45 -0
- data/stdlib/builtin/class.rbs +145 -0
- data/stdlib/builtin/comparable.rbs +116 -0
- data/stdlib/builtin/complex.rbs +400 -0
- data/stdlib/builtin/constants.rbs +37 -0
- data/stdlib/builtin/data.rbs +5 -0
- data/stdlib/builtin/deprecated.rbs +2 -0
- data/stdlib/builtin/dir.rbs +413 -0
- data/stdlib/builtin/encoding.rbs +607 -0
- data/stdlib/builtin/enumerable.rbs +404 -0
- data/stdlib/builtin/enumerator.rbs +260 -0
- data/stdlib/builtin/errno.rbs +781 -0
- data/stdlib/builtin/errors.rbs +582 -0
- data/stdlib/builtin/exception.rbs +194 -0
- data/stdlib/builtin/false_class.rbs +40 -0
- data/stdlib/builtin/fiber.rbs +68 -0
- data/stdlib/builtin/fiber_error.rbs +12 -0
- data/stdlib/builtin/file.rbs +1076 -0
- data/stdlib/builtin/file_test.rbs +59 -0
- data/stdlib/builtin/float.rbs +696 -0
- data/stdlib/builtin/gc.rbs +243 -0
- data/stdlib/builtin/hash.rbs +1029 -0
- data/stdlib/builtin/integer.rbs +707 -0
- data/stdlib/builtin/io.rbs +683 -0
- data/stdlib/builtin/kernel.rbs +576 -0
- data/stdlib/builtin/marshal.rbs +161 -0
- data/stdlib/builtin/match_data.rbs +271 -0
- data/stdlib/builtin/math.rbs +369 -0
- data/stdlib/builtin/method.rbs +185 -0
- data/stdlib/builtin/module.rbs +1104 -0
- data/stdlib/builtin/nil_class.rbs +82 -0
- data/stdlib/builtin/numeric.rbs +409 -0
- data/stdlib/builtin/object.rbs +824 -0
- data/stdlib/builtin/proc.rbs +429 -0
- data/stdlib/builtin/process.rbs +1227 -0
- data/stdlib/builtin/random.rbs +267 -0
- data/stdlib/builtin/range.rbs +226 -0
- data/stdlib/builtin/rational.rbs +424 -0
- data/stdlib/builtin/rb_config.rbs +57 -0
- data/stdlib/builtin/regexp.rbs +1083 -0
- data/stdlib/builtin/ruby_vm.rbs +14 -0
- data/stdlib/builtin/signal.rbs +55 -0
- data/stdlib/builtin/string.rbs +1901 -0
- data/stdlib/builtin/string_io.rbs +284 -0
- data/stdlib/builtin/struct.rbs +40 -0
- data/stdlib/builtin/symbol.rbs +228 -0
- data/stdlib/builtin/thread.rbs +1108 -0
- data/stdlib/builtin/thread_group.rbs +23 -0
- data/stdlib/builtin/time.rbs +1047 -0
- data/stdlib/builtin/trace_point.rbs +290 -0
- data/stdlib/builtin/true_class.rbs +46 -0
- data/stdlib/builtin/unbound_method.rbs +153 -0
- data/stdlib/builtin/warning.rbs +17 -0
- data/stdlib/coverage/coverage.rbs +62 -0
- data/stdlib/csv/csv.rbs +773 -0
- data/stdlib/erb/erb.rbs +392 -0
- data/stdlib/find/find.rbs +40 -0
- data/stdlib/ipaddr/ipaddr.rbs +247 -0
- data/stdlib/json/json.rbs +335 -0
- data/stdlib/pathname/pathname.rbs +1093 -0
- data/stdlib/prime/integer-extension.rbs +23 -0
- data/stdlib/prime/prime.rbs +188 -0
- data/stdlib/securerandom/securerandom.rbs +9 -0
- data/stdlib/set/set.rbs +301 -0
- data/stdlib/tmpdir/tmpdir.rbs +53 -0
- metadata +292 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
::ARGF: Object
|
2
|
+
|
3
|
+
::ARGV: Array[String]
|
4
|
+
|
5
|
+
::CROSS_COMPILING: NilClass
|
6
|
+
|
7
|
+
::FALSE: FalseClass
|
8
|
+
|
9
|
+
::NIL: NilClass
|
10
|
+
|
11
|
+
::RUBY_COPYRIGHT: String
|
12
|
+
|
13
|
+
::RUBY_DESCRIPTION: String
|
14
|
+
|
15
|
+
::RUBY_ENGINE: String
|
16
|
+
|
17
|
+
::RUBY_ENGINE_VERSION: String
|
18
|
+
|
19
|
+
::RUBY_PATCHLEVEL: Integer
|
20
|
+
|
21
|
+
::RUBY_PLATFORM: String
|
22
|
+
|
23
|
+
::RUBY_RELEASE_DATE: String
|
24
|
+
|
25
|
+
::RUBY_REVISION: Integer
|
26
|
+
|
27
|
+
::RUBY_VERSION: String
|
28
|
+
|
29
|
+
::STDERR: IO
|
30
|
+
|
31
|
+
::STDIN: IO
|
32
|
+
|
33
|
+
::STDOUT: IO
|
34
|
+
|
35
|
+
::TOPLEVEL_BINDING: Binding
|
36
|
+
|
37
|
+
::TRUE: TrueClass
|
@@ -0,0 +1,413 @@
|
|
1
|
+
# Objects of class Dir are directory streams representing directories in the
|
2
|
+
# underlying file system. They provide a variety of ways to list directories and
|
3
|
+
# their contents. See also File.
|
4
|
+
#
|
5
|
+
# The directory used in these examples contains the two regular files
|
6
|
+
# (`config.h` and `main.rb`), the parent directory (`..`), and the directory
|
7
|
+
# itself (`.`).
|
8
|
+
#
|
9
|
+
class Dir
|
10
|
+
include Enumerable[String, Dir]
|
11
|
+
|
12
|
+
# Returns a new directory object for the named directory.
|
13
|
+
#
|
14
|
+
# The optional *encoding* keyword argument specifies the encoding of the
|
15
|
+
# directory. If not specified, the filesystem encoding is used.
|
16
|
+
#
|
17
|
+
def initialize: (string, ?encoding: encoding | nil) -> void
|
18
|
+
|
19
|
+
# Equivalent to calling `Dir.glob([string,...], 0)`.
|
20
|
+
#
|
21
|
+
def self.[]: (*string patterns, ?base: string) ?{ (String path) -> void } -> Array[String]
|
22
|
+
|
23
|
+
# Changes the current working directory of the process to the given string. When
|
24
|
+
# called without an argument, changes the directory to the value of the
|
25
|
+
# environment variable `HOME`, or `LOGDIR`. SystemCallError (probably
|
26
|
+
# Errno::ENOENT) if the target directory does not exist.
|
27
|
+
#
|
28
|
+
# If a block is given, it is passed the name of the new current directory, and
|
29
|
+
# the block is executed with that as the current directory. The original working
|
30
|
+
# directory is restored when the block exits. The return value of `chdir` is the
|
31
|
+
# value of the block. `chdir` blocks can be nested, but in a multi-threaded
|
32
|
+
# program an error will be raised if a thread attempts to open a `chdir` block
|
33
|
+
# while another thread has one open.
|
34
|
+
#
|
35
|
+
# Dir.chdir("/var/spool/mail")
|
36
|
+
# puts Dir.pwd
|
37
|
+
# Dir.chdir("/tmp") do
|
38
|
+
# puts Dir.pwd
|
39
|
+
# Dir.chdir("/usr") do
|
40
|
+
# puts Dir.pwd
|
41
|
+
# end
|
42
|
+
# puts Dir.pwd
|
43
|
+
# end
|
44
|
+
# puts Dir.pwd
|
45
|
+
#
|
46
|
+
# *produces:*
|
47
|
+
#
|
48
|
+
# /var/spool/mail
|
49
|
+
# /tmp
|
50
|
+
# /usr
|
51
|
+
# /tmp
|
52
|
+
# /var/spool/mail
|
53
|
+
#
|
54
|
+
def self.chdir: (?string) -> void
|
55
|
+
| [U] (?string) { (String) -> U } -> U
|
56
|
+
|
57
|
+
# Returns an array containing all of the filenames except for "." and ".." in
|
58
|
+
# the given directory. Will raise a SystemCallError if the named directory
|
59
|
+
# doesn't exist.
|
60
|
+
#
|
61
|
+
# The optional *encoding* keyword argument specifies the encoding of the
|
62
|
+
# directory. If not specified, the filesystem encoding is used.
|
63
|
+
#
|
64
|
+
# Dir.children("testdir") #=> ["config.h", "main.rb"]
|
65
|
+
#
|
66
|
+
def self.children: (string dirname, ?encoding: string | Encoding | nil enc) -> Array[String]
|
67
|
+
|
68
|
+
# Changes this process's idea of the file system root. Only a privileged process
|
69
|
+
# may make this call. Not available on all platforms. On Unix systems, see
|
70
|
+
# `chroot(2)` for more information.
|
71
|
+
#
|
72
|
+
def self.chroot: (string) -> void
|
73
|
+
|
74
|
+
# Deletes the named directory. Raises a subclass of SystemCallError if the
|
75
|
+
# directory isn't empty.
|
76
|
+
#
|
77
|
+
def self.delete: (string) -> void
|
78
|
+
|
79
|
+
# Calls the block once for each entry except for "." and ".." in the named
|
80
|
+
# directory, passing the filename of each entry as a parameter to the block.
|
81
|
+
#
|
82
|
+
# If no block is given, an enumerator is returned instead.
|
83
|
+
#
|
84
|
+
# Dir.each_child("testdir") {|x| puts "Got #{x}" }
|
85
|
+
#
|
86
|
+
# *produces:*
|
87
|
+
#
|
88
|
+
# Got config.h
|
89
|
+
# Got main.rb
|
90
|
+
#
|
91
|
+
def self.each_child: (string dirname, ?encoding: string | Encoding | nil enc) -> Enumerator[String, void]
|
92
|
+
| (string dirname, ?encoding: string | Encoding | nil enc) { (String filename) -> void } -> void
|
93
|
+
|
94
|
+
# Returns `true` if the named file is an empty directory, `false` if it is not a
|
95
|
+
# directory or non-empty.
|
96
|
+
#
|
97
|
+
def self.empty?: (string path_name) -> bool
|
98
|
+
|
99
|
+
# Returns an array containing all of the filenames in the given directory. Will
|
100
|
+
# raise a SystemCallError if the named directory doesn't exist.
|
101
|
+
#
|
102
|
+
# The optional *encoding* keyword argument specifies the encoding of the
|
103
|
+
# directory. If not specified, the filesystem encoding is used.
|
104
|
+
#
|
105
|
+
# Dir.entries("testdir") #=> [".", "..", "config.h", "main.rb"]
|
106
|
+
#
|
107
|
+
def self.entries: (string dirname, ?encoding: encoding | nil enc) -> ::Array[String]
|
108
|
+
|
109
|
+
# Returns `true` if the named file is a directory, `false` otherwise.
|
110
|
+
#
|
111
|
+
def self.exist?: (string file) -> bool
|
112
|
+
|
113
|
+
# Deprecated method. Don't use.
|
114
|
+
#
|
115
|
+
def self.exists?: (string file) -> bool
|
116
|
+
|
117
|
+
# Calls the block once for each entry in the named directory, passing the
|
118
|
+
# filename of each entry as a parameter to the block.
|
119
|
+
#
|
120
|
+
# If no block is given, an enumerator is returned instead.
|
121
|
+
#
|
122
|
+
# Dir.foreach("testdir") {|x| puts "Got #{x}" }
|
123
|
+
#
|
124
|
+
# *produces:*
|
125
|
+
#
|
126
|
+
# Got .
|
127
|
+
# Got ..
|
128
|
+
# Got config.h
|
129
|
+
# Got main.rb
|
130
|
+
#
|
131
|
+
alias self.foreach self.each_child
|
132
|
+
|
133
|
+
# Returns the path to the current working directory of this process as a string.
|
134
|
+
#
|
135
|
+
# Dir.chdir("/tmp") #=> 0
|
136
|
+
# Dir.getwd #=> "/tmp"
|
137
|
+
# Dir.pwd #=> "/tmp"
|
138
|
+
#
|
139
|
+
def self.getwd: () -> String
|
140
|
+
|
141
|
+
# Expands `pattern`, which is a pattern string or an Array of pattern strings,
|
142
|
+
# and returns an array containing the matching filenames. If a block is given,
|
143
|
+
# calls the block once for each matching filename, passing the filename as a
|
144
|
+
# parameter to the block.
|
145
|
+
#
|
146
|
+
# The optional `base` keyword argument specifies the base directory for
|
147
|
+
# interpreting relative pathnames instead of the current working directory. As
|
148
|
+
# the results are not prefixed with the base directory name in this case, you
|
149
|
+
# will need to prepend the base directory name if you want real paths.
|
150
|
+
#
|
151
|
+
# Note that the pattern is not a regexp, it's closer to a shell glob. See
|
152
|
+
# File::fnmatch for the meaning of the `flags` parameter. Case sensitivity
|
153
|
+
# depends on your system (File::FNM_CASEFOLD is ignored), as does the order in
|
154
|
+
# which the results are returned.
|
155
|
+
#
|
156
|
+
# `*`
|
157
|
+
# : Matches any file. Can be restricted by other values in the glob.
|
158
|
+
# Equivalent to `/ .* /mx` in regexp.
|
159
|
+
#
|
160
|
+
# `*`
|
161
|
+
# : Matches all files
|
162
|
+
# `c*`
|
163
|
+
# : Matches all files beginning with `c`
|
164
|
+
# `*c`
|
165
|
+
# : Matches all files ending with `c`
|
166
|
+
# `*c*`
|
167
|
+
# : Match all files that have `c` in them (including at the beginning or
|
168
|
+
# end).
|
169
|
+
#
|
170
|
+
#
|
171
|
+
# Note, this will not match Unix-like hidden files (dotfiles). In order to
|
172
|
+
# include those in the match results, you must use the File::FNM_DOTMATCH
|
173
|
+
# flag or something like `"{*,.*}"`.
|
174
|
+
#
|
175
|
+
# `**`
|
176
|
+
# : Matches directories recursively.
|
177
|
+
#
|
178
|
+
# `?`
|
179
|
+
# : Matches any one character. Equivalent to `/.{1}/` in regexp.
|
180
|
+
#
|
181
|
+
# `[set]`
|
182
|
+
# : Matches any one character in `set`. Behaves exactly like character sets
|
183
|
+
# in Regexp, including set negation (`[^a-z]`).
|
184
|
+
#
|
185
|
+
# `{p,q}`
|
186
|
+
# : Matches either literal `p` or literal `q`. Equivalent to pattern
|
187
|
+
# alternation in regexp.
|
188
|
+
#
|
189
|
+
# Matching literals may be more than one character in length. More than two
|
190
|
+
# literals may be specified.
|
191
|
+
#
|
192
|
+
# ` \\ `
|
193
|
+
# : Escapes the next metacharacter.
|
194
|
+
#
|
195
|
+
# Note that this means you cannot use backslash on windows as part of a
|
196
|
+
# glob, i.e. `Dir["c:\\foo*"]` will not work, use `Dir["c:/foo*"]` instead.
|
197
|
+
#
|
198
|
+
#
|
199
|
+
# Examples:
|
200
|
+
#
|
201
|
+
# Dir["config.?"] #=> ["config.h"]
|
202
|
+
# Dir.glob("config.?") #=> ["config.h"]
|
203
|
+
# Dir.glob("*.[a-z][a-z]") #=> ["main.rb"]
|
204
|
+
# Dir.glob("*.[^r]*") #=> ["config.h"]
|
205
|
+
# Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"]
|
206
|
+
# Dir.glob("*") #=> ["config.h", "main.rb"]
|
207
|
+
# Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"]
|
208
|
+
# Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"]
|
209
|
+
#
|
210
|
+
# rbfiles = File.join("**", "*.rb")
|
211
|
+
# Dir.glob(rbfiles) #=> ["main.rb",
|
212
|
+
# # "lib/song.rb",
|
213
|
+
# # "lib/song/karaoke.rb"]
|
214
|
+
#
|
215
|
+
# Dir.glob(rbfiles, base: "lib") #=> ["song.rb",
|
216
|
+
# # "song/karaoke.rb"]
|
217
|
+
#
|
218
|
+
# libdirs = File.join("**", "lib")
|
219
|
+
# Dir.glob(libdirs) #=> ["lib"]
|
220
|
+
#
|
221
|
+
# librbfiles = File.join("**", "lib", "**", "*.rb")
|
222
|
+
# Dir.glob(librbfiles) #=> ["lib/song.rb",
|
223
|
+
# # "lib/song/karaoke.rb"]
|
224
|
+
#
|
225
|
+
# librbfiles = File.join("**", "lib", "*.rb")
|
226
|
+
# Dir.glob(librbfiles) #=> ["lib/song.rb"]
|
227
|
+
#
|
228
|
+
def self.glob: (string | ::Array[string] pattern, ?Integer flags, ?base: string) -> ::Array[String]
|
229
|
+
| (string | ::Array[string] pattern, ?Integer flags, ?base: string) { (String) -> void } -> void
|
230
|
+
|
231
|
+
# Returns the home directory of the current user or the named user if given.
|
232
|
+
#
|
233
|
+
def self.home: (?string user) -> String
|
234
|
+
|
235
|
+
# Makes a new directory named by *string*, with permissions specified by the
|
236
|
+
# optional parameter *anInteger*. The permissions may be modified by the value
|
237
|
+
# of File::umask, and are ignored on NT. Raises a SystemCallError if the
|
238
|
+
# directory cannot be created. See also the discussion of permissions in the
|
239
|
+
# class documentation for File.
|
240
|
+
#
|
241
|
+
# Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0
|
242
|
+
#
|
243
|
+
def self.mkdir: (string, ?Integer permissions) -> void
|
244
|
+
|
245
|
+
# The optional *encoding* keyword argument specifies the encoding of the
|
246
|
+
# directory. If not specified, the filesystem encoding is used.
|
247
|
+
#
|
248
|
+
# With no block, `open` is a synonym for Dir::new. If a block is present, it is
|
249
|
+
# passed *aDir* as a parameter. The directory is closed at the end of the block,
|
250
|
+
# and Dir::open returns the value of the block.
|
251
|
+
#
|
252
|
+
def self.open: (string, ?encoding: encoding | nil) -> Dir
|
253
|
+
| [U] (string, ?encoding: encoding | nil) { (Dir) -> U } -> U
|
254
|
+
|
255
|
+
# Returns the path to the current working directory of this process as a string.
|
256
|
+
#
|
257
|
+
# Dir.chdir("/tmp") #=> 0
|
258
|
+
# Dir.getwd #=> "/tmp"
|
259
|
+
# Dir.pwd #=> "/tmp"
|
260
|
+
#
|
261
|
+
def self.pwd: () -> String
|
262
|
+
|
263
|
+
# Deletes the named directory. Raises a subclass of SystemCallError if the
|
264
|
+
# directory isn't empty.
|
265
|
+
#
|
266
|
+
alias self.rmdir self.delete
|
267
|
+
|
268
|
+
# Deletes the named directory. Raises a subclass of SystemCallError if the
|
269
|
+
# directory isn't empty.
|
270
|
+
#
|
271
|
+
alias self.unlink self.delete
|
272
|
+
|
273
|
+
public
|
274
|
+
|
275
|
+
# Returns an array containing all of the filenames except for "." and ".." in
|
276
|
+
# this directory.
|
277
|
+
#
|
278
|
+
# d = Dir.new("testdir")
|
279
|
+
# d.children #=> ["config.h", "main.rb"]
|
280
|
+
#
|
281
|
+
def children: () -> Array[String]
|
282
|
+
|
283
|
+
# Closes the directory stream. Calling this method on closed Dir object is
|
284
|
+
# ignored since Ruby 2.3.
|
285
|
+
#
|
286
|
+
# d = Dir.new("testdir")
|
287
|
+
# d.close #=> nil
|
288
|
+
#
|
289
|
+
def close: () -> void
|
290
|
+
|
291
|
+
# Calls the block once for each entry in this directory, passing the filename of
|
292
|
+
# each entry as a parameter to the block.
|
293
|
+
#
|
294
|
+
# If no block is given, an enumerator is returned instead.
|
295
|
+
#
|
296
|
+
# d = Dir.new("testdir")
|
297
|
+
# d.each {|x| puts "Got #{x}" }
|
298
|
+
#
|
299
|
+
# *produces:*
|
300
|
+
#
|
301
|
+
# Got .
|
302
|
+
# Got ..
|
303
|
+
# Got config.h
|
304
|
+
# Got main.rb
|
305
|
+
#
|
306
|
+
def each: () { (String) -> void } -> self
|
307
|
+
| () -> ::Enumerator[String, self]
|
308
|
+
|
309
|
+
# Calls the block once for each entry except for "." and ".." in this directory,
|
310
|
+
# passing the filename of each entry as a parameter to the block.
|
311
|
+
#
|
312
|
+
# If no block is given, an enumerator is returned instead.
|
313
|
+
#
|
314
|
+
# d = Dir.new("testdir")
|
315
|
+
# d.each_child {|x| puts "Got #{x}" }
|
316
|
+
#
|
317
|
+
# *produces:*
|
318
|
+
#
|
319
|
+
# Got config.h
|
320
|
+
# Got main.rb
|
321
|
+
#
|
322
|
+
def each_child: () { (String) -> void } -> self
|
323
|
+
| () -> ::Enumerator[String, self]
|
324
|
+
|
325
|
+
# Returns the file descriptor used in *dir*.
|
326
|
+
#
|
327
|
+
# d = Dir.new("..")
|
328
|
+
# d.fileno #=> 8
|
329
|
+
#
|
330
|
+
# This method uses dirfd() function defined by POSIX 2008. NotImplementedError
|
331
|
+
# is raised on other platforms, such as Windows, which doesn't provide the
|
332
|
+
# function.
|
333
|
+
#
|
334
|
+
def fileno: () -> Integer
|
335
|
+
|
336
|
+
# Return a string describing this Dir object.
|
337
|
+
#
|
338
|
+
def inspect: () -> String
|
339
|
+
|
340
|
+
# Returns the path parameter passed to *dir*'s constructor.
|
341
|
+
#
|
342
|
+
# d = Dir.new("..")
|
343
|
+
# d.path #=> ".."
|
344
|
+
#
|
345
|
+
def path: () -> String?
|
346
|
+
|
347
|
+
# Returns the current position in *dir*. See also Dir#seek.
|
348
|
+
#
|
349
|
+
# d = Dir.new("testdir")
|
350
|
+
# d.tell #=> 0
|
351
|
+
# d.read #=> "."
|
352
|
+
# d.tell #=> 12
|
353
|
+
#
|
354
|
+
def pos: () -> Integer
|
355
|
+
|
356
|
+
# Synonym for Dir#seek, but returns the position parameter.
|
357
|
+
#
|
358
|
+
# d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
|
359
|
+
# d.read #=> "."
|
360
|
+
# i = d.pos #=> 12
|
361
|
+
# d.read #=> ".."
|
362
|
+
# d.pos = i #=> 12
|
363
|
+
# d.read #=> ".."
|
364
|
+
#
|
365
|
+
def pos=: (Integer pos) -> Integer
|
366
|
+
|
367
|
+
# Reads the next entry from *dir* and returns it as a string. Returns `nil` at
|
368
|
+
# the end of the stream.
|
369
|
+
#
|
370
|
+
# d = Dir.new("testdir")
|
371
|
+
# d.read #=> "."
|
372
|
+
# d.read #=> ".."
|
373
|
+
# d.read #=> "config.h"
|
374
|
+
#
|
375
|
+
def read: () -> String?
|
376
|
+
|
377
|
+
# Repositions *dir* to the first entry.
|
378
|
+
#
|
379
|
+
# d = Dir.new("testdir")
|
380
|
+
# d.read #=> "."
|
381
|
+
# d.rewind #=> #<Dir:0x401b3fb0>
|
382
|
+
# d.read #=> "."
|
383
|
+
#
|
384
|
+
def rewind: () -> self
|
385
|
+
|
386
|
+
# Seeks to a particular location in *dir*. *integer* must be a value returned by
|
387
|
+
# Dir#tell.
|
388
|
+
#
|
389
|
+
# d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
|
390
|
+
# d.read #=> "."
|
391
|
+
# i = d.tell #=> 12
|
392
|
+
# d.read #=> ".."
|
393
|
+
# d.seek(i) #=> #<Dir:0x401b3c40>
|
394
|
+
# d.read #=> ".."
|
395
|
+
#
|
396
|
+
def seek: (Integer) -> self
|
397
|
+
|
398
|
+
# Returns the current position in *dir*. See also Dir#seek.
|
399
|
+
#
|
400
|
+
# d = Dir.new("testdir")
|
401
|
+
# d.tell #=> 0
|
402
|
+
# d.read #=> "."
|
403
|
+
# d.tell #=> 12
|
404
|
+
#
|
405
|
+
def tell: () -> Integer
|
406
|
+
|
407
|
+
# Returns the path parameter passed to *dir*'s constructor.
|
408
|
+
#
|
409
|
+
# d = Dir.new("..")
|
410
|
+
# d.path #=> ".."
|
411
|
+
#
|
412
|
+
alias to_path path
|
413
|
+
end
|