rbs 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +28 -0
  3. data/.gitignore +12 -0
  4. data/.rubocop.yml +15 -0
  5. data/BSDL +22 -0
  6. data/CHANGELOG.md +9 -0
  7. data/COPYING +56 -0
  8. data/Gemfile +6 -0
  9. data/README.md +93 -0
  10. data/Rakefile +142 -0
  11. data/bin/annotate-with-rdoc +157 -0
  12. data/bin/console +14 -0
  13. data/bin/query-rdoc +103 -0
  14. data/bin/setup +10 -0
  15. data/bin/sort +89 -0
  16. data/bin/test_runner.rb +16 -0
  17. data/docs/CONTRIBUTING.md +97 -0
  18. data/docs/sigs.md +148 -0
  19. data/docs/stdlib.md +152 -0
  20. data/docs/syntax.md +528 -0
  21. data/exe/rbs +7 -0
  22. data/lib/rbs.rb +64 -0
  23. data/lib/rbs/ast/annotation.rb +27 -0
  24. data/lib/rbs/ast/comment.rb +27 -0
  25. data/lib/rbs/ast/declarations.rb +395 -0
  26. data/lib/rbs/ast/members.rb +362 -0
  27. data/lib/rbs/buffer.rb +50 -0
  28. data/lib/rbs/builtin_names.rb +55 -0
  29. data/lib/rbs/cli.rb +558 -0
  30. data/lib/rbs/constant.rb +26 -0
  31. data/lib/rbs/constant_table.rb +150 -0
  32. data/lib/rbs/definition.rb +170 -0
  33. data/lib/rbs/definition_builder.rb +919 -0
  34. data/lib/rbs/environment.rb +281 -0
  35. data/lib/rbs/environment_loader.rb +136 -0
  36. data/lib/rbs/environment_walker.rb +124 -0
  37. data/lib/rbs/errors.rb +187 -0
  38. data/lib/rbs/location.rb +102 -0
  39. data/lib/rbs/method_type.rb +123 -0
  40. data/lib/rbs/namespace.rb +91 -0
  41. data/lib/rbs/parser.y +1344 -0
  42. data/lib/rbs/prototype/rb.rb +553 -0
  43. data/lib/rbs/prototype/rbi.rb +587 -0
  44. data/lib/rbs/prototype/runtime.rb +381 -0
  45. data/lib/rbs/substitution.rb +46 -0
  46. data/lib/rbs/test.rb +26 -0
  47. data/lib/rbs/test/errors.rb +61 -0
  48. data/lib/rbs/test/hook.rb +294 -0
  49. data/lib/rbs/test/setup.rb +58 -0
  50. data/lib/rbs/test/spy.rb +325 -0
  51. data/lib/rbs/test/test_helper.rb +183 -0
  52. data/lib/rbs/test/type_check.rb +254 -0
  53. data/lib/rbs/type_name.rb +70 -0
  54. data/lib/rbs/types.rb +936 -0
  55. data/lib/rbs/variance_calculator.rb +138 -0
  56. data/lib/rbs/vendorer.rb +47 -0
  57. data/lib/rbs/version.rb +3 -0
  58. data/lib/rbs/writer.rb +269 -0
  59. data/lib/ruby/signature.rb +7 -0
  60. data/rbs.gemspec +46 -0
  61. data/stdlib/abbrev/abbrev.rbs +60 -0
  62. data/stdlib/base64/base64.rbs +71 -0
  63. data/stdlib/benchmark/benchmark.rbs +372 -0
  64. data/stdlib/builtin/array.rbs +1997 -0
  65. data/stdlib/builtin/basic_object.rbs +280 -0
  66. data/stdlib/builtin/binding.rbs +177 -0
  67. data/stdlib/builtin/builtin.rbs +45 -0
  68. data/stdlib/builtin/class.rbs +145 -0
  69. data/stdlib/builtin/comparable.rbs +116 -0
  70. data/stdlib/builtin/complex.rbs +400 -0
  71. data/stdlib/builtin/constants.rbs +37 -0
  72. data/stdlib/builtin/data.rbs +5 -0
  73. data/stdlib/builtin/deprecated.rbs +2 -0
  74. data/stdlib/builtin/dir.rbs +413 -0
  75. data/stdlib/builtin/encoding.rbs +607 -0
  76. data/stdlib/builtin/enumerable.rbs +404 -0
  77. data/stdlib/builtin/enumerator.rbs +260 -0
  78. data/stdlib/builtin/errno.rbs +781 -0
  79. data/stdlib/builtin/errors.rbs +582 -0
  80. data/stdlib/builtin/exception.rbs +194 -0
  81. data/stdlib/builtin/false_class.rbs +40 -0
  82. data/stdlib/builtin/fiber.rbs +68 -0
  83. data/stdlib/builtin/fiber_error.rbs +12 -0
  84. data/stdlib/builtin/file.rbs +1076 -0
  85. data/stdlib/builtin/file_test.rbs +59 -0
  86. data/stdlib/builtin/float.rbs +696 -0
  87. data/stdlib/builtin/gc.rbs +243 -0
  88. data/stdlib/builtin/hash.rbs +1029 -0
  89. data/stdlib/builtin/integer.rbs +707 -0
  90. data/stdlib/builtin/io.rbs +683 -0
  91. data/stdlib/builtin/kernel.rbs +576 -0
  92. data/stdlib/builtin/marshal.rbs +161 -0
  93. data/stdlib/builtin/match_data.rbs +271 -0
  94. data/stdlib/builtin/math.rbs +369 -0
  95. data/stdlib/builtin/method.rbs +185 -0
  96. data/stdlib/builtin/module.rbs +1104 -0
  97. data/stdlib/builtin/nil_class.rbs +82 -0
  98. data/stdlib/builtin/numeric.rbs +409 -0
  99. data/stdlib/builtin/object.rbs +824 -0
  100. data/stdlib/builtin/proc.rbs +429 -0
  101. data/stdlib/builtin/process.rbs +1227 -0
  102. data/stdlib/builtin/random.rbs +267 -0
  103. data/stdlib/builtin/range.rbs +226 -0
  104. data/stdlib/builtin/rational.rbs +424 -0
  105. data/stdlib/builtin/rb_config.rbs +57 -0
  106. data/stdlib/builtin/regexp.rbs +1083 -0
  107. data/stdlib/builtin/ruby_vm.rbs +14 -0
  108. data/stdlib/builtin/signal.rbs +55 -0
  109. data/stdlib/builtin/string.rbs +1901 -0
  110. data/stdlib/builtin/string_io.rbs +284 -0
  111. data/stdlib/builtin/struct.rbs +40 -0
  112. data/stdlib/builtin/symbol.rbs +228 -0
  113. data/stdlib/builtin/thread.rbs +1108 -0
  114. data/stdlib/builtin/thread_group.rbs +23 -0
  115. data/stdlib/builtin/time.rbs +1047 -0
  116. data/stdlib/builtin/trace_point.rbs +290 -0
  117. data/stdlib/builtin/true_class.rbs +46 -0
  118. data/stdlib/builtin/unbound_method.rbs +153 -0
  119. data/stdlib/builtin/warning.rbs +17 -0
  120. data/stdlib/coverage/coverage.rbs +62 -0
  121. data/stdlib/csv/csv.rbs +773 -0
  122. data/stdlib/erb/erb.rbs +392 -0
  123. data/stdlib/find/find.rbs +40 -0
  124. data/stdlib/ipaddr/ipaddr.rbs +247 -0
  125. data/stdlib/json/json.rbs +335 -0
  126. data/stdlib/pathname/pathname.rbs +1093 -0
  127. data/stdlib/prime/integer-extension.rbs +23 -0
  128. data/stdlib/prime/prime.rbs +188 -0
  129. data/stdlib/securerandom/securerandom.rbs +9 -0
  130. data/stdlib/set/set.rbs +301 -0
  131. data/stdlib/tmpdir/tmpdir.rbs +53 -0
  132. metadata +292 -0
@@ -0,0 +1,683 @@
1
+ # The [IO](IO) class is the basis for all input and
2
+ # output in Ruby. An I/O stream may be *duplexed* (that is,
3
+ # bidirectional), and so may use more than one native operating system
4
+ # stream.
5
+ #
6
+ # Many of the examples in this section use the
7
+ # [File](https://ruby-doc.org/core-2.6.3/File.html) class, the only
8
+ # standard subclass of [IO](IO). The two classes are
9
+ # closely associated. Like the
10
+ # [File](https://ruby-doc.org/core-2.6.3/File.html) class, the Socket
11
+ # library subclasses from [IO](IO) (such as TCPSocket
12
+ # or UDPSocket).
13
+ #
14
+ # The
15
+ # [Kernel\#open](https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-open)
16
+ # method can create an [IO](IO) (or
17
+ # [File](https://ruby-doc.org/core-2.6.3/File.html) ) object for these
18
+ # types of arguments:
19
+ #
20
+ # - A plain string represents a filename suitable for the underlying
21
+ # operating system.
22
+ #
23
+ # - A string starting with `"|"` indicates a subprocess. The remainder
24
+ # of the string following the `"|"` is invoked as a process with
25
+ # appropriate input/output channels connected to it.
26
+ #
27
+ # - A string equal to `"|-"` will create another Ruby instance as a
28
+ # subprocess.
29
+ #
30
+ # The [IO](IO) may be opened with different file modes
31
+ # (read-only, write-only) and encodings for proper conversion. See
32
+ # [::new](IO#method-c-new) for these options. See
33
+ # [Kernel\#open](https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-open)
34
+ # for details of the various command formats described above.
35
+ #
36
+ # [::popen](IO#method-c-popen), the Open3 library, or
37
+ # Process\#spawn may also be used to communicate with subprocesses through
38
+ # an [IO](IO).
39
+ #
40
+ # Ruby will convert pathnames between different operating system
41
+ # conventions if possible. For instance, on a Windows system the filename
42
+ # `"/gumby/ruby/test.rb"` will be opened as `"\gumby\ruby\test.rb"` . When
43
+ # specifying a Windows-style filename in a Ruby string, remember to escape
44
+ # the backslashes:
45
+ #
46
+ # ```ruby
47
+ # "C:\\gumby\\ruby\\test.rb"
48
+ # ```
49
+ #
50
+ # Our examples here will use the Unix-style forward slashes;
51
+ # File::ALT\_SEPARATOR can be used to get the platform-specific separator
52
+ # character.
53
+ #
54
+ # The global constant [ARGF](https://ruby-doc.org/core-2.6.3/ARGF.html)
55
+ # (also accessible as `$<` ) provides an IO-like stream which allows
56
+ # access to all files mentioned on the command line (or STDIN if no files
57
+ # are mentioned).
58
+ # [ARGF\#path](https://ruby-doc.org/core-2.6.3/ARGF.html#method-i-path)
59
+ # and its alias
60
+ # [ARGF\#filename](https://ruby-doc.org/core-2.6.3/ARGF.html#method-i-filename)
61
+ # are provided to access the name of the file currently being read.
62
+ #
63
+ #
64
+ # The io/console extension provides methods for interacting with the
65
+ # console. The console can be accessed from IO.console or the standard
66
+ # input/output/error [IO](IO) objects.
67
+ #
68
+ # Requiring io/console adds the following methods:
69
+ #
70
+ # - IO::console
71
+ #
72
+ # - IO\#raw
73
+ #
74
+ # - IO\#raw\!
75
+ #
76
+ # - IO\#cooked
77
+ #
78
+ # - IO\#cooked\!
79
+ #
80
+ # - IO\#getch
81
+ #
82
+ # - IO\#echo=
83
+ #
84
+ # - IO\#echo?
85
+ #
86
+ # - IO\#noecho
87
+ #
88
+ # - IO\#winsize
89
+ #
90
+ # - IO\#winsize=
91
+ #
92
+ # - IO\#iflush
93
+ #
94
+ # - IO\#ioflush
95
+ #
96
+ # - IO\#oflush
97
+ #
98
+ # Example:
99
+ #
100
+ # ```ruby
101
+ # require 'io/console'
102
+ # rows, columns = $stdout.winsize
103
+ # puts "Your screen is #{columns} wide and #{rows} tall"
104
+ # ```
105
+ class IO < Object
106
+ include File::Constants
107
+
108
+ include Enumerable[String, IO]
109
+
110
+ def <<: (untyped arg0) -> self
111
+
112
+ def advise: (Symbol arg0, ?Integer offset, ?Integer len) -> NilClass
113
+
114
+ def autoclose=: (bool arg0) -> bool
115
+
116
+ # Returns `true` if the underlying file descriptor of *ios* will be closed
117
+ # automatically at its finalization, otherwise `false` .
118
+ def autoclose?: () -> bool
119
+
120
+ # Puts *ios* into binary mode. Once a stream is in binary mode, it cannot
121
+ # be reset to nonbinary mode.
122
+ #
123
+ # - newline conversion disabled
124
+ #
125
+ # - encoding conversion disabled
126
+ #
127
+ # - content is treated as ASCII-8BIT
128
+ def binmode: () -> self
129
+
130
+ # Returns `true` if *ios* is binmode.
131
+ def binmode?: () -> bool
132
+
133
+ # Closes *ios* and flushes any pending writes to the operating system. The
134
+ # stream is unavailable for any further data operations; an `IOError` is
135
+ # raised if such an attempt is made. I/O streams are automatically closed
136
+ # when they are claimed by the garbage collector.
137
+ #
138
+ # If *ios* is opened by `IO.popen`, `close` sets `$?` .
139
+ #
140
+ # Calling this method on closed [IO](IO.downloaded.ruby_doc) object is
141
+ # just ignored since Ruby 2.3.
142
+ def close: () -> NilClass
143
+
144
+ def close_on_exec=: (bool arg0) -> bool
145
+
146
+ # Returns `true` if *ios* will be closed on exec.
147
+ #
148
+ # ```ruby
149
+ # f = open("/dev/null")
150
+ # f.close_on_exec? #=> false
151
+ # f.close_on_exec = true
152
+ # f.close_on_exec? #=> true
153
+ # f.close_on_exec = false
154
+ # f.close_on_exec? #=> false
155
+ # ```
156
+ def close_on_exec?: () -> bool
157
+
158
+ # Closes the read end of a duplex I/O stream (i.e., one that contains both
159
+ # a read and a write stream, such as a pipe). Will raise an `IOError` if
160
+ # the stream is not duplexed.
161
+ #
162
+ # ```ruby
163
+ # f = IO.popen("/bin/sh","r+")
164
+ # f.close_read
165
+ # f.readlines
166
+ # ```
167
+ #
168
+ # *produces:*
169
+ #
170
+ # prog.rb:3:in `readlines': not opened for reading (IOError)
171
+ # from prog.rb:3
172
+ #
173
+ # Calling this method on closed [IO](IO.downloaded.ruby_doc) object is
174
+ # just ignored since Ruby 2.3.
175
+ def close_read: () -> NilClass
176
+
177
+ # Closes the write end of a duplex I/O stream (i.e., one that contains
178
+ # both a read and a write stream, such as a pipe). Will raise an `IOError`
179
+ # if the stream is not duplexed.
180
+ #
181
+ # ```ruby
182
+ # f = IO.popen("/bin/sh","r+")
183
+ # f.close_write
184
+ # f.print "nowhere"
185
+ # ```
186
+ #
187
+ # *produces:*
188
+ #
189
+ # prog.rb:3:in `write': not opened for writing (IOError)
190
+ # from prog.rb:3:in `print'
191
+ # from prog.rb:3
192
+ #
193
+ # Calling this method on closed [IO](IO.downloaded.ruby_doc) object is
194
+ # just ignored since Ruby 2.3.
195
+ def close_write: () -> NilClass
196
+
197
+ # Returns `true` if *ios* is completely closed (for duplex streams, both
198
+ # reader and writer), `false` otherwise.
199
+ #
200
+ # ```ruby
201
+ # f = File.new("testfile")
202
+ # f.close #=> nil
203
+ # f.closed? #=> true
204
+ # f = IO.popen("/bin/sh","r+")
205
+ # f.close_write #=> nil
206
+ # f.closed? #=> false
207
+ # f.close_read #=> nil
208
+ # f.closed? #=> true
209
+ # ```
210
+ def closed?: () -> bool
211
+
212
+ def each: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
213
+ | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
214
+
215
+ def each_byte: () { (Integer arg0) -> untyped } -> self
216
+ | () -> ::Enumerator[Integer, self]
217
+
218
+ def each_char: () { (String arg0) -> untyped } -> self
219
+ | () -> ::Enumerator[String, self]
220
+
221
+ def each_codepoint: () { (Integer arg0) -> untyped } -> self
222
+ | () -> ::Enumerator[Integer, self]
223
+
224
+ # Returns true if *ios* is at end of file that means there are no more
225
+ # data to read. The stream must be opened for reading or an `IOError` will
226
+ # be raised.
227
+ #
228
+ # ```ruby
229
+ # f = File.new("testfile")
230
+ # dummy = f.readlines
231
+ # f.eof #=> true
232
+ # ```
233
+ #
234
+ # If *ios* is a stream such as pipe or socket, `IO#eof?` blocks until the
235
+ # other end sends some data or closes it.
236
+ #
237
+ # ```ruby
238
+ # r, w = IO.pipe
239
+ # Thread.new { sleep 1; w.close }
240
+ # r.eof? #=> true after 1 second blocking
241
+ #
242
+ # r, w = IO.pipe
243
+ # Thread.new { sleep 1; w.puts "a" }
244
+ # r.eof? #=> false after 1 second blocking
245
+ #
246
+ # r, w = IO.pipe
247
+ # r.eof? # blocks forever
248
+ # ```
249
+ #
250
+ # Note that `IO#eof?` reads data to the input byte buffer. So `IO#sysread`
251
+ # may not behave as you intend with `IO#eof?`, unless you call
252
+ # `IO#rewind` first (which is not available for some streams).
253
+ def eof: () -> bool
254
+
255
+ def fcntl: (Integer integer_cmd, String | Integer arg) -> Integer
256
+
257
+ # Immediately writes all buffered data in *ios* to disk.
258
+ #
259
+ # If the underlying operating system does not support *fdatasync(2)* ,
260
+ # `IO#fsync` is called instead (which might raise a `NotImplementedError`
261
+ # ).
262
+ def fdatasync: () -> Integer?
263
+
264
+ # Returns an integer representing the numeric file descriptor for *ios* .
265
+ #
266
+ # ```ruby
267
+ # $stdin.fileno #=> 0
268
+ # $stdout.fileno #=> 1
269
+ # ```
270
+ #
271
+ #
272
+ #
273
+ # Also aliased as: [to\_i](IO.downloaded.ruby_doc#method-i-to_i)
274
+ def fileno: () -> Integer
275
+
276
+ # Flushes any buffered data within *ios* to the underlying operating
277
+ # system (note that this is Ruby internal buffering only; the OS may
278
+ # buffer the data as well).
279
+ #
280
+ # ```ruby
281
+ # $stdout.print "no newline"
282
+ # $stdout.flush
283
+ # ```
284
+ #
285
+ # *produces:*
286
+ #
287
+ # ```ruby
288
+ # no newline
289
+ # ```
290
+ def flush: () -> self
291
+
292
+ # Immediately writes all buffered data in *ios* to disk. Note that `fsync`
293
+ # differs from using `IO#sync=` . The latter ensures that data is flushed
294
+ # from Ruby’s buffers, but does not guarantee that the underlying
295
+ # operating system actually writes it to disk.
296
+ #
297
+ # `NotImplementedError` is raised if the underlying operating system does
298
+ # not support *fsync(2)* .
299
+ def fsync: () -> Integer?
300
+
301
+ # Gets the next 8-bit byte (0..255) from *ios* . Returns `nil` if called
302
+ # at end of file.
303
+ #
304
+ # ```ruby
305
+ # f = File.new("testfile")
306
+ # f.getbyte #=> 84
307
+ # f.getbyte #=> 104
308
+ # ```
309
+ def getbyte: () -> Integer?
310
+
311
+ # Reads a one-character string from *ios* . Returns `nil` if called at end
312
+ # of file.
313
+ #
314
+ # ```ruby
315
+ # f = File.new("testfile")
316
+ # f.getc #=> "h"
317
+ # f.getc #=> "e"
318
+ # ```
319
+ def getc: () -> String?
320
+
321
+ def gets: (?String sep, ?Integer limit) -> String?
322
+
323
+ def initialize: (Integer fd, ?Integer mode, ?Integer opt) -> void
324
+
325
+ # Return a string describing this [IO](IO.downloaded.ruby_doc) object.
326
+ def inspect: () -> String
327
+
328
+ # Returns the [Encoding](https://ruby-doc.org/core-2.6.3/Encoding.html) of
329
+ # the internal string if conversion is specified. Otherwise returns `nil`
330
+ # .
331
+ def internal_encoding: () -> Encoding
332
+
333
+ def ioctl: (Integer integer_cmd, String | Integer arg) -> Integer
334
+
335
+ # Returns `true` if *ios* is associated with a terminal device (tty),
336
+ # `false` otherwise.
337
+ #
338
+ # ```ruby
339
+ # File.new("testfile").isatty #=> false
340
+ # File.new("/dev/tty").isatty #=> true
341
+ # ```
342
+ def isatty: () -> bool
343
+
344
+ # Returns the current line number in *ios* . The stream must be opened for
345
+ # reading. `lineno` counts the number of times
346
+ # [gets](IO.downloaded.ruby_doc#method-i-gets) is called rather than the
347
+ # number of newlines encountered. The two values will differ if
348
+ # [gets](IO.downloaded.ruby_doc#method-i-gets) is called with a separator
349
+ # other than newline.
350
+ #
351
+ # Methods that use `$/` like [each](IO.downloaded.ruby_doc#method-i-each)
352
+ # , [lines](IO.downloaded.ruby_doc#method-i-lines) and
353
+ # [readline](IO.downloaded.ruby_doc#method-i-readline) will also increment
354
+ # `lineno` .
355
+ #
356
+ # See also the `$.` variable.
357
+ #
358
+ # ```ruby
359
+ # f = File.new("testfile")
360
+ # f.lineno #=> 0
361
+ # f.gets #=> "This is line one\n"
362
+ # f.lineno #=> 1
363
+ # f.gets #=> "This is line two\n"
364
+ # f.lineno #=> 2
365
+ # ```
366
+ def lineno: () -> Integer
367
+
368
+ def lineno=: (Integer arg0) -> Integer
369
+
370
+ # Returns the process ID of a child process associated with *ios* . This
371
+ # will be set by `IO.popen` .
372
+ #
373
+ # ```ruby
374
+ # pipe = IO.popen("-")
375
+ # if pipe
376
+ # $stderr.puts "In parent, child pid is #{pipe.pid}"
377
+ # else
378
+ # $stderr.puts "In child, pid is #{$$}"
379
+ # end
380
+ # ```
381
+ #
382
+ # *produces:*
383
+ #
384
+ # In child, pid is 26209
385
+ # In parent, child pid is 26209
386
+ def pid: () -> Integer
387
+
388
+ # Returns the current offset (in bytes) of *ios* .
389
+ #
390
+ # ```ruby
391
+ # f = File.new("testfile")
392
+ # f.pos #=> 0
393
+ # f.gets #=> "This is line one\n"
394
+ # f.pos #=> 17
395
+ # ```
396
+ def pos: () -> Integer
397
+
398
+ def pos=: (Integer arg0) -> Integer
399
+
400
+ def print: (*untyped arg0) -> NilClass
401
+
402
+ def printf: (String format_string, *untyped arg0) -> NilClass
403
+
404
+ def putc: (Numeric | String arg0) -> untyped
405
+
406
+ def puts: (*untyped arg0) -> NilClass
407
+
408
+ def read: (?Integer length, ?String outbuf) -> String?
409
+
410
+ def read_nonblock: (Integer len) -> String
411
+ | (Integer len, ?String buf) -> String
412
+
413
+ # Reads a byte as with `IO#getbyte`, but raises an `EOFError` on end of
414
+ # file.
415
+ def readbyte: () -> Integer
416
+
417
+ # Reads a one-character string from *ios* . Raises an `EOFError` on end of
418
+ # file.
419
+ #
420
+ # ```ruby
421
+ # f = File.new("testfile")
422
+ # f.readchar #=> "h"
423
+ # f.readchar #=> "e"
424
+ # ```
425
+ def readchar: () -> String
426
+
427
+ def readline: (?String sep, ?Integer limit) -> String
428
+
429
+ def readlines: (?String sep, ?Integer limit) -> ::Array[String]
430
+
431
+ def readpartial: (Integer maxlen) -> String
432
+ | (Integer maxlen, ?String outbuf) -> String
433
+
434
+ def reopen: (IO other_IO_or_path) -> IO
435
+ | (String other_IO_or_path, ?String mode_str) -> IO
436
+
437
+ # Positions *ios* to the beginning of input, resetting `lineno` to zero.
438
+ #
439
+ # ```ruby
440
+ # f = File.new("testfile")
441
+ # f.readline #=> "This is line one\n"
442
+ # f.rewind #=> 0
443
+ # f.lineno #=> 0
444
+ # f.readline #=> "This is line one\n"
445
+ # ```
446
+ #
447
+ # Note that it cannot be used with streams such as pipes, ttys, and
448
+ # sockets.
449
+ def rewind: () -> Integer
450
+
451
+ def seek: (Integer amount, ?Integer whence) -> Integer
452
+
453
+ def set_encoding: (?String | Encoding ext_or_ext_int_enc) -> self
454
+ | (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
455
+
456
+ # Returns status information for *ios* as an object of type `File::Stat` .
457
+ #
458
+ # ```ruby
459
+ # f = File.new("testfile")
460
+ # s = f.stat
461
+ # "%o" % s.mode #=> "100644"
462
+ # s.blksize #=> 4096
463
+ # s.atime #=> Wed Apr 09 08:53:54 CDT 2003
464
+ # ```
465
+ def stat: () -> File::Stat
466
+
467
+ # Returns the current “sync mode” of *ios* . When sync mode is true, all
468
+ # output is immediately flushed to the underlying operating system and is
469
+ # not buffered by Ruby internally. See also `IO#fsync` .
470
+ #
471
+ # ```ruby
472
+ # f = File.new("testfile")
473
+ # f.sync #=> false
474
+ # ```
475
+ def sync: () -> bool
476
+
477
+ def sync=: (bool arg0) -> bool
478
+
479
+ def sysread: (Integer maxlen, String outbuf) -> String
480
+
481
+ def sysseek: (Integer amount, ?Integer whence) -> Integer
482
+
483
+ def syswrite: (String arg0) -> Integer
484
+
485
+ # Returns the current offset (in bytes) of *ios* .
486
+ #
487
+ # ```ruby
488
+ # f = File.new("testfile")
489
+ # f.pos #=> 0
490
+ # f.gets #=> "This is line one\n"
491
+ # f.pos #=> 17
492
+ # ```
493
+ def tell: () -> Integer
494
+
495
+ # Returns *ios* .
496
+ def to_io: () -> self
497
+
498
+ # Returns `true` if *ios* is associated with a terminal device (tty),
499
+ # `false` otherwise.
500
+ #
501
+ # ```ruby
502
+ # File.new("testfile").isatty #=> false
503
+ # File.new("/dev/tty").isatty #=> true
504
+ # ```
505
+ def tty?: () -> bool
506
+
507
+ def ungetbyte: (String | Integer arg0) -> NilClass
508
+
509
+ def ungetc: (String arg0) -> NilClass
510
+
511
+ def write: (String arg0) -> Integer
512
+
513
+ def self.binread: (String name, ?Integer length, ?Integer offset) -> String
514
+
515
+ def self.binwrite: (String name, String arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
516
+
517
+ def self.copy_stream: (String | IO src, String | IO dst, ?Integer copy_length, ?Integer src_offset) -> Integer
518
+
519
+ def self.popen: (*untyped args) -> untyped
520
+
521
+ def self.read: (String name, ?Integer length, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> String
522
+
523
+ def self.readlines: (String name, ?String sep, ?Integer limit, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> ::Array[String]
524
+
525
+ def self.select: (::Array[IO]? read_array, ?::Array[IO]? write_array, ?::Array[IO]? error_array, ?Integer? timeout) -> ::Array[::Array[IO]]?
526
+
527
+ def self.sysopen: (String path, ?String mode, ?String perm) -> Integer
528
+
529
+ def self.try_convert: (untyped arg0) -> IO?
530
+
531
+ def self.write: (String name, String arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
532
+
533
+ def self.for_fd: (Integer fd, ?Integer mode, ?Integer opt) -> self
534
+
535
+ def bytes: () { (Integer arg0) -> untyped } -> self
536
+ | () -> ::Enumerator[Integer, self]
537
+
538
+ def chars: () { (String arg0) -> untyped } -> self
539
+ | () -> ::Enumerator[String, self]
540
+
541
+ def codepoints: () { (Integer arg0) -> untyped } -> self
542
+ | () -> ::Enumerator[Integer, self]
543
+
544
+ def each_line: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
545
+ | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
546
+
547
+ # Returns true if *ios* is at end of file that means there are no more
548
+ # data to read. The stream must be opened for reading or an `IOError` will
549
+ # be raised.
550
+ #
551
+ # ```ruby
552
+ # f = File.new("testfile")
553
+ # dummy = f.readlines
554
+ # f.eof #=> true
555
+ # ```
556
+ #
557
+ # If *ios* is a stream such as pipe or socket, `IO#eof?` blocks until the
558
+ # other end sends some data or closes it.
559
+ #
560
+ # ```ruby
561
+ # r, w = IO.pipe
562
+ # Thread.new { sleep 1; w.close }
563
+ # r.eof? #=> true after 1 second blocking
564
+ #
565
+ # r, w = IO.pipe
566
+ # Thread.new { sleep 1; w.puts "a" }
567
+ # r.eof? #=> false after 1 second blocking
568
+ #
569
+ # r, w = IO.pipe
570
+ # r.eof? # blocks forever
571
+ # ```
572
+ #
573
+ # Note that `IO#eof?` reads data to the input byte buffer. So `IO#sysread`
574
+ # may not behave as you intend with `IO#eof?`, unless you call
575
+ # `IO#rewind` first (which is not available for some streams).
576
+ def eof?: () -> bool
577
+
578
+ def lines: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
579
+ | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
580
+
581
+ # Alias for: [fileno](IO.downloaded.ruby_doc#method-i-fileno)
582
+ def to_i: () -> Integer
583
+ end
584
+
585
+ IO::APPEND: Integer
586
+
587
+ IO::BINARY: Integer
588
+
589
+ IO::CREAT: Integer
590
+
591
+ IO::DIRECT: Integer
592
+
593
+ IO::DSYNC: Integer
594
+
595
+ IO::EXCL: Integer
596
+
597
+ IO::FNM_CASEFOLD: Integer
598
+
599
+ IO::FNM_DOTMATCH: Integer
600
+
601
+ IO::FNM_EXTGLOB: Integer
602
+
603
+ IO::FNM_NOESCAPE: Integer
604
+
605
+ IO::FNM_PATHNAME: Integer
606
+
607
+ IO::FNM_SHORTNAME: Integer
608
+
609
+ IO::FNM_SYSCASE: Integer
610
+
611
+ IO::LOCK_EX: Integer
612
+
613
+ IO::LOCK_NB: Integer
614
+
615
+ IO::LOCK_SH: Integer
616
+
617
+ IO::LOCK_UN: Integer
618
+
619
+ IO::NOATIME: Integer
620
+
621
+ IO::NOCTTY: Integer
622
+
623
+ IO::NOFOLLOW: Integer
624
+
625
+ IO::NONBLOCK: Integer
626
+
627
+ IO::NULL: String
628
+
629
+ IO::RDONLY: Integer
630
+
631
+ IO::RDWR: Integer
632
+
633
+ IO::RSYNC: Integer
634
+
635
+ IO::SEEK_CUR: Integer
636
+
637
+ IO::SEEK_DATA: Integer
638
+
639
+ IO::SEEK_END: Integer
640
+
641
+ IO::SEEK_HOLE: Integer
642
+
643
+ IO::SEEK_SET: Integer
644
+
645
+ IO::SHARE_DELETE: Integer
646
+
647
+ IO::SYNC: Integer
648
+
649
+ IO::TMPFILE: Integer
650
+
651
+ IO::TRUNC: Integer
652
+
653
+ IO::WRONLY: Integer
654
+
655
+ class IO::EAGAINWaitReadable < Errno::EAGAIN
656
+ include IO::WaitReadable
657
+ end
658
+
659
+ IO::EAGAINWaitReadable::Errno: Integer
660
+
661
+ class IO::EAGAINWaitWritable < Errno::EAGAIN
662
+ include IO::WaitWritable
663
+ end
664
+
665
+ IO::EAGAINWaitWritable::Errno: Integer
666
+
667
+ class IO::EINPROGRESSWaitReadable < Errno::EINPROGRESS
668
+ include IO::WaitReadable
669
+ end
670
+
671
+ IO::EINPROGRESSWaitReadable::Errno: Integer
672
+
673
+ class IO::EINPROGRESSWaitWritable < Errno::EINPROGRESS
674
+ include IO::WaitWritable
675
+ end
676
+
677
+ IO::EINPROGRESSWaitWritable::Errno: Integer
678
+
679
+ module IO::WaitReadable
680
+ end
681
+
682
+ module IO::WaitWritable
683
+ end