rbs 3.0.0.dev.2 → 3.0.0.dev.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -1
  3. data/.github/workflows/ruby.yml +4 -0
  4. data/Gemfile.lock +11 -11
  5. data/Rakefile +2 -2
  6. data/Steepfile +1 -1
  7. data/core/array.rbs +573 -423
  8. data/core/basic_object.rbs +11 -39
  9. data/core/binding.rbs +1 -1
  10. data/core/builtin.rbs +8 -0
  11. data/core/class.rbs +37 -0
  12. data/core/comparable.rbs +7 -18
  13. data/core/complex.rbs +2 -2
  14. data/core/data.rbs +419 -0
  15. data/core/dir.rbs +52 -104
  16. data/core/encoding.rbs +22 -181
  17. data/core/enumerable.rbs +212 -175
  18. data/core/enumerator/product.rbs +96 -0
  19. data/core/enumerator.rbs +57 -8
  20. data/core/errors.rbs +8 -2
  21. data/core/exception.rbs +41 -0
  22. data/core/fiber.rbs +95 -12
  23. data/core/file.rbs +840 -275
  24. data/core/file_test.rbs +34 -19
  25. data/core/float.rbs +40 -96
  26. data/core/gc.rbs +15 -3
  27. data/core/hash.rbs +113 -175
  28. data/core/integer.rbs +85 -145
  29. data/core/io/buffer.rbs +187 -60
  30. data/core/io/wait.rbs +28 -16
  31. data/core/io.rbs +1859 -1389
  32. data/core/kernel.rbs +525 -961
  33. data/core/match_data.rbs +306 -142
  34. data/core/math.rbs +506 -234
  35. data/core/method.rbs +0 -24
  36. data/core/module.rbs +110 -17
  37. data/core/nil_class.rbs +2 -0
  38. data/core/numeric.rbs +76 -144
  39. data/core/object.rbs +88 -212
  40. data/core/proc.rbs +17 -5
  41. data/core/process.rbs +22 -5
  42. data/core/ractor.rbs +1 -1
  43. data/core/random.rbs +20 -3
  44. data/core/range.rbs +91 -89
  45. data/core/rational.rbs +2 -3
  46. data/core/rbs/unnamed/argf.rbs +177 -120
  47. data/core/rbs/unnamed/env_class.rbs +89 -163
  48. data/core/rbs/unnamed/random.rbs +36 -12
  49. data/core/refinement.rbs +8 -0
  50. data/core/regexp.rbs +462 -272
  51. data/core/ruby_vm.rbs +210 -0
  52. data/{stdlib/set/0 → core}/set.rbs +43 -47
  53. data/core/string.rbs +1403 -1332
  54. data/core/string_io.rbs +191 -107
  55. data/core/struct.rbs +67 -63
  56. data/core/symbol.rbs +187 -201
  57. data/core/thread.rbs +40 -35
  58. data/core/time.rbs +902 -826
  59. data/core/trace_point.rbs +55 -6
  60. data/core/unbound_method.rbs +48 -24
  61. data/docs/collection.md +4 -0
  62. data/docs/syntax.md +55 -0
  63. data/ext/rbs_extension/parser.c +5 -6
  64. data/lib/rbs/cli.rb +6 -1
  65. data/lib/rbs/collection/cleaner.rb +8 -1
  66. data/lib/rbs/collection/config/lockfile.rb +3 -1
  67. data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
  68. data/lib/rbs/collection/config.rb +1 -1
  69. data/lib/rbs/collection/sources/git.rb +9 -2
  70. data/lib/rbs/collection/sources/local.rb +79 -0
  71. data/lib/rbs/collection/sources.rb +8 -1
  72. data/lib/rbs/environment.rb +6 -5
  73. data/lib/rbs/environment_loader.rb +3 -2
  74. data/lib/rbs/errors.rb +18 -0
  75. data/lib/rbs/locator.rb +26 -7
  76. data/lib/rbs/sorter.rb +2 -2
  77. data/lib/rbs/version.rb +1 -1
  78. data/sig/collection/sources.rbs +32 -3
  79. data/sig/environment.rbs +2 -3
  80. data/sig/locator.rbs +14 -2
  81. data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
  82. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
  83. data/stdlib/cgi/0/core.rbs +16 -0
  84. data/stdlib/coverage/0/coverage.rbs +50 -8
  85. data/stdlib/csv/0/csv.rbs +1 -1
  86. data/stdlib/date/0/date.rbs +856 -726
  87. data/stdlib/date/0/date_time.rbs +83 -210
  88. data/stdlib/erb/0/erb.rbs +13 -36
  89. data/stdlib/etc/0/etc.rbs +127 -20
  90. data/stdlib/fileutils/0/fileutils.rbs +1290 -381
  91. data/stdlib/logger/0/logger.rbs +466 -316
  92. data/stdlib/net-http/0/net-http.rbs +2211 -534
  93. data/stdlib/nkf/0/nkf.rbs +5 -5
  94. data/stdlib/objspace/0/objspace.rbs +31 -14
  95. data/stdlib/openssl/0/openssl.rbs +11 -7
  96. data/stdlib/optparse/0/optparse.rbs +20 -17
  97. data/stdlib/pathname/0/pathname.rbs +21 -4
  98. data/stdlib/pstore/0/pstore.rbs +378 -154
  99. data/stdlib/pty/0/pty.rbs +24 -8
  100. data/stdlib/ripper/0/ripper.rbs +1650 -0
  101. data/stdlib/socket/0/addrinfo.rbs +9 -15
  102. data/stdlib/socket/0/socket.rbs +36 -3
  103. data/stdlib/strscan/0/string_scanner.rbs +7 -5
  104. data/stdlib/tempfile/0/tempfile.rbs +104 -44
  105. data/stdlib/time/0/time.rbs +2 -2
  106. data/stdlib/uri/0/file.rbs +5 -0
  107. data/stdlib/uri/0/generic.rbs +2 -2
  108. data/stdlib/yaml/0/yaml.rbs +2 -2
  109. data/stdlib/zlib/0/zlib.rbs +1 -1
  110. metadata +8 -6
  111. data/core/deprecated.rbs +0 -9
  112. data/sig/shims/ripper.rbs +0 -8
@@ -1,11 +1,11 @@
1
1
  module RBS
2
2
  module Unnamed
3
3
  # <!-- rdoc-file=io.c -->
4
- # `ARGF` is a stream designed for use in scripts that process files given as
4
+ # ARGF is a stream designed for use in scripts that process files given as
5
5
  # command-line arguments or passed in via STDIN.
6
6
  #
7
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
8
+ # argument per element. ARGF assumes that any arguments that aren't filenames
9
9
  # have been removed from `ARGV`. For example:
10
10
  #
11
11
  # $ ruby argf.rb --verbose file1 file2
@@ -14,17 +14,16 @@ module RBS
14
14
  # option = ARGV.shift #=> "--verbose"
15
15
  # ARGV #=> ["file1", "file2"]
16
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*.
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 by
19
+ # the contents of *file2*.
20
20
  #
21
- # After a file in `ARGV` has been read `ARGF` removes it from the Array. Thus,
21
+ # After a file in `ARGV` has been read ARGF removes it from the Array. Thus,
22
22
  # after all files have been read `ARGV` will be empty.
23
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:
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 `ARGV`,
26
+ # they are treated as if they were named on the command line. For example:
28
27
  #
29
28
  # ARGV.replace ["file1"]
30
29
  # ARGF.readlines # Returns the contents of file1 as an Array
@@ -32,8 +31,8 @@ module RBS
32
31
  # ARGV.replace ["file2", "file3"]
33
32
  # ARGF.read # Returns the contents of file2 and file3
34
33
  #
35
- # If `ARGV` is empty, `ARGF` acts as if it contained STDIN, i.e. the data piped
36
- # to your script. For example:
34
+ # If `ARGV` is empty, ARGF acts as if it contained STDIN, i.e. the data piped to
35
+ # your script. For example:
37
36
  #
38
37
  # $ echo "glark" | ruby -e 'p ARGF.read'
39
38
  # "glark\n"
@@ -64,7 +63,7 @@ module RBS
64
63
  # rdoc-file=io.c
65
64
  # - ARGF.binmode -> ARGF
66
65
  # -->
67
- # Puts `ARGF` into binary mode. Once a stream is in binary mode, it cannot be
66
+ # Puts ARGF into binary mode. Once a stream is in binary mode, it cannot be
68
67
  # reset to non-binary mode. This option has the following effects:
69
68
  #
70
69
  # * Newline conversion is disabled.
@@ -78,8 +77,8 @@ module RBS
78
77
  # rdoc-file=io.c
79
78
  # - ARGF.binmode? -> true or false
80
79
  # -->
81
- # Returns true if `ARGF` is being read in binary mode; false otherwise. To
82
- # enable binary mode use `ARGF.binmode`.
80
+ # Returns true if ARGF is being read in binary mode; false otherwise. To enable
81
+ # binary mode use ARGF.binmode.
83
82
  #
84
83
  # For example:
85
84
  #
@@ -95,7 +94,7 @@ module RBS
95
94
  # - ARGF.close -> ARGF
96
95
  # -->
97
96
  # 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.
97
+ # more files to open, just closes the current file. STDIN will not be closed.
99
98
  #
100
99
  # For example:
101
100
  #
@@ -114,7 +113,7 @@ module RBS
114
113
  # - ARGF.closed? -> true or false
115
114
  # -->
116
115
  # Returns *true* if the current file has been closed; *false* otherwise. Use
117
- # `ARGF.close` to actually close the current file.
116
+ # ARGF.close to actually close the current file.
118
117
  #
119
118
  %a{annotate:rdoc:copy:ARGF#closed?}
120
119
  def closed?: () -> bool
@@ -131,15 +130,15 @@ module RBS
131
130
  # Returns an enumerator which iterates over each line (separated by *sep*, which
132
131
  # defaults to your platform's newline character) of each file in `ARGV`. If a
133
132
  # 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`
133
+ # an enumerator is returned. The optional *limit* argument is an Integer
135
134
  # specifying the maximum length of each line; longer lines will be split
136
135
  # according to this limit.
137
136
  #
138
137
  # This method allows you to treat the files supplied on the command line as a
139
138
  # single file consisting of the concatenation of each named file. After the last
140
139
  # 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,
140
+ # returned. The ARGF.filename and ARGF.lineno methods can be used to determine
141
+ # the filename of the current line and line number of the whole input,
143
142
  # respectively.
144
143
  #
145
144
  # For example, the following code prints out each line of each named file
@@ -168,12 +167,12 @@ module RBS
168
167
  # - ARGF.each_byte -> an_enumerator
169
168
  # -->
170
169
  # Iterates over each byte of each file in `ARGV`. A byte is returned as an
171
- # `Integer` in the range 0..255.
170
+ # Integer in the range 0..255.
172
171
  #
173
172
  # This method allows you to treat the files supplied on the command line as a
174
173
  # single file consisting of the concatenation of each named file. After the last
175
174
  # 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
175
+ # returned. The ARGF.filename method can be used to determine the filename of
177
176
  # the current byte.
178
177
  #
179
178
  # If no block is given, an enumerator is returned instead.
@@ -191,13 +190,13 @@ module RBS
191
190
  # - ARGF.each_char {|char| block } -> ARGF
192
191
  # - ARGF.each_char -> an_enumerator
193
192
  # -->
194
- # Iterates over each character of each file in `ARGF`.
193
+ # Iterates over each character of each file in ARGF.
195
194
  #
196
195
  # This method allows you to treat the files supplied on the command line as a
197
196
  # single file consisting of the concatenation of each named file. After the last
198
197
  # 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.
198
+ # second file is returned. The ARGF.filename method can be used to determine the
199
+ # name of the file in which the current character appears.
201
200
  #
202
201
  # If no block is given, an enumerator is returned instead.
203
202
  #
@@ -210,13 +209,13 @@ module RBS
210
209
  # - ARGF.each_codepoint {|codepoint| block } -> ARGF
211
210
  # - ARGF.each_codepoint -> an_enumerator
212
211
  # -->
213
- # Iterates over each codepoint of each file in `ARGF`.
212
+ # Iterates over each codepoint of each file in ARGF.
214
213
  #
215
214
  # This method allows you to treat the files supplied on the command line as a
216
215
  # single file consisting of the concatenation of each named file. After the last
217
216
  # 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.
217
+ # second file is returned. The ARGF.filename method can be used to determine the
218
+ # name of the file in which the current codepoint appears.
220
219
  #
221
220
  # If no block is given, an enumerator is returned instead.
222
221
  #
@@ -228,15 +227,15 @@ module RBS
228
227
  # Returns an enumerator which iterates over each line (separated by *sep*, which
229
228
  # defaults to your platform's newline character) of each file in `ARGV`. If a
230
229
  # 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`
230
+ # an enumerator is returned. The optional *limit* argument is an Integer
232
231
  # specifying the maximum length of each line; longer lines will be split
233
232
  # according to this limit.
234
233
  #
235
234
  # This method allows you to treat the files supplied on the command line as a
236
235
  # single file consisting of the concatenation of each named file. After the last
237
236
  # 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,
237
+ # returned. The ARGF.filename and ARGF.lineno methods can be used to determine
238
+ # the filename of the current line and line number of the whole input,
240
239
  # respectively.
241
240
  #
242
241
  # For example, the following code prints out each line of each named file
@@ -264,8 +263,8 @@ module RBS
264
263
  # - ARGF.eof? -> true or false
265
264
  # - ARGF.eof -> true or false
266
265
  # -->
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
266
+ # Returns true if the current file in ARGF is at end of file, i.e. it has no
267
+ # data to read. The stream must be opened for reading or an IOError will be
269
268
  # raised.
270
269
  #
271
270
  # $ echo "eof" | ruby argf.rb
@@ -280,8 +279,8 @@ module RBS
280
279
  def eof: () -> bool
281
280
 
282
281
  # <!-- 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
282
+ # Returns true if the current file in ARGF is at end of file, i.e. it has no
283
+ # data to read. The stream must be opened for reading or an IOError will be
285
284
  # raised.
286
285
  #
287
286
  # $ echo "eof" | ruby argf.rb
@@ -299,12 +298,12 @@ module RBS
299
298
  # rdoc-file=io.c
300
299
  # - ARGF.external_encoding -> encoding
301
300
  # -->
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.
301
+ # Returns the external encoding for files read from ARGF as an Encoding object.
302
+ # The external encoding is the encoding of the text as stored in a file.
303
+ # Contrast with ARGF.internal_encoding, which is the encoding used to represent
304
+ # this text within Ruby.
306
305
  #
307
- # To set the external encoding use `ARGF.set_encoding`.
306
+ # To set the external encoding use ARGF.set_encoding.
308
307
  #
309
308
  # For example:
310
309
  #
@@ -317,8 +316,8 @@ module RBS
317
316
  # rdoc-file=io.c
318
317
  # - ARGF.file -> IO or File object
319
318
  # -->
320
- # Returns the current file as an `IO` or `File` object. `$stdin` is returned
321
- # when the current file is STDIN.
319
+ # Returns the current file as an IO or File object. `$stdin` is returned when
320
+ # the current file is STDIN.
322
321
  #
323
322
  # For example:
324
323
  #
@@ -364,7 +363,7 @@ module RBS
364
363
  # - ARGF.to_i -> integer
365
364
  # -->
366
365
  # Returns an integer representing the numeric file descriptor for the current
367
- # file. Raises an `ArgumentError` if there isn't a current file.
366
+ # file. Raises an ArgumentError if there isn't a current file.
368
367
  #
369
368
  # ARGF.fileno #=> 3
370
369
  #
@@ -375,7 +374,7 @@ module RBS
375
374
  # rdoc-file=io.c
376
375
  # - ARGF.getbyte -> Integer or nil
377
376
  # -->
378
- # Gets the next 8-bit byte (0..255) from `ARGF`. Returns `nil` if called at the
377
+ # Gets the next 8-bit byte (0..255) from ARGF. Returns `nil` if called at the
379
378
  # end of the stream.
380
379
  #
381
380
  # For example:
@@ -396,10 +395,10 @@ module RBS
396
395
  # rdoc-file=io.c
397
396
  # - ARGF.getc -> String or nil
398
397
  # -->
399
- # Reads the next character from `ARGF` and returns it as a `String`. Returns
400
- # `nil` at the end of the stream.
398
+ # Reads the next character from ARGF and returns it as a String. Returns `nil`
399
+ # at the end of the stream.
401
400
  #
402
- # `ARGF` treats the files named on the command line as a single file created by
401
+ # ARGF treats the files named on the command line as a single file created by
403
402
  # concatenating their contents. After returning the last character of the first
404
403
  # file, it returns the first character of the second file, and so on.
405
404
  #
@@ -424,10 +423,10 @@ module RBS
424
423
  # - ARGF.gets(limit [, getline_args]) -> string or nil
425
424
  # - ARGF.gets(sep, limit [, getline_args]) -> string or nil
426
425
  # -->
427
- # Returns the next line from the current file in `ARGF`.
426
+ # Returns the next line from the current file in ARGF.
428
427
  #
429
428
  # 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.
429
+ # character as a separator, supply it as a String for the *sep* argument.
431
430
  #
432
431
  # The optional *limit* argument specifies how many characters of each line to
433
432
  # return. By default all characters are returned.
@@ -441,9 +440,9 @@ module RBS
441
440
  # rdoc-file=io.c
442
441
  # - ARGF.inplace_mode -> String
443
442
  # -->
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.
443
+ # Returns the file extension appended to the names of backup copies of modified
444
+ # files under in-place edit mode. This value can be set using ARGF.inplace_mode=
445
+ # or passing the `-i` switch to the Ruby binary.
447
446
  #
448
447
  %a{annotate:rdoc:copy:ARGF#inplace_mode}
449
448
  def inplace_mode: () -> String?
@@ -452,9 +451,8 @@ module RBS
452
451
  # rdoc-file=io.c
453
452
  # - ARGF.inplace_mode = ext -> ARGF
454
453
  # -->
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.
454
+ # Sets the filename extension for in-place editing mode to the given String. The
455
+ # backup copy of each file being edited has this value appended to its filename.
458
456
  #
459
457
  # For example:
460
458
  #
@@ -465,8 +463,8 @@ module RBS
465
463
  # print line.sub("foo","bar")
466
464
  # end
467
465
  #
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*.
466
+ # First, *file.txt.bak* is created as a backup copy of *file.txt*. Then, each
467
+ # line of *file.txt* has the first occurrence of "foo" replaced with "bar".
470
468
  #
471
469
  %a{annotate:rdoc:copy:ARGF#inplace_mode=}
472
470
  def inplace_mode=: (String) -> self
@@ -477,10 +475,10 @@ module RBS
477
475
  # rdoc-file=io.c
478
476
  # - ARGF.internal_encoding -> encoding
479
477
  # -->
480
- # Returns the internal encoding for strings read from `ARGF` as an `Encoding`
478
+ # Returns the internal encoding for strings read from ARGF as an Encoding
481
479
  # object.
482
480
  #
483
- # If `ARGF.set_encoding` has been called with two encoding names, the second is
481
+ # If ARGF.set_encoding has been called with two encoding names, the second is
484
482
  # returned. Otherwise, if `Encoding.default_external` has been set, that value
485
483
  # is returned. Failing that, if a default external encoding was specified on the
486
484
  # command-line, that value is used. If the encoding is unknown, `nil` is
@@ -494,7 +492,7 @@ module RBS
494
492
  # - ARGF.lineno -> integer
495
493
  # -->
496
494
  # Returns the current line number of ARGF as a whole. This value can be set
497
- # manually with `ARGF.lineno=`.
495
+ # manually with ARGF.lineno=.
498
496
  #
499
497
  # For example:
500
498
  #
@@ -509,11 +507,11 @@ module RBS
509
507
  # rdoc-file=io.c
510
508
  # - ARGF.lineno = integer -> integer
511
509
  # -->
512
- # Sets the line number of `ARGF` as a whole to the given `Integer`.
510
+ # Sets the line number of ARGF as a whole to the given Integer.
513
511
  #
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`.
512
+ # ARGF sets the line number automatically as you read data, so normally you will
513
+ # not need to set it explicitly. To access the current line number use
514
+ # ARGF.lineno.
517
515
  #
518
516
  # For example:
519
517
  #
@@ -547,7 +545,7 @@ module RBS
547
545
  def path: () -> String
548
546
 
549
547
  # <!-- rdoc-file=io.c -->
550
- # Returns the current offset (in bytes) of the current file in `ARGF`.
548
+ # Returns the current offset (in bytes) of the current file in ARGF.
551
549
  #
552
550
  # ARGF.pos #=> 0
553
551
  # ARGF.gets #=> "This is line one\n"
@@ -560,7 +558,7 @@ module RBS
560
558
  # rdoc-file=io.c
561
559
  # - ARGF.pos = position -> Integer
562
560
  # -->
563
- # Seeks to the position given by *position* (in bytes) in `ARGF`.
561
+ # Seeks to the position given by *position* (in bytes) in ARGF.
564
562
  #
565
563
  # For example:
566
564
  #
@@ -572,50 +570,88 @@ module RBS
572
570
 
573
571
  # <!--
574
572
  # rdoc-file=io.c
575
- # - ios.print -> nil
576
- # - ios.print(obj, ...) -> nil
573
+ # - print(*objects) -> nil
577
574
  # -->
578
- # Writes the given object(s) to *ios*. Returns `nil`.
575
+ # Writes the given objects to the stream; returns `nil`. Appends the output
576
+ # record separator `$OUTPUT_RECORD_SEPARATOR` (`$\`), if it is not `nil`. See
577
+ # [Line IO](rdoc-ref:IO@Line+IO).
579
578
  #
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 `$_`.
579
+ # With argument `objects` given, for each object:
583
580
  #
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.
581
+ # * Converts via its method `to_s` if not a string.
582
+ # * Writes to the stream.
583
+ # * If not the last object, writes the output field separator
584
+ # `$OUTPUT_FIELD_SEPARATOR` (`$,`) if it is not `nil`.
587
585
  #
588
- # $stdout.print("This is ", 100, " percent.\n")
589
586
  #
590
- # *produces:*
587
+ # With default separators:
591
588
  #
592
- # This is 100 percent.
589
+ # f = File.open('t.tmp', 'w+')
590
+ # objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero']
591
+ # p $OUTPUT_RECORD_SEPARATOR
592
+ # p $OUTPUT_FIELD_SEPARATOR
593
+ # f.print(*objects)
594
+ # f.rewind
595
+ # p f.read
596
+ # f.close
597
+ #
598
+ # Output:
599
+ #
600
+ # nil
601
+ # nil
602
+ # "00.00/10+0izerozero"
603
+ #
604
+ # With specified separators:
605
+ #
606
+ # $\ = "\n"
607
+ # $, = ','
608
+ # f.rewind
609
+ # f.print(*objects)
610
+ # f.rewind
611
+ # p f.read
612
+ #
613
+ # Output:
614
+ #
615
+ # "0,0.0,0/1,0+0i,zero,zero\n"
616
+ #
617
+ # With no argument given, writes the content of `$_` (which is usually the most
618
+ # recent user input):
619
+ #
620
+ # f = File.open('t.tmp', 'w+')
621
+ # gets # Sets $_ to the most recent user input.
622
+ # f.print
623
+ # f.close
593
624
  #
594
625
  %a{annotate:rdoc:copy:ARGF#print}
595
626
  def print: (*untyped args) -> nil
596
627
 
597
628
  # <!--
598
629
  # rdoc-file=io.c
599
- # - ios.printf(format_string [, obj, ...]) -> nil
630
+ # - printf(format_string, *objects) -> nil
600
631
  # -->
601
- # Formats and writes to *ios*, converting parameters under control of the format
602
- # string. See Kernel#sprintf for details.
632
+ # Formats and writes `objects` to the stream.
633
+ #
634
+ # For details on `format_string`, see [Format
635
+ # Specifications](rdoc-ref:format_specifications.rdoc).
603
636
  #
604
637
  %a{annotate:rdoc:copy:ARGF#printf}
605
638
  def printf: (String format_string, *untyped args) -> nil
606
639
 
607
640
  # <!--
608
641
  # rdoc-file=io.c
609
- # - ios.putc(obj) -> obj
642
+ # - putc(object) -> object
610
643
  # -->
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.
644
+ # Writes a character to the stream. See [Character
645
+ # IO](rdoc-ref:IO@Character+IO).
646
+ #
647
+ # If `object` is numeric, converts to integer if necessary, then writes the
648
+ # character whose code is the least significant byte; if `object` is a string,
649
+ # writes the first character:
614
650
  #
615
651
  # $stdout.putc "A"
616
652
  # $stdout.putc 65
617
653
  #
618
- # *produces:*
654
+ # Output:
619
655
  #
620
656
  # AA
621
657
  #
@@ -624,27 +660,48 @@ module RBS
624
660
 
625
661
  # <!--
626
662
  # rdoc-file=io.c
627
- # - ios.puts(obj, ...) -> nil
663
+ # - puts(*objects) -> nil
628
664
  # -->
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`.
665
+ # Writes the given `objects` to the stream, which must be open for writing;
666
+ # returns `nil`.\ Writes a newline after each that does not already end with a
667
+ # newline sequence. If called without arguments, writes a newline. See [Line
668
+ # IO](rdoc-ref:IO@Line+IO).
669
+ #
670
+ # Note that each added newline is the character `"\n"<//tt>, not the output
671
+ # record separator (<tt>$\`).
672
+ #
673
+ # Treatment for each object:
631
674
  #
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.
675
+ # * String: writes the string.
676
+ # * Neither string nor array: writes `object.to_s`.
677
+ # * Array: writes each element of the array; arrays may be nested.
636
678
  #
637
- # $stdout.puts("this", "is", ["a", "test"])
638
679
  #
639
- # *produces:*
680
+ # To keep these examples brief, we define this helper method:
681
+ #
682
+ # def show(*objects)
683
+ # # Puts objects to file.
684
+ # f = File.new('t.tmp', 'w+')
685
+ # f.puts(objects)
686
+ # # Return file content.
687
+ # f.rewind
688
+ # p f.read
689
+ # f.close
690
+ # end
691
+ #
692
+ # # Strings without newlines.
693
+ # show('foo', 'bar', 'baz') # => "foo\nbar\nbaz\n"
694
+ # # Strings, some with newlines.
695
+ # show("foo\n", 'bar', "baz\n") # => "foo\nbar\nbaz\n"
640
696
  #
641
- # this
642
- # is
643
- # a
644
- # test
697
+ # # Neither strings nor arrays:
698
+ # show(0, 0.0, Rational(0, 1), Complex(9, 0), :zero)
699
+ # # => "0\n0.0\n0/1\n9+0i\nzero\n"
645
700
  #
646
- # Note that `puts` always uses newlines and is not affected by the output record
647
- # separator (`$\`).
701
+ # # Array of strings.
702
+ # show(['foo', "bar\n", 'baz']) # => "foo\nbar\nbaz\n"
703
+ # # Nested arrays.
704
+ # show([[[0, 1], 2, 3], 4, 5]) # => "0\n1\n2\n3\n4\n5\n"
648
705
  #
649
706
  %a{annotate:rdoc:copy:ARGF#puts}
650
707
  def puts: (*untyped obj) -> nil
@@ -709,8 +766,8 @@ module RBS
709
766
  # rdoc-file=io.c
710
767
  # - ARGF.readbyte -> Integer
711
768
  # -->
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.
769
+ # Reads the next 8-bit byte from ARGF and returns it as an Integer. Raises an
770
+ # EOFError after the last byte of the last file has been read.
714
771
  #
715
772
  # For example:
716
773
  #
@@ -730,8 +787,8 @@ module RBS
730
787
  # rdoc-file=io.c
731
788
  # - ARGF.readchar -> String or nil
732
789
  # -->
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.
790
+ # Reads the next character from ARGF and returns it as a String. Raises an
791
+ # EOFError after the last character of the last file has been read.
735
792
  #
736
793
  # For example:
737
794
  #
@@ -753,15 +810,15 @@ module RBS
753
810
  # - ARGF.readline(limit) -> string
754
811
  # - ARGF.readline(sep, limit) -> string
755
812
  # -->
756
- # Returns the next line from the current file in `ARGF`.
813
+ # Returns the next line from the current file in ARGF.
757
814
  #
758
815
  # 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.
816
+ # character as a separator, supply it as a String for the *sep* argument.
760
817
  #
761
818
  # The optional *limit* argument specifies how many characters of each line to
762
819
  # return. By default all characters are returned.
763
820
  #
764
- # An `EOFError` is raised at the end of the file.
821
+ # An EOFError is raised at the end of the file.
765
822
  #
766
823
  %a{annotate:rdoc:copy:ARGF#readline}
767
824
  def readline: (?String sep, ?Integer limit) -> String
@@ -775,8 +832,8 @@ module RBS
775
832
  # - ARGF.to_a(limit) -> array
776
833
  # - ARGF.to_a(sep, limit) -> array
777
834
  # -->
778
- # Reads each file in `ARGF` in its entirety, returning an `Array` containing
779
- # lines from the files. Lines are assumed to be separated by *sep*.
835
+ # Reads each file in ARGF in its entirety, returning an Array containing lines
836
+ # from the files. Lines are assumed to be separated by *sep*.
780
837
  #
781
838
  # lines = ARGF.readlines
782
839
  # lines[0] #=> "This is line one\n"
@@ -807,8 +864,8 @@ module RBS
807
864
  # rdoc-file=io.c
808
865
  # - ARGF.rewind -> 0
809
866
  # -->
810
- # Positions the current file to the beginning of input, resetting `ARGF.lineno`
811
- # to zero.
867
+ # Positions the current file to the beginning of input, resetting ARGF.lineno to
868
+ # zero.
812
869
  #
813
870
  # ARGF.readline #=> "This is line one\n"
814
871
  # ARGF.rewind #=> 0
@@ -822,7 +879,7 @@ module RBS
822
879
  # rdoc-file=io.c
823
880
  # - ARGF.seek(amount, whence=IO::SEEK_SET) -> 0
824
881
  # -->
825
- # Seeks to offset *amount* (an `Integer`) in the `ARGF` stream according to the
882
+ # Seeks to offset *amount* (an Integer) in the ARGF stream according to the
826
883
  # value of *whence*. See IO#seek for further details.
827
884
  #
828
885
  %a{annotate:rdoc:copy:ARGF#seek}
@@ -848,7 +905,7 @@ module RBS
848
905
  # the internal encoding.
849
906
  #
850
907
  # 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
908
+ # Hash argument can be used to adjust the conversion process. The structure of
852
909
  # this hash is explained in the String#encode documentation.
853
910
  #
854
911
  # For example:
@@ -883,7 +940,7 @@ module RBS
883
940
  # - ARGF.tell -> Integer
884
941
  # - ARGF.pos -> Integer
885
942
  # -->
886
- # Returns the current offset (in bytes) of the current file in `ARGF`.
943
+ # Returns the current offset (in bytes) of the current file in ARGF.
887
944
  #
888
945
  # ARGF.pos #=> 0
889
946
  # ARGF.gets #=> "This is line one\n"
@@ -893,8 +950,8 @@ module RBS
893
950
  def tell: () -> Integer
894
951
 
895
952
  # <!-- rdoc-file=io.c -->
896
- # Reads each file in `ARGF` in its entirety, returning an `Array` containing
897
- # lines from the files. Lines are assumed to be separated by *sep*.
953
+ # Reads each file in ARGF in its entirety, returning an Array containing lines
954
+ # from the files. Lines are assumed to be separated by *sep*.
898
955
  #
899
956
  # lines = ARGF.readlines
900
957
  # lines[0] #=> "This is line one\n"
@@ -904,7 +961,7 @@ module RBS
904
961
 
905
962
  # <!-- rdoc-file=io.c -->
906
963
  # Returns an integer representing the numeric file descriptor for the current
907
- # file. Raises an `ArgumentError` if there isn't a current file.
964
+ # file. Raises an ArgumentError if there isn't a current file.
908
965
  #
909
966
  # ARGF.fileno #=> 3
910
967
  #
@@ -915,8 +972,8 @@ module RBS
915
972
  # rdoc-file=io.c
916
973
  # - ARGF.to_io -> IO
917
974
  # -->
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.
975
+ # Returns an IO object representing the current file. This will be a File object
976
+ # unless the current file is a stream such as STDIN.
920
977
  #
921
978
  # For example:
922
979
  #