rbs 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +1 -1
- data/.github/workflows/ruby.yml +3 -3
- data/CHANGELOG.md +44 -0
- data/Gemfile.lock +5 -5
- data/Rakefile +6 -38
- data/Steepfile +6 -2
- data/core/constants.rbs +1 -1
- data/core/env.rbs +1 -1323
- data/core/global_variables.rbs +1 -1
- data/core/hash.rbs +3 -3
- data/core/kernel.rbs +2 -2
- data/core/random.rbs +5 -220
- data/core/rational.rbs +3 -3
- data/core/rbs/unnamed/argf.rbs +965 -0
- data/core/rbs/unnamed/env_class.rbs +1325 -0
- data/core/rbs/unnamed/random.rbs +270 -0
- data/core/regexp.rbs +2 -3
- data/docs/CONTRIBUTING.md +2 -2
- data/ext/rbs_extension/lexer.c +1343 -1353
- data/ext/rbs_extension/lexer.re +2 -2
- data/ext/rbs_extension/rbs_extension.h +1 -1
- data/ext/rbs_extension/unescape.c +17 -10
- data/lib/rbs/ast/members.rb +6 -3
- data/lib/rbs/cli.rb +2 -0
- data/lib/rbs/factory.rb +2 -0
- data/lib/rbs/prototype/helpers.rb +1 -5
- data/lib/rbs/prototype/rb.rb +105 -56
- data/lib/rbs/prototype/rbi.rb +65 -30
- data/lib/rbs/prototype/runtime.rb +4 -3
- data/lib/rbs/test/setup_helper.rb +6 -1
- data/lib/rbs/version.rb +1 -1
- data/schema/members.json +4 -1
- data/sig/collection/config.rbs +3 -0
- data/sig/factory.rbs +5 -0
- data/sig/prototype/helpers.rbs +23 -0
- data/sig/prototype/rb.rbs +84 -0
- data/sig/prototype/rbi.rbs +73 -0
- data/sig/shims/abstract_syntax_tree.rbs +25 -0
- data/sig/shims/enumerable.rbs +5 -0
- data/sig/shims/pp.rbs +3 -0
- data/sig/shims/ripper.rbs +8 -0
- data/stdlib/cgi/0/manifest.yaml +2 -0
- data/stdlib/date/0/time.rbs +26 -0
- data/stdlib/etc/0/etc.rbs +745 -0
- data/stdlib/minitest/0/kernel.rbs +42 -0
- data/stdlib/minitest/0/manifest.yaml +2 -0
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +49 -0
- data/stdlib/minitest/0/minitest/assertion.rbs +16 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +545 -0
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +16 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
- data/stdlib/minitest/0/minitest/benchmark.rbs +258 -0
- data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
- data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
- data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
- data/stdlib/minitest/0/minitest/guard.rbs +64 -0
- data/stdlib/minitest/0/minitest/mock.rbs +60 -0
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +42 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +6 -0
- data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
- data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
- data/stdlib/minitest/0/minitest/pride_io.rbs +54 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +17 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
- data/stdlib/minitest/0/minitest/reportable.rbs +51 -0
- data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/result.rbs +28 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +131 -0
- data/stdlib/minitest/0/minitest/skip.rbs +6 -0
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +125 -0
- data/stdlib/minitest/0/minitest/spec.rbs +11 -0
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +76 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +25 -0
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
- data/stdlib/minitest/0/minitest/test.rbs +76 -0
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +10 -0
- data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
- data/stdlib/minitest/0/minitest/unit.rbs +5 -0
- data/stdlib/minitest/0/minitest.rbs +966 -0
- data/stdlib/rubygems/0/errors.rbs +113 -0
- metadata +54 -4
- data/lib/rbs/char_scanner.rb +0 -20
@@ -0,0 +1,965 @@
|
|
1
|
+
module RBS
|
2
|
+
module Unnamed
|
3
|
+
# <!-- rdoc-file=io.c -->
|
4
|
+
# `ARGF` is a stream designed for use in scripts that process files given as
|
5
|
+
# command-line arguments or passed in via STDIN.
|
6
|
+
#
|
7
|
+
# The arguments passed to your script are stored in the `ARGV` Array, one
|
8
|
+
# argument per element. `ARGF` assumes that any arguments that aren't filenames
|
9
|
+
# have been removed from `ARGV`. For example:
|
10
|
+
#
|
11
|
+
# $ ruby argf.rb --verbose file1 file2
|
12
|
+
#
|
13
|
+
# ARGV #=> ["--verbose", "file1", "file2"]
|
14
|
+
# option = ARGV.shift #=> "--verbose"
|
15
|
+
# ARGV #=> ["file1", "file2"]
|
16
|
+
#
|
17
|
+
# You can now use `ARGF` to work with a concatenation of each of these named
|
18
|
+
# files. For instance, `ARGF.read` will return the contents of *file1* followed
|
19
|
+
# by the contents of *file2*.
|
20
|
+
#
|
21
|
+
# After a file in `ARGV` has been read `ARGF` removes it from the Array. Thus,
|
22
|
+
# after all files have been read `ARGV` will be empty.
|
23
|
+
#
|
24
|
+
# You can manipulate `ARGV` yourself to control what `ARGF` operates on. If you
|
25
|
+
# remove a file from `ARGV`, it is ignored by `ARGF`; if you add files to
|
26
|
+
# `ARGV`, they are treated as if they were named on the command line. For
|
27
|
+
# example:
|
28
|
+
#
|
29
|
+
# ARGV.replace ["file1"]
|
30
|
+
# ARGF.readlines # Returns the contents of file1 as an Array
|
31
|
+
# ARGV #=> []
|
32
|
+
# ARGV.replace ["file2", "file3"]
|
33
|
+
# ARGF.read # Returns the contents of file2 and file3
|
34
|
+
#
|
35
|
+
# If `ARGV` is empty, `ARGF` acts as if it contained STDIN, i.e. the data piped
|
36
|
+
# to your script. For example:
|
37
|
+
#
|
38
|
+
# $ echo "glark" | ruby -e 'p ARGF.read'
|
39
|
+
# "glark\n"
|
40
|
+
#
|
41
|
+
%a{annotate:rdoc:copy:ARGF}
|
42
|
+
class ARGFClass
|
43
|
+
include Enumerable[String]
|
44
|
+
|
45
|
+
public
|
46
|
+
|
47
|
+
# <!--
|
48
|
+
# rdoc-file=io.c
|
49
|
+
# - ARGF.argv -> ARGV
|
50
|
+
# -->
|
51
|
+
# Returns the `ARGV` array, which contains the arguments passed to your script,
|
52
|
+
# one per element.
|
53
|
+
#
|
54
|
+
# For example:
|
55
|
+
#
|
56
|
+
# $ ruby argf.rb -v glark.txt
|
57
|
+
#
|
58
|
+
# ARGF.argv #=> ["-v", "glark.txt"]
|
59
|
+
#
|
60
|
+
%a{annotate:rdoc:copy:ARGF#argv}
|
61
|
+
def argv: () -> ::Array[String]
|
62
|
+
|
63
|
+
# <!--
|
64
|
+
# rdoc-file=io.c
|
65
|
+
# - ARGF.binmode -> ARGF
|
66
|
+
# -->
|
67
|
+
# Puts `ARGF` into binary mode. Once a stream is in binary mode, it cannot be
|
68
|
+
# reset to non-binary mode. This option has the following effects:
|
69
|
+
#
|
70
|
+
# * Newline conversion is disabled.
|
71
|
+
# * Encoding conversion is disabled.
|
72
|
+
# * Content is treated as ASCII-8BIT.
|
73
|
+
#
|
74
|
+
%a{annotate:rdoc:copy:ARGF#binmode}
|
75
|
+
def binmode: () -> self
|
76
|
+
|
77
|
+
# <!--
|
78
|
+
# rdoc-file=io.c
|
79
|
+
# - ARGF.binmode? -> true or false
|
80
|
+
# -->
|
81
|
+
# Returns true if `ARGF` is being read in binary mode; false otherwise. To
|
82
|
+
# enable binary mode use `ARGF.binmode`.
|
83
|
+
#
|
84
|
+
# For example:
|
85
|
+
#
|
86
|
+
# ARGF.binmode? #=> false
|
87
|
+
# ARGF.binmode
|
88
|
+
# ARGF.binmode? #=> true
|
89
|
+
#
|
90
|
+
%a{annotate:rdoc:copy:ARGF#binmode?}
|
91
|
+
def binmode?: () -> bool
|
92
|
+
|
93
|
+
# <!--
|
94
|
+
# rdoc-file=io.c
|
95
|
+
# - ARGF.close -> ARGF
|
96
|
+
# -->
|
97
|
+
# Closes the current file and skips to the next file in ARGV. If there are no
|
98
|
+
# more files to open, just closes the current file. `STDIN` will not be closed.
|
99
|
+
#
|
100
|
+
# For example:
|
101
|
+
#
|
102
|
+
# $ ruby argf.rb foo bar
|
103
|
+
#
|
104
|
+
# ARGF.filename #=> "foo"
|
105
|
+
# ARGF.close
|
106
|
+
# ARGF.filename #=> "bar"
|
107
|
+
# ARGF.close
|
108
|
+
#
|
109
|
+
%a{annotate:rdoc:copy:ARGF#close}
|
110
|
+
def close: () -> self
|
111
|
+
|
112
|
+
# <!--
|
113
|
+
# rdoc-file=io.c
|
114
|
+
# - ARGF.closed? -> true or false
|
115
|
+
# -->
|
116
|
+
# Returns *true* if the current file has been closed; *false* otherwise. Use
|
117
|
+
# `ARGF.close` to actually close the current file.
|
118
|
+
#
|
119
|
+
%a{annotate:rdoc:copy:ARGF#closed?}
|
120
|
+
def closed?: () -> bool
|
121
|
+
|
122
|
+
# <!--
|
123
|
+
# rdoc-file=io.c
|
124
|
+
# - ARGF.each(sep=$/) {|line| block } -> ARGF
|
125
|
+
# - ARGF.each(sep=$/, limit) {|line| block } -> ARGF
|
126
|
+
# - ARGF.each(...) -> an_enumerator
|
127
|
+
# - ARGF.each_line(sep=$/) {|line| block } -> ARGF
|
128
|
+
# - ARGF.each_line(sep=$/, limit) {|line| block } -> ARGF
|
129
|
+
# - ARGF.each_line(...) -> an_enumerator
|
130
|
+
# -->
|
131
|
+
# Returns an enumerator which iterates over each line (separated by *sep*, which
|
132
|
+
# defaults to your platform's newline character) of each file in `ARGV`. If a
|
133
|
+
# block is supplied, each line in turn will be yielded to the block, otherwise
|
134
|
+
# an enumerator is returned. The optional *limit* argument is an `Integer`
|
135
|
+
# specifying the maximum length of each line; longer lines will be split
|
136
|
+
# according to this limit.
|
137
|
+
#
|
138
|
+
# This method allows you to treat the files supplied on the command line as a
|
139
|
+
# single file consisting of the concatenation of each named file. After the last
|
140
|
+
# line of the first file has been returned, the first line of the second file is
|
141
|
+
# returned. The `ARGF.filename` and `ARGF.lineno` methods can be used to
|
142
|
+
# determine the filename of the current line and line number of the whole input,
|
143
|
+
# respectively.
|
144
|
+
#
|
145
|
+
# For example, the following code prints out each line of each named file
|
146
|
+
# prefixed with its line number, displaying the filename once per file:
|
147
|
+
#
|
148
|
+
# ARGF.each_line do |line|
|
149
|
+
# puts ARGF.filename if ARGF.file.lineno == 1
|
150
|
+
# puts "#{ARGF.file.lineno}: #{line}"
|
151
|
+
# end
|
152
|
+
#
|
153
|
+
# While the following code prints only the first file's name at first, and the
|
154
|
+
# contents with line number counted through all named files.
|
155
|
+
#
|
156
|
+
# ARGF.each_line do |line|
|
157
|
+
# puts ARGF.filename if ARGF.lineno == 1
|
158
|
+
# puts "#{ARGF.lineno}: #{line}"
|
159
|
+
# end
|
160
|
+
#
|
161
|
+
%a{annotate:rdoc:copy:ARGF#each}
|
162
|
+
def each: (?String sep, ?Integer limit) { (String line) -> untyped } -> self
|
163
|
+
| (?String sep, ?Integer limit) -> ::Enumerator[String, self]
|
164
|
+
|
165
|
+
# <!--
|
166
|
+
# rdoc-file=io.c
|
167
|
+
# - ARGF.each_byte {|byte| block } -> ARGF
|
168
|
+
# - ARGF.each_byte -> an_enumerator
|
169
|
+
# -->
|
170
|
+
# Iterates over each byte of each file in `ARGV`. A byte is returned as an
|
171
|
+
# `Integer` in the range 0..255.
|
172
|
+
#
|
173
|
+
# This method allows you to treat the files supplied on the command line as a
|
174
|
+
# single file consisting of the concatenation of each named file. After the last
|
175
|
+
# byte of the first file has been returned, the first byte of the second file is
|
176
|
+
# returned. The `ARGF.filename` method can be used to determine the filename of
|
177
|
+
# the current byte.
|
178
|
+
#
|
179
|
+
# If no block is given, an enumerator is returned instead.
|
180
|
+
#
|
181
|
+
# For example:
|
182
|
+
#
|
183
|
+
# ARGF.bytes.to_a #=> [35, 32, ... 95, 10]
|
184
|
+
#
|
185
|
+
%a{annotate:rdoc:copy:ARGF#each_byte}
|
186
|
+
def each_byte: () { (Integer byte) -> untyped } -> self
|
187
|
+
| () -> ::Enumerator[Integer, self]
|
188
|
+
|
189
|
+
# <!--
|
190
|
+
# rdoc-file=io.c
|
191
|
+
# - ARGF.each_char {|char| block } -> ARGF
|
192
|
+
# - ARGF.each_char -> an_enumerator
|
193
|
+
# -->
|
194
|
+
# Iterates over each character of each file in `ARGF`.
|
195
|
+
#
|
196
|
+
# This method allows you to treat the files supplied on the command line as a
|
197
|
+
# single file consisting of the concatenation of each named file. After the last
|
198
|
+
# character of the first file has been returned, the first character of the
|
199
|
+
# second file is returned. The `ARGF.filename` method can be used to determine
|
200
|
+
# the name of the file in which the current character appears.
|
201
|
+
#
|
202
|
+
# If no block is given, an enumerator is returned instead.
|
203
|
+
#
|
204
|
+
%a{annotate:rdoc:copy:ARGF#each_char}
|
205
|
+
def each_char: () { (String char) -> untyped } -> self
|
206
|
+
| () -> ::Enumerator[String, self]
|
207
|
+
|
208
|
+
# <!--
|
209
|
+
# rdoc-file=io.c
|
210
|
+
# - ARGF.each_codepoint {|codepoint| block } -> ARGF
|
211
|
+
# - ARGF.each_codepoint -> an_enumerator
|
212
|
+
# -->
|
213
|
+
# Iterates over each codepoint of each file in `ARGF`.
|
214
|
+
#
|
215
|
+
# This method allows you to treat the files supplied on the command line as a
|
216
|
+
# single file consisting of the concatenation of each named file. After the last
|
217
|
+
# codepoint of the first file has been returned, the first codepoint of the
|
218
|
+
# second file is returned. The `ARGF.filename` method can be used to determine
|
219
|
+
# the name of the file in which the current codepoint appears.
|
220
|
+
#
|
221
|
+
# If no block is given, an enumerator is returned instead.
|
222
|
+
#
|
223
|
+
%a{annotate:rdoc:copy:ARGF#each_codepoint}
|
224
|
+
def each_codepoint: () { (Integer codepoint) -> untyped } -> self
|
225
|
+
| () -> ::Enumerator[Integer, self]
|
226
|
+
|
227
|
+
# <!-- rdoc-file=io.c -->
|
228
|
+
# Returns an enumerator which iterates over each line (separated by *sep*, which
|
229
|
+
# defaults to your platform's newline character) of each file in `ARGV`. If a
|
230
|
+
# block is supplied, each line in turn will be yielded to the block, otherwise
|
231
|
+
# an enumerator is returned. The optional *limit* argument is an `Integer`
|
232
|
+
# specifying the maximum length of each line; longer lines will be split
|
233
|
+
# according to this limit.
|
234
|
+
#
|
235
|
+
# This method allows you to treat the files supplied on the command line as a
|
236
|
+
# single file consisting of the concatenation of each named file. After the last
|
237
|
+
# line of the first file has been returned, the first line of the second file is
|
238
|
+
# returned. The `ARGF.filename` and `ARGF.lineno` methods can be used to
|
239
|
+
# determine the filename of the current line and line number of the whole input,
|
240
|
+
# respectively.
|
241
|
+
#
|
242
|
+
# For example, the following code prints out each line of each named file
|
243
|
+
# prefixed with its line number, displaying the filename once per file:
|
244
|
+
#
|
245
|
+
# ARGF.each_line do |line|
|
246
|
+
# puts ARGF.filename if ARGF.file.lineno == 1
|
247
|
+
# puts "#{ARGF.file.lineno}: #{line}"
|
248
|
+
# end
|
249
|
+
#
|
250
|
+
# While the following code prints only the first file's name at first, and the
|
251
|
+
# contents with line number counted through all named files.
|
252
|
+
#
|
253
|
+
# ARGF.each_line do |line|
|
254
|
+
# puts ARGF.filename if ARGF.lineno == 1
|
255
|
+
# puts "#{ARGF.lineno}: #{line}"
|
256
|
+
# end
|
257
|
+
#
|
258
|
+
%a{annotate:rdoc:copy:ARGF#each_line}
|
259
|
+
def each_line: (?String sep, ?Integer limit) { (String line) -> untyped } -> self
|
260
|
+
| (?String sep, ?Integer limit) -> ::Enumerator[String, self]
|
261
|
+
|
262
|
+
# <!--
|
263
|
+
# rdoc-file=io.c
|
264
|
+
# - ARGF.eof? -> true or false
|
265
|
+
# - ARGF.eof -> true or false
|
266
|
+
# -->
|
267
|
+
# Returns true if the current file in `ARGF` is at end of file, i.e. it has no
|
268
|
+
# data to read. The stream must be opened for reading or an `IOError` will be
|
269
|
+
# raised.
|
270
|
+
#
|
271
|
+
# $ echo "eof" | ruby argf.rb
|
272
|
+
#
|
273
|
+
# ARGF.eof? #=> false
|
274
|
+
# 3.times { ARGF.readchar }
|
275
|
+
# ARGF.eof? #=> false
|
276
|
+
# ARGF.readchar #=> "\n"
|
277
|
+
# ARGF.eof? #=> true
|
278
|
+
#
|
279
|
+
%a{annotate:rdoc:copy:ARGF#eof}
|
280
|
+
def eof: () -> bool
|
281
|
+
|
282
|
+
# <!-- rdoc-file=io.c -->
|
283
|
+
# Returns true if the current file in `ARGF` is at end of file, i.e. it has no
|
284
|
+
# data to read. The stream must be opened for reading or an `IOError` will be
|
285
|
+
# raised.
|
286
|
+
#
|
287
|
+
# $ echo "eof" | ruby argf.rb
|
288
|
+
#
|
289
|
+
# ARGF.eof? #=> false
|
290
|
+
# 3.times { ARGF.readchar }
|
291
|
+
# ARGF.eof? #=> false
|
292
|
+
# ARGF.readchar #=> "\n"
|
293
|
+
# ARGF.eof? #=> true
|
294
|
+
#
|
295
|
+
%a{annotate:rdoc:copy:ARGF#eof?}
|
296
|
+
def eof?: () -> bool
|
297
|
+
|
298
|
+
# <!--
|
299
|
+
# rdoc-file=io.c
|
300
|
+
# - ARGF.external_encoding -> encoding
|
301
|
+
# -->
|
302
|
+
# Returns the external encoding for files read from `ARGF` as an `Encoding`
|
303
|
+
# object. The external encoding is the encoding of the text as stored in a file.
|
304
|
+
# Contrast with `ARGF.internal_encoding`, which is the encoding used to
|
305
|
+
# represent this text within Ruby.
|
306
|
+
#
|
307
|
+
# To set the external encoding use `ARGF.set_encoding`.
|
308
|
+
#
|
309
|
+
# For example:
|
310
|
+
#
|
311
|
+
# ARGF.external_encoding #=> #<Encoding:UTF-8>
|
312
|
+
#
|
313
|
+
%a{annotate:rdoc:copy:ARGF#external_encoding}
|
314
|
+
def external_encoding: () -> Encoding
|
315
|
+
|
316
|
+
# <!--
|
317
|
+
# rdoc-file=io.c
|
318
|
+
# - ARGF.file -> IO or File object
|
319
|
+
# -->
|
320
|
+
# Returns the current file as an `IO` or `File` object. `$stdin` is returned
|
321
|
+
# when the current file is STDIN.
|
322
|
+
#
|
323
|
+
# For example:
|
324
|
+
#
|
325
|
+
# $ echo "foo" > foo
|
326
|
+
# $ echo "bar" > bar
|
327
|
+
#
|
328
|
+
# $ ruby argf.rb foo bar
|
329
|
+
#
|
330
|
+
# ARGF.file #=> #<File:foo>
|
331
|
+
# ARGF.read(5) #=> "foo\nb"
|
332
|
+
# ARGF.file #=> #<File:bar>
|
333
|
+
#
|
334
|
+
%a{annotate:rdoc:copy:ARGF#file}
|
335
|
+
def file: () -> (IO | File)
|
336
|
+
|
337
|
+
# <!--
|
338
|
+
# rdoc-file=io.c
|
339
|
+
# - ARGF.filename -> String
|
340
|
+
# - ARGF.path -> String
|
341
|
+
# -->
|
342
|
+
# Returns the current filename. "-" is returned when the current file is STDIN.
|
343
|
+
#
|
344
|
+
# For example:
|
345
|
+
#
|
346
|
+
# $ echo "foo" > foo
|
347
|
+
# $ echo "bar" > bar
|
348
|
+
# $ echo "glark" > glark
|
349
|
+
#
|
350
|
+
# $ ruby argf.rb foo bar glark
|
351
|
+
#
|
352
|
+
# ARGF.filename #=> "foo"
|
353
|
+
# ARGF.read(5) #=> "foo\nb"
|
354
|
+
# ARGF.filename #=> "bar"
|
355
|
+
# ARGF.skip
|
356
|
+
# ARGF.filename #=> "glark"
|
357
|
+
#
|
358
|
+
%a{annotate:rdoc:copy:ARGF#filename}
|
359
|
+
def filename: () -> String
|
360
|
+
|
361
|
+
# <!--
|
362
|
+
# rdoc-file=io.c
|
363
|
+
# - ARGF.fileno -> integer
|
364
|
+
# - ARGF.to_i -> integer
|
365
|
+
# -->
|
366
|
+
# Returns an integer representing the numeric file descriptor for the current
|
367
|
+
# file. Raises an `ArgumentError` if there isn't a current file.
|
368
|
+
#
|
369
|
+
# ARGF.fileno #=> 3
|
370
|
+
#
|
371
|
+
%a{annotate:rdoc:copy:ARGF#fileno}
|
372
|
+
def fileno: () -> Integer
|
373
|
+
|
374
|
+
# <!--
|
375
|
+
# rdoc-file=io.c
|
376
|
+
# - ARGF.getbyte -> Integer or nil
|
377
|
+
# -->
|
378
|
+
# Gets the next 8-bit byte (0..255) from `ARGF`. Returns `nil` if called at the
|
379
|
+
# end of the stream.
|
380
|
+
#
|
381
|
+
# For example:
|
382
|
+
#
|
383
|
+
# $ echo "foo" > file
|
384
|
+
# $ ruby argf.rb file
|
385
|
+
#
|
386
|
+
# ARGF.getbyte #=> 102
|
387
|
+
# ARGF.getbyte #=> 111
|
388
|
+
# ARGF.getbyte #=> 111
|
389
|
+
# ARGF.getbyte #=> 10
|
390
|
+
# ARGF.getbyte #=> nil
|
391
|
+
#
|
392
|
+
%a{annotate:rdoc:copy:ARGF#getbyte}
|
393
|
+
def getbyte: () -> Integer?
|
394
|
+
|
395
|
+
# <!--
|
396
|
+
# rdoc-file=io.c
|
397
|
+
# - ARGF.getc -> String or nil
|
398
|
+
# -->
|
399
|
+
# Reads the next character from `ARGF` and returns it as a `String`. Returns
|
400
|
+
# `nil` at the end of the stream.
|
401
|
+
#
|
402
|
+
# `ARGF` treats the files named on the command line as a single file created by
|
403
|
+
# concatenating their contents. After returning the last character of the first
|
404
|
+
# file, it returns the first character of the second file, and so on.
|
405
|
+
#
|
406
|
+
# For example:
|
407
|
+
#
|
408
|
+
# $ echo "foo" > file
|
409
|
+
# $ ruby argf.rb file
|
410
|
+
#
|
411
|
+
# ARGF.getc #=> "f"
|
412
|
+
# ARGF.getc #=> "o"
|
413
|
+
# ARGF.getc #=> "o"
|
414
|
+
# ARGF.getc #=> "\n"
|
415
|
+
# ARGF.getc #=> nil
|
416
|
+
# ARGF.getc #=> nil
|
417
|
+
#
|
418
|
+
%a{annotate:rdoc:copy:ARGF#getc}
|
419
|
+
def getc: () -> String?
|
420
|
+
|
421
|
+
# <!--
|
422
|
+
# rdoc-file=io.c
|
423
|
+
# - ARGF.gets(sep=$/ [, getline_args]) -> string or nil
|
424
|
+
# - ARGF.gets(limit [, getline_args]) -> string or nil
|
425
|
+
# - ARGF.gets(sep, limit [, getline_args]) -> string or nil
|
426
|
+
# -->
|
427
|
+
# Returns the next line from the current file in `ARGF`.
|
428
|
+
#
|
429
|
+
# By default lines are assumed to be separated by `$/`; to use a different
|
430
|
+
# character as a separator, supply it as a `String` for the *sep* argument.
|
431
|
+
#
|
432
|
+
# The optional *limit* argument specifies how many characters of each line to
|
433
|
+
# return. By default all characters are returned.
|
434
|
+
#
|
435
|
+
# See IO.readlines for details about getline_args.
|
436
|
+
#
|
437
|
+
%a{annotate:rdoc:copy:ARGF#gets}
|
438
|
+
def gets: (?String sep, ?Integer limit) -> String?
|
439
|
+
|
440
|
+
# <!--
|
441
|
+
# rdoc-file=io.c
|
442
|
+
# - ARGF.inplace_mode -> String
|
443
|
+
# -->
|
444
|
+
# Returns the file extension appended to the names of modified files under
|
445
|
+
# in-place edit mode. This value can be set using `ARGF.inplace_mode=` or
|
446
|
+
# passing the `-i` switch to the Ruby binary.
|
447
|
+
#
|
448
|
+
%a{annotate:rdoc:copy:ARGF#inplace_mode}
|
449
|
+
def inplace_mode: () -> String?
|
450
|
+
|
451
|
+
# <!--
|
452
|
+
# rdoc-file=io.c
|
453
|
+
# - ARGF.inplace_mode = ext -> ARGF
|
454
|
+
# -->
|
455
|
+
# Sets the filename extension for in-place editing mode to the given String.
|
456
|
+
# Each file being edited has this value appended to its filename. The modified
|
457
|
+
# file is saved under this new name.
|
458
|
+
#
|
459
|
+
# For example:
|
460
|
+
#
|
461
|
+
# $ ruby argf.rb file.txt
|
462
|
+
#
|
463
|
+
# ARGF.inplace_mode = '.bak'
|
464
|
+
# ARGF.each_line do |line|
|
465
|
+
# print line.sub("foo","bar")
|
466
|
+
# end
|
467
|
+
#
|
468
|
+
# Each line of *file.txt* has the first occurrence of "foo" replaced with "bar",
|
469
|
+
# then the new line is written out to *file.txt.bak*.
|
470
|
+
#
|
471
|
+
%a{annotate:rdoc:copy:ARGF#inplace_mode=}
|
472
|
+
def inplace_mode=: (String) -> self
|
473
|
+
|
474
|
+
alias inspect to_s
|
475
|
+
|
476
|
+
# <!--
|
477
|
+
# rdoc-file=io.c
|
478
|
+
# - ARGF.internal_encoding -> encoding
|
479
|
+
# -->
|
480
|
+
# Returns the internal encoding for strings read from `ARGF` as an `Encoding`
|
481
|
+
# object.
|
482
|
+
#
|
483
|
+
# If `ARGF.set_encoding` has been called with two encoding names, the second is
|
484
|
+
# returned. Otherwise, if `Encoding.default_external` has been set, that value
|
485
|
+
# is returned. Failing that, if a default external encoding was specified on the
|
486
|
+
# command-line, that value is used. If the encoding is unknown, `nil` is
|
487
|
+
# returned.
|
488
|
+
#
|
489
|
+
%a{annotate:rdoc:copy:ARGF#internal_encoding}
|
490
|
+
def internal_encoding: () -> Encoding
|
491
|
+
|
492
|
+
# <!--
|
493
|
+
# rdoc-file=io.c
|
494
|
+
# - ARGF.lineno -> integer
|
495
|
+
# -->
|
496
|
+
# Returns the current line number of ARGF as a whole. This value can be set
|
497
|
+
# manually with `ARGF.lineno=`.
|
498
|
+
#
|
499
|
+
# For example:
|
500
|
+
#
|
501
|
+
# ARGF.lineno #=> 0
|
502
|
+
# ARGF.readline #=> "This is line 1\n"
|
503
|
+
# ARGF.lineno #=> 1
|
504
|
+
#
|
505
|
+
%a{annotate:rdoc:copy:ARGF#lineno}
|
506
|
+
def lineno: () -> Integer
|
507
|
+
|
508
|
+
# <!--
|
509
|
+
# rdoc-file=io.c
|
510
|
+
# - ARGF.lineno = integer -> integer
|
511
|
+
# -->
|
512
|
+
# Sets the line number of `ARGF` as a whole to the given `Integer`.
|
513
|
+
#
|
514
|
+
# `ARGF` sets the line number automatically as you read data, so normally you
|
515
|
+
# will not need to set it explicitly. To access the current line number use
|
516
|
+
# `ARGF.lineno`.
|
517
|
+
#
|
518
|
+
# For example:
|
519
|
+
#
|
520
|
+
# ARGF.lineno #=> 0
|
521
|
+
# ARGF.readline #=> "This is line 1\n"
|
522
|
+
# ARGF.lineno #=> 1
|
523
|
+
# ARGF.lineno = 0 #=> 0
|
524
|
+
# ARGF.lineno #=> 0
|
525
|
+
#
|
526
|
+
%a{annotate:rdoc:copy:ARGF#lineno=}
|
527
|
+
def lineno=: (Integer) -> untyped
|
528
|
+
|
529
|
+
# <!-- rdoc-file=io.c -->
|
530
|
+
# Returns the current filename. "-" is returned when the current file is STDIN.
|
531
|
+
#
|
532
|
+
# For example:
|
533
|
+
#
|
534
|
+
# $ echo "foo" > foo
|
535
|
+
# $ echo "bar" > bar
|
536
|
+
# $ echo "glark" > glark
|
537
|
+
#
|
538
|
+
# $ ruby argf.rb foo bar glark
|
539
|
+
#
|
540
|
+
# ARGF.filename #=> "foo"
|
541
|
+
# ARGF.read(5) #=> "foo\nb"
|
542
|
+
# ARGF.filename #=> "bar"
|
543
|
+
# ARGF.skip
|
544
|
+
# ARGF.filename #=> "glark"
|
545
|
+
#
|
546
|
+
%a{annotate:rdoc:copy:ARGF#path}
|
547
|
+
def path: () -> String
|
548
|
+
|
549
|
+
# <!-- rdoc-file=io.c -->
|
550
|
+
# Returns the current offset (in bytes) of the current file in `ARGF`.
|
551
|
+
#
|
552
|
+
# ARGF.pos #=> 0
|
553
|
+
# ARGF.gets #=> "This is line one\n"
|
554
|
+
# ARGF.pos #=> 17
|
555
|
+
#
|
556
|
+
%a{annotate:rdoc:copy:ARGF#pos}
|
557
|
+
def pos: () -> Integer
|
558
|
+
|
559
|
+
# <!--
|
560
|
+
# rdoc-file=io.c
|
561
|
+
# - ARGF.pos = position -> Integer
|
562
|
+
# -->
|
563
|
+
# Seeks to the position given by *position* (in bytes) in `ARGF`.
|
564
|
+
#
|
565
|
+
# For example:
|
566
|
+
#
|
567
|
+
# ARGF.pos = 17
|
568
|
+
# ARGF.gets #=> "This is line two\n"
|
569
|
+
#
|
570
|
+
%a{annotate:rdoc:copy:ARGF#pos=}
|
571
|
+
def pos=: (Integer) -> Integer
|
572
|
+
|
573
|
+
# <!--
|
574
|
+
# rdoc-file=io.c
|
575
|
+
# - ios.print -> nil
|
576
|
+
# - ios.print(obj, ...) -> nil
|
577
|
+
# -->
|
578
|
+
# Writes the given object(s) to *ios*. Returns `nil`.
|
579
|
+
#
|
580
|
+
# The stream must be opened for writing. Each given object that isn't a string
|
581
|
+
# will be converted by calling its `to_s` method. When called without arguments,
|
582
|
+
# prints the contents of `$_`.
|
583
|
+
#
|
584
|
+
# If the output field separator (`$,`) is not `nil`, it is inserted between
|
585
|
+
# objects. If the output record separator (`$\`) is not `nil`, it is appended to
|
586
|
+
# the output.
|
587
|
+
#
|
588
|
+
# $stdout.print("This is ", 100, " percent.\n")
|
589
|
+
#
|
590
|
+
# *produces:*
|
591
|
+
#
|
592
|
+
# This is 100 percent.
|
593
|
+
#
|
594
|
+
%a{annotate:rdoc:copy:ARGF#print}
|
595
|
+
def print: (*untyped args) -> nil
|
596
|
+
|
597
|
+
# <!--
|
598
|
+
# rdoc-file=io.c
|
599
|
+
# - ios.printf(format_string [, obj, ...]) -> nil
|
600
|
+
# -->
|
601
|
+
# Formats and writes to *ios*, converting parameters under control of the format
|
602
|
+
# string. See Kernel#sprintf for details.
|
603
|
+
#
|
604
|
+
%a{annotate:rdoc:copy:ARGF#printf}
|
605
|
+
def printf: (String format_string, *untyped args) -> nil
|
606
|
+
|
607
|
+
# <!--
|
608
|
+
# rdoc-file=io.c
|
609
|
+
# - ios.putc(obj) -> obj
|
610
|
+
# -->
|
611
|
+
# If *obj* is Numeric, write the character whose code is the least-significant
|
612
|
+
# byte of *obj*. If *obj* is String, write the first character of *obj* to
|
613
|
+
# *ios*. Otherwise, raise TypeError.
|
614
|
+
#
|
615
|
+
# $stdout.putc "A"
|
616
|
+
# $stdout.putc 65
|
617
|
+
#
|
618
|
+
# *produces:*
|
619
|
+
#
|
620
|
+
# AA
|
621
|
+
#
|
622
|
+
%a{annotate:rdoc:copy:ARGF#putc}
|
623
|
+
def putc: (Numeric | String obj) -> untyped
|
624
|
+
|
625
|
+
# <!--
|
626
|
+
# rdoc-file=io.c
|
627
|
+
# - ios.puts(obj, ...) -> nil
|
628
|
+
# -->
|
629
|
+
# Writes the given object(s) to *ios*. Writes a newline after any that do not
|
630
|
+
# already end with a newline sequence. Returns `nil`.
|
631
|
+
#
|
632
|
+
# The stream must be opened for writing. If called with an array argument,
|
633
|
+
# writes each element on a new line. Each given object that isn't a string or
|
634
|
+
# array will be converted by calling its `to_s` method. If called without
|
635
|
+
# arguments, outputs a single newline.
|
636
|
+
#
|
637
|
+
# $stdout.puts("this", "is", ["a", "test"])
|
638
|
+
#
|
639
|
+
# *produces:*
|
640
|
+
#
|
641
|
+
# this
|
642
|
+
# is
|
643
|
+
# a
|
644
|
+
# test
|
645
|
+
#
|
646
|
+
# Note that `puts` always uses newlines and is not affected by the output record
|
647
|
+
# separator (`$\`).
|
648
|
+
#
|
649
|
+
%a{annotate:rdoc:copy:ARGF#puts}
|
650
|
+
def puts: (*untyped obj) -> nil
|
651
|
+
|
652
|
+
# <!--
|
653
|
+
# rdoc-file=io.c
|
654
|
+
# - ARGF.read([length [, outbuf]]) -> string, outbuf, or nil
|
655
|
+
# -->
|
656
|
+
# Reads *length* bytes from ARGF. The files named on the command line are
|
657
|
+
# concatenated and treated as a single file by this method, so when called
|
658
|
+
# without arguments the contents of this pseudo file are returned in their
|
659
|
+
# entirety.
|
660
|
+
#
|
661
|
+
# *length* must be a non-negative integer or `nil`.
|
662
|
+
#
|
663
|
+
# If *length* is a positive integer, `read` tries to read *length* bytes without
|
664
|
+
# any conversion (binary mode). It returns `nil` if an EOF is encountered before
|
665
|
+
# anything can be read. Fewer than *length* bytes are returned if an EOF is
|
666
|
+
# encountered during the read. In the case of an integer *length*, the resulting
|
667
|
+
# string is always in ASCII-8BIT encoding.
|
668
|
+
#
|
669
|
+
# If *length* is omitted or is `nil`, it reads until EOF and the encoding
|
670
|
+
# conversion is applied, if applicable. A string is returned even if EOF is
|
671
|
+
# encountered before any data is read.
|
672
|
+
#
|
673
|
+
# If *length* is zero, it returns an empty string (`""`).
|
674
|
+
#
|
675
|
+
# If the optional *outbuf* argument is present, it must reference a String,
|
676
|
+
# which will receive the data. The *outbuf* will contain only the received data
|
677
|
+
# after the method call even if it is not empty at the beginning.
|
678
|
+
#
|
679
|
+
# For example:
|
680
|
+
#
|
681
|
+
# $ echo "small" > small.txt
|
682
|
+
# $ echo "large" > large.txt
|
683
|
+
# $ ./glark.rb small.txt large.txt
|
684
|
+
#
|
685
|
+
# ARGF.read #=> "small\nlarge"
|
686
|
+
# ARGF.read(200) #=> "small\nlarge"
|
687
|
+
# ARGF.read(2) #=> "sm"
|
688
|
+
# ARGF.read(0) #=> ""
|
689
|
+
#
|
690
|
+
# Note that this method behaves like the fread() function in C. This means it
|
691
|
+
# retries to invoke read(2) system calls to read data with the specified length.
|
692
|
+
# If you need the behavior like a single read(2) system call, consider
|
693
|
+
# ARGF#readpartial or ARGF#read_nonblock.
|
694
|
+
#
|
695
|
+
%a{annotate:rdoc:copy:ARGF#read}
|
696
|
+
def read: (?int? length, ?string outbuf) -> String?
|
697
|
+
|
698
|
+
# <!--
|
699
|
+
# rdoc-file=io.c
|
700
|
+
# - ARGF.read_nonblock(maxlen[, options]) -> string
|
701
|
+
# - ARGF.read_nonblock(maxlen, outbuf[, options]) -> outbuf
|
702
|
+
# -->
|
703
|
+
# Reads at most *maxlen* bytes from the ARGF stream in non-blocking mode.
|
704
|
+
#
|
705
|
+
%a{annotate:rdoc:copy:ARGF#read_nonblock}
|
706
|
+
def read_nonblock: (int maxlen, ?string buf, **untyped options) -> String
|
707
|
+
|
708
|
+
# <!--
|
709
|
+
# rdoc-file=io.c
|
710
|
+
# - ARGF.readbyte -> Integer
|
711
|
+
# -->
|
712
|
+
# Reads the next 8-bit byte from ARGF and returns it as an `Integer`. Raises an
|
713
|
+
# `EOFError` after the last byte of the last file has been read.
|
714
|
+
#
|
715
|
+
# For example:
|
716
|
+
#
|
717
|
+
# $ echo "foo" > file
|
718
|
+
# $ ruby argf.rb file
|
719
|
+
#
|
720
|
+
# ARGF.readbyte #=> 102
|
721
|
+
# ARGF.readbyte #=> 111
|
722
|
+
# ARGF.readbyte #=> 111
|
723
|
+
# ARGF.readbyte #=> 10
|
724
|
+
# ARGF.readbyte #=> end of file reached (EOFError)
|
725
|
+
#
|
726
|
+
%a{annotate:rdoc:copy:ARGF#readbyte}
|
727
|
+
def readbyte: () -> Integer
|
728
|
+
|
729
|
+
# <!--
|
730
|
+
# rdoc-file=io.c
|
731
|
+
# - ARGF.readchar -> String or nil
|
732
|
+
# -->
|
733
|
+
# Reads the next character from `ARGF` and returns it as a `String`. Raises an
|
734
|
+
# `EOFError` after the last character of the last file has been read.
|
735
|
+
#
|
736
|
+
# For example:
|
737
|
+
#
|
738
|
+
# $ echo "foo" > file
|
739
|
+
# $ ruby argf.rb file
|
740
|
+
#
|
741
|
+
# ARGF.readchar #=> "f"
|
742
|
+
# ARGF.readchar #=> "o"
|
743
|
+
# ARGF.readchar #=> "o"
|
744
|
+
# ARGF.readchar #=> "\n"
|
745
|
+
# ARGF.readchar #=> end of file reached (EOFError)
|
746
|
+
#
|
747
|
+
%a{annotate:rdoc:copy:ARGF#readchar}
|
748
|
+
def readchar: () -> String
|
749
|
+
|
750
|
+
# <!--
|
751
|
+
# rdoc-file=io.c
|
752
|
+
# - ARGF.readline(sep=$/) -> string
|
753
|
+
# - ARGF.readline(limit) -> string
|
754
|
+
# - ARGF.readline(sep, limit) -> string
|
755
|
+
# -->
|
756
|
+
# Returns the next line from the current file in `ARGF`.
|
757
|
+
#
|
758
|
+
# By default lines are assumed to be separated by `$/`; to use a different
|
759
|
+
# character as a separator, supply it as a `String` for the *sep* argument.
|
760
|
+
#
|
761
|
+
# The optional *limit* argument specifies how many characters of each line to
|
762
|
+
# return. By default all characters are returned.
|
763
|
+
#
|
764
|
+
# An `EOFError` is raised at the end of the file.
|
765
|
+
#
|
766
|
+
%a{annotate:rdoc:copy:ARGF#readline}
|
767
|
+
def readline: (?String sep, ?Integer limit) -> String
|
768
|
+
|
769
|
+
# <!--
|
770
|
+
# rdoc-file=io.c
|
771
|
+
# - ARGF.readlines(sep=$/) -> array
|
772
|
+
# - ARGF.readlines(limit) -> array
|
773
|
+
# - ARGF.readlines(sep, limit) -> array
|
774
|
+
# - ARGF.to_a(sep=$/) -> array
|
775
|
+
# - ARGF.to_a(limit) -> array
|
776
|
+
# - ARGF.to_a(sep, limit) -> array
|
777
|
+
# -->
|
778
|
+
# Reads `ARGF`'s current file in its entirety, returning an `Array` of its
|
779
|
+
# lines, one line per element. Lines are assumed to be separated by *sep*.
|
780
|
+
#
|
781
|
+
# lines = ARGF.readlines
|
782
|
+
# lines[0] #=> "This is line one\n"
|
783
|
+
#
|
784
|
+
%a{annotate:rdoc:copy:ARGF#readlines}
|
785
|
+
def readlines: (?String sep, ?Integer limit) -> ::Array[String]
|
786
|
+
|
787
|
+
# <!--
|
788
|
+
# rdoc-file=io.c
|
789
|
+
# - ARGF.readpartial(maxlen) -> string
|
790
|
+
# - ARGF.readpartial(maxlen, outbuf) -> outbuf
|
791
|
+
# -->
|
792
|
+
# Reads at most *maxlen* bytes from the ARGF stream.
|
793
|
+
#
|
794
|
+
# If the optional *outbuf* argument is present, it must reference a String,
|
795
|
+
# which will receive the data. The *outbuf* will contain only the received data
|
796
|
+
# after the method call even if it is not empty at the beginning.
|
797
|
+
#
|
798
|
+
# It raises EOFError on end of ARGF stream. Since ARGF stream is a concatenation
|
799
|
+
# of multiple files, internally EOF is occur for each file. ARGF.readpartial
|
800
|
+
# returns empty strings for EOFs except the last one and raises EOFError for the
|
801
|
+
# last one.
|
802
|
+
#
|
803
|
+
%a{annotate:rdoc:copy:ARGF#readpartial}
|
804
|
+
def readpartial: (int maxlen, ?string outbuf) -> String
|
805
|
+
|
806
|
+
# <!--
|
807
|
+
# rdoc-file=io.c
|
808
|
+
# - ARGF.rewind -> 0
|
809
|
+
# -->
|
810
|
+
# Positions the current file to the beginning of input, resetting `ARGF.lineno`
|
811
|
+
# to zero.
|
812
|
+
#
|
813
|
+
# ARGF.readline #=> "This is line one\n"
|
814
|
+
# ARGF.rewind #=> 0
|
815
|
+
# ARGF.lineno #=> 0
|
816
|
+
# ARGF.readline #=> "This is line one\n"
|
817
|
+
#
|
818
|
+
%a{annotate:rdoc:copy:ARGF#rewind}
|
819
|
+
def rewind: () -> Integer
|
820
|
+
|
821
|
+
# <!--
|
822
|
+
# rdoc-file=io.c
|
823
|
+
# - ARGF.seek(amount, whence=IO::SEEK_SET) -> 0
|
824
|
+
# -->
|
825
|
+
# Seeks to offset *amount* (an `Integer`) in the `ARGF` stream according to the
|
826
|
+
# value of *whence*. See IO#seek for further details.
|
827
|
+
#
|
828
|
+
%a{annotate:rdoc:copy:ARGF#seek}
|
829
|
+
def seek: (Integer amount, ?Integer whence) -> Integer
|
830
|
+
|
831
|
+
# <!--
|
832
|
+
# rdoc-file=io.c
|
833
|
+
# - ARGF.set_encoding(ext_enc) -> ARGF
|
834
|
+
# - ARGF.set_encoding("ext_enc:int_enc") -> ARGF
|
835
|
+
# - ARGF.set_encoding(ext_enc, int_enc) -> ARGF
|
836
|
+
# - ARGF.set_encoding("ext_enc:int_enc", opt) -> ARGF
|
837
|
+
# - ARGF.set_encoding(ext_enc, int_enc, opt) -> ARGF
|
838
|
+
# -->
|
839
|
+
# If single argument is specified, strings read from ARGF are tagged with the
|
840
|
+
# encoding specified.
|
841
|
+
#
|
842
|
+
# If two encoding names separated by a colon are given, e.g. "ascii:utf-8", the
|
843
|
+
# read string is converted from the first encoding (external encoding) to the
|
844
|
+
# second encoding (internal encoding), then tagged with the second encoding.
|
845
|
+
#
|
846
|
+
# If two arguments are specified, they must be encoding objects or encoding
|
847
|
+
# names. Again, the first specifies the external encoding; the second specifies
|
848
|
+
# the internal encoding.
|
849
|
+
#
|
850
|
+
# If the external encoding and the internal encoding are specified, the optional
|
851
|
+
# `Hash` argument can be used to adjust the conversion process. The structure of
|
852
|
+
# this hash is explained in the String#encode documentation.
|
853
|
+
#
|
854
|
+
# For example:
|
855
|
+
#
|
856
|
+
# ARGF.set_encoding('ascii') # Tag the input as US-ASCII text
|
857
|
+
# ARGF.set_encoding(Encoding::UTF_8) # Tag the input as UTF-8 text
|
858
|
+
# ARGF.set_encoding('utf-8','ascii') # Transcode the input from US-ASCII
|
859
|
+
# # to UTF-8.
|
860
|
+
#
|
861
|
+
%a{annotate:rdoc:copy:ARGF#set_encoding}
|
862
|
+
def set_encoding: (String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
|
863
|
+
|
864
|
+
# <!--
|
865
|
+
# rdoc-file=io.c
|
866
|
+
# - ARGF.skip -> ARGF
|
867
|
+
# -->
|
868
|
+
# Sets the current file to the next file in ARGV. If there aren't any more files
|
869
|
+
# it has no effect.
|
870
|
+
#
|
871
|
+
# For example:
|
872
|
+
#
|
873
|
+
# $ ruby argf.rb foo bar
|
874
|
+
# ARGF.filename #=> "foo"
|
875
|
+
# ARGF.skip
|
876
|
+
# ARGF.filename #=> "bar"
|
877
|
+
#
|
878
|
+
%a{annotate:rdoc:copy:ARGF#skip}
|
879
|
+
def skip: () -> self
|
880
|
+
|
881
|
+
# <!--
|
882
|
+
# rdoc-file=io.c
|
883
|
+
# - ARGF.tell -> Integer
|
884
|
+
# - ARGF.pos -> Integer
|
885
|
+
# -->
|
886
|
+
# Returns the current offset (in bytes) of the current file in `ARGF`.
|
887
|
+
#
|
888
|
+
# ARGF.pos #=> 0
|
889
|
+
# ARGF.gets #=> "This is line one\n"
|
890
|
+
# ARGF.pos #=> 17
|
891
|
+
#
|
892
|
+
%a{annotate:rdoc:copy:ARGF#tell}
|
893
|
+
def tell: () -> Integer
|
894
|
+
|
895
|
+
# <!-- rdoc-file=io.c -->
|
896
|
+
# Reads `ARGF`'s current file in its entirety, returning an `Array` of its
|
897
|
+
# lines, one line per element. Lines are assumed to be separated by *sep*.
|
898
|
+
#
|
899
|
+
# lines = ARGF.readlines
|
900
|
+
# lines[0] #=> "This is line one\n"
|
901
|
+
#
|
902
|
+
%a{annotate:rdoc:copy:ARGF#to_a}
|
903
|
+
def to_a: (?String sep, ?Integer limit) -> ::Array[String]
|
904
|
+
|
905
|
+
# <!-- rdoc-file=io.c -->
|
906
|
+
# Returns an integer representing the numeric file descriptor for the current
|
907
|
+
# file. Raises an `ArgumentError` if there isn't a current file.
|
908
|
+
#
|
909
|
+
# ARGF.fileno #=> 3
|
910
|
+
#
|
911
|
+
%a{annotate:rdoc:copy:ARGF#to_i}
|
912
|
+
def to_i: () -> Integer
|
913
|
+
|
914
|
+
# <!--
|
915
|
+
# rdoc-file=io.c
|
916
|
+
# - ARGF.to_io -> IO
|
917
|
+
# -->
|
918
|
+
# Returns an `IO` object representing the current file. This will be a `File`
|
919
|
+
# object unless the current file is a stream such as STDIN.
|
920
|
+
#
|
921
|
+
# For example:
|
922
|
+
#
|
923
|
+
# ARGF.to_io #=> #<File:glark.txt>
|
924
|
+
# ARGF.to_io #=> #<IO:<STDIN>>
|
925
|
+
#
|
926
|
+
%a{annotate:rdoc:copy:ARGF#to_io}
|
927
|
+
def to_io: () -> IO
|
928
|
+
|
929
|
+
# <!--
|
930
|
+
# rdoc-file=io.c
|
931
|
+
# - ARGF.to_s -> String
|
932
|
+
# -->
|
933
|
+
# Returns "ARGF".
|
934
|
+
#
|
935
|
+
%a{annotate:rdoc:copy:ARGF#to_s}
|
936
|
+
def to_s: () -> String
|
937
|
+
|
938
|
+
# <!--
|
939
|
+
# rdoc-file=io.c
|
940
|
+
# - ARGF.to_write_io -> io
|
941
|
+
# -->
|
942
|
+
# Returns IO instance tied to *ARGF* for writing if inplace mode is enabled.
|
943
|
+
#
|
944
|
+
%a{annotate:rdoc:copy:ARGF#to_write_io}
|
945
|
+
def to_write_io: () -> IO
|
946
|
+
|
947
|
+
# <!--
|
948
|
+
# rdoc-file=io.c
|
949
|
+
# - ARGF.write(string) -> integer
|
950
|
+
# -->
|
951
|
+
# Writes *string* if inplace mode.
|
952
|
+
#
|
953
|
+
%a{annotate:rdoc:copy:ARGF#write}
|
954
|
+
def write: (_ToS string) -> Integer
|
955
|
+
|
956
|
+
private
|
957
|
+
|
958
|
+
%a{annotate:rdoc:copy:ARGF#initialize}
|
959
|
+
def initialize: (*String argv) -> void
|
960
|
+
|
961
|
+
%a{annotate:rdoc:copy:ARGF#initialize_copy}
|
962
|
+
def initialize_copy: (self orig) -> self
|
963
|
+
end
|
964
|
+
end
|
965
|
+
end
|