rbs 3.7.0 → 3.8.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +7 -7
- data/CHANGELOG.md +52 -0
- data/core/array.rbs +1743 -1580
- data/core/basic_object.rbs +38 -35
- data/core/comparable.rbs +1 -1
- data/core/complex.rbs +165 -93
- data/core/data.rbs +1 -1
- data/core/dir.rbs +1 -17
- data/core/encoding.rbs +12 -6
- data/core/enumerable.rbs +270 -266
- data/core/enumerator.rbs +0 -2
- data/core/env.rbs +1 -1
- data/core/errno.rbs +33 -16
- data/core/errors.rbs +2 -2
- data/core/exception.rbs +236 -170
- data/core/fiber.rbs +3 -2
- data/core/file.rbs +32 -74
- data/core/float.rbs +125 -72
- data/core/gc.rbs +138 -40
- data/core/hash.rbs +120 -141
- data/core/integer.rbs +79 -50
- data/core/io/buffer.rbs +49 -43
- data/core/io.rbs +97 -144
- data/core/kernel.rbs +290 -200
- data/core/match_data.rbs +76 -2
- data/core/math.rbs +0 -36
- data/core/module.rbs +28 -23
- data/core/nil_class.rbs +0 -3
- data/core/numeric.rbs +100 -103
- data/core/object.rbs +0 -4
- data/core/object_space/weak_key_map.rbs +3 -4
- data/core/object_space.rbs +3 -3
- data/core/proc.rbs +0 -2
- data/core/process.rbs +109 -57
- data/core/ractor.rbs +37 -4
- data/core/range.rbs +114 -87
- data/core/rational.rbs +0 -2
- data/core/rbs/unnamed/argf.rbs +234 -33
- data/core/rbs/unnamed/env_class.rbs +35 -53
- data/core/rbs/unnamed/random.rbs +1 -2
- data/core/regexp.rbs +4 -52
- data/core/ruby_vm.rbs +88 -9
- data/core/rubygems/config_file.rbs +3 -0
- data/core/rubygems/errors.rbs +0 -5
- data/core/rubygems/platform.rbs +0 -9
- data/core/rubygems/rubygems.rbs +0 -5
- data/core/rubygems/version.rbs +6 -6
- data/core/set.rbs +3 -15
- data/core/string.rbs +130 -136
- data/core/struct.rbs +6 -18
- data/core/symbol.rbs +14 -21
- data/core/thread.rbs +32 -35
- data/core/time.rbs +127 -50
- data/core/trace_point.rbs +16 -0
- data/core/true_class.rbs +0 -1
- data/core/warning.rbs +9 -2
- data/docs/architecture.md +1 -1
- data/docs/syntax.md +1 -1
- data/ext/rbs_extension/location.c +29 -19
- data/ext/rbs_extension/parser.c +267 -292
- data/ext/rbs_extension/parserstate.c +56 -22
- data/lib/rbs/annotate/annotations.rb +3 -3
- data/lib/rbs/annotate/rdoc_source.rb +2 -2
- data/lib/rbs/cli/diff.rb +3 -3
- data/lib/rbs/cli/validate.rb +1 -1
- data/lib/rbs/cli.rb +13 -13
- data/lib/rbs/collection/config.rb +3 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +3 -3
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/namespace.rb +1 -0
- data/lib/rbs/parser_aux.rb +2 -2
- data/lib/rbs/prototype/rb.rb +11 -8
- data/lib/rbs/prototype/rbi.rb +9 -5
- data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
- data/lib/rbs/prototype/runtime.rb +4 -5
- data/lib/rbs/type_name.rb +14 -9
- data/lib/rbs/unit_test/type_assertions.rb +2 -2
- data/lib/rbs/validator.rb +3 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +2 -2
- data/rbs.gemspec +4 -0
- data/sig/ancestor_graph.rbs +4 -4
- data/sig/namespace.rbs +2 -3
- data/sig/resolver/constant_resolver.rbs +2 -2
- data/sig/resolver/context.rbs +1 -1
- data/sig/type_alias_regularity.rbs +5 -5
- data/sig/typename.rbs +8 -5
- data/sig/use_map.rbs +1 -1
- data/sig/validator.rbs +2 -2
- data/stdlib/base64/0/base64.rbs +0 -9
- data/stdlib/benchmark/0/benchmark.rbs +11 -2
- data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
- data/stdlib/cgi/0/core.rbs +47 -0
- data/stdlib/coverage/0/coverage.rbs +0 -3
- data/stdlib/csv/0/csv.rbs +18 -58
- data/stdlib/date/0/date.rbs +4 -19
- data/stdlib/did_you_mean/0/did_you_mean.rbs +0 -5
- data/stdlib/digest/0/digest.rbs +25 -2
- data/stdlib/erb/0/erb.rbs +0 -1
- data/stdlib/etc/0/etc.rbs +51 -34
- data/stdlib/fileutils/0/fileutils.rbs +3 -44
- data/stdlib/io-console/0/io-console.rbs +69 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +8 -4
- data/stdlib/json/0/json.rbs +56 -71
- data/stdlib/logger/0/log_device.rbs +1 -1
- data/stdlib/logger/0/logger.rbs +3 -18
- data/stdlib/net-http/0/net-http.rbs +19 -77
- data/stdlib/nkf/0/nkf.rbs +30 -0
- data/stdlib/objspace/0/objspace.rbs +1 -2
- data/stdlib/observable/0/observable.rbs +1 -1
- data/stdlib/open-uri/0/open-uri.rbs +52 -0
- data/stdlib/open3/0/open3.rbs +0 -8
- data/stdlib/openssl/0/openssl.rbs +136 -69
- data/stdlib/optparse/0/optparse.rbs +58 -18
- data/stdlib/pathname/0/pathname.rbs +2 -8
- data/stdlib/pp/0/pp.rbs +3 -1
- data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
- data/stdlib/pstore/0/pstore.rbs +0 -6
- data/stdlib/psych/0/psych.rbs +15 -4
- data/stdlib/pty/0/pty.rbs +46 -4
- data/stdlib/rdoc/0/code_object.rbs +0 -4
- data/stdlib/rdoc/0/markup.rbs +10 -12
- data/stdlib/rdoc/0/rdoc.rbs +1 -2
- data/stdlib/resolv/0/resolv.rbs +8 -3
- data/stdlib/ripper/0/ripper.rbs +0 -2
- data/stdlib/securerandom/0/securerandom.rbs +0 -2
- data/stdlib/shellwords/0/shellwords.rbs +11 -12
- data/stdlib/singleton/0/singleton.rbs +0 -1
- data/stdlib/socket/0/addrinfo.rbs +0 -1
- data/stdlib/socket/0/basic_socket.rbs +0 -5
- data/stdlib/socket/0/socket.rbs +49 -25
- data/stdlib/socket/0/tcp_server.rbs +0 -3
- data/stdlib/socket/0/tcp_socket.rbs +58 -3
- data/stdlib/socket/0/udp_socket.rbs +0 -1
- data/stdlib/socket/0/unix_server.rbs +0 -3
- data/stdlib/strscan/0/string_scanner.rbs +1265 -422
- data/stdlib/tempfile/0/tempfile.rbs +135 -28
- data/stdlib/time/0/time.rbs +48 -35
- data/stdlib/timeout/0/timeout.rbs +11 -8
- data/stdlib/tmpdir/0/tmpdir.rbs +8 -1
- data/stdlib/tsort/0/tsort.rbs +0 -4
- data/stdlib/uri/0/common.rbs +11 -30
- data/stdlib/uri/0/ftp.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +22 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
- data/stdlib/zlib/0/buf_error.rbs +1 -70
- data/stdlib/zlib/0/data_error.rbs +1 -70
- data/stdlib/zlib/0/deflate.rbs +8 -72
- data/stdlib/zlib/0/error.rbs +1 -70
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
- data/stdlib/zlib/0/gzip_file.rbs +1 -71
- data/stdlib/zlib/0/gzip_reader.rbs +3 -74
- data/stdlib/zlib/0/gzip_writer.rbs +1 -70
- data/stdlib/zlib/0/inflate.rbs +4 -71
- data/stdlib/zlib/0/mem_error.rbs +1 -70
- data/stdlib/zlib/0/need_dict.rbs +1 -70
- data/stdlib/zlib/0/stream_end.rbs +1 -70
- data/stdlib/zlib/0/stream_error.rbs +1 -70
- data/stdlib/zlib/0/version_error.rbs +1 -70
- data/stdlib/zlib/0/zlib.rbs +0 -2
- data/stdlib/zlib/0/zstream.rbs +4 -72
- metadata +4 -6
data/core/rbs/unnamed/argf.rbs
CHANGED
@@ -1,45 +1,248 @@
|
|
1
1
|
module RBS
|
2
2
|
module Unnamed
|
3
3
|
# <!-- rdoc-file=io.c -->
|
4
|
-
# ARGF
|
5
|
-
# command-line arguments or passed in via STDIN.
|
4
|
+
# ## ARGF and `ARGV`
|
6
5
|
#
|
7
|
-
# The
|
8
|
-
#
|
9
|
-
# have been removed from `ARGV`. For example:
|
6
|
+
# The ARGF object works with the array at global variable `ARGV` to make
|
7
|
+
# `$stdin` and file streams available in the Ruby program:
|
10
8
|
#
|
11
|
-
#
|
9
|
+
# * **ARGV** may be thought of as the **argument vector** array.
|
12
10
|
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# ARGV #=> ["file1", "file2"]
|
11
|
+
# Initially, it contains the command-line arguments and options that are
|
12
|
+
# passed to the Ruby program; the program can modify that array as it likes.
|
16
13
|
#
|
17
|
-
#
|
18
|
-
# files. For instance, ARGF.read will return the contents of *file1* followed by
|
19
|
-
# the contents of *file2*.
|
14
|
+
# * **ARGF** may be thought of as the **argument files** object.
|
20
15
|
#
|
21
|
-
#
|
22
|
-
#
|
16
|
+
# It can access file streams and/or the `$stdin` stream, based on what it
|
17
|
+
# finds in `ARGV`. This provides a convenient way for the command line to
|
18
|
+
# specify streams for a Ruby program to read.
|
23
19
|
#
|
24
|
-
#
|
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:
|
20
|
+
# ## Reading
|
27
21
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# ARGV #=> []
|
31
|
-
# ARGV.replace ["file2", "file3"]
|
32
|
-
# ARGF.read # Returns the contents of file2 and file3
|
22
|
+
# ARGF may read from *source* streams, which at any particular time are
|
23
|
+
# determined by the content of `ARGV`.
|
33
24
|
#
|
34
|
-
#
|
35
|
-
# from STDIN, i.e. the data piped or typed to your script. For example:
|
25
|
+
# ### Simplest Case
|
36
26
|
#
|
37
|
-
#
|
38
|
-
#
|
27
|
+
# When the *very first* ARGF read occurs with an empty `ARGV` (`[]`), the source
|
28
|
+
# is `$stdin`:
|
39
29
|
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
30
|
+
# * File `t.rb`:
|
31
|
+
#
|
32
|
+
# p ['ARGV', ARGV]
|
33
|
+
# p ['ARGF.read', ARGF.read]
|
34
|
+
#
|
35
|
+
# * Commands and outputs (see below for the content of files `foo.txt` and
|
36
|
+
# `bar.txt`):
|
37
|
+
#
|
38
|
+
# $ echo "Open the pod bay doors, Hal." | ruby t.rb
|
39
|
+
# ["ARGV", []]
|
40
|
+
# ["ARGF.read", "Open the pod bay doors, Hal.\n"]
|
41
|
+
#
|
42
|
+
# $ cat foo.txt bar.txt | ruby t.rb
|
43
|
+
# ["ARGV", []]
|
44
|
+
# ["ARGF.read", "Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"]
|
45
|
+
#
|
46
|
+
# ### About the Examples
|
47
|
+
#
|
48
|
+
# Many examples here assume the existence of files `foo.txt` and `bar.txt`:
|
49
|
+
#
|
50
|
+
# $ cat foo.txt
|
51
|
+
# Foo 0
|
52
|
+
# Foo 1
|
53
|
+
# $ cat bar.txt
|
54
|
+
# Bar 0
|
55
|
+
# Bar 1
|
56
|
+
# Bar 2
|
57
|
+
# Bar 3
|
58
|
+
#
|
59
|
+
# ### Sources in `ARGV`
|
60
|
+
#
|
61
|
+
# For any ARGF read *except* the [simplest case](rdoc-ref:ARGF@Simplest+Case)
|
62
|
+
# (that is, *except* for the *very first* ARGF read with an empty `ARGV`), the
|
63
|
+
# sources are found in `ARGV`.
|
64
|
+
#
|
65
|
+
# ARGF assumes that each element in array `ARGV` is a potential source, and is
|
66
|
+
# one of:
|
67
|
+
#
|
68
|
+
# * The string path to a file that may be opened as a stream.
|
69
|
+
# * The character `'-'`, meaning stream `$stdin`.
|
70
|
+
#
|
71
|
+
# Each element that is *not* one of these should be removed from `ARGV` before
|
72
|
+
# ARGF accesses that source.
|
73
|
+
#
|
74
|
+
# In the following example:
|
75
|
+
#
|
76
|
+
# * Filepaths `foo.txt` and `bar.txt` may be retained as potential sources.
|
77
|
+
# * Options `--xyzzy` and `--mojo` should be removed.
|
78
|
+
#
|
79
|
+
# Example:
|
80
|
+
#
|
81
|
+
# * File `t.rb`:
|
82
|
+
#
|
83
|
+
# # Print arguments (and options, if any) found on command line.
|
84
|
+
# p ['ARGV', ARGV]
|
85
|
+
#
|
86
|
+
# * Command and output:
|
87
|
+
#
|
88
|
+
# $ ruby t.rb --xyzzy --mojo foo.txt bar.txt
|
89
|
+
# ["ARGV", ["--xyzzy", "--mojo", "foo.txt", "bar.txt"]]
|
90
|
+
#
|
91
|
+
# ARGF's stream access considers the elements of `ARGV`, left to right:
|
92
|
+
#
|
93
|
+
# * File `t.rb`:
|
94
|
+
#
|
95
|
+
# p "ARGV: #{ARGV}"
|
96
|
+
# p "Line: #{ARGF.read}" # Read everything from all specified streams.
|
97
|
+
#
|
98
|
+
# * Command and output:
|
99
|
+
#
|
100
|
+
# $ ruby t.rb foo.txt bar.txt
|
101
|
+
# "ARGV: [\"foo.txt\", \"bar.txt\"]"
|
102
|
+
# "Read: Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"
|
103
|
+
#
|
104
|
+
# Because the value at `ARGV` is an ordinary array, you can manipulate it to
|
105
|
+
# control which sources ARGF considers:
|
106
|
+
#
|
107
|
+
# * If you remove an element from `ARGV`, ARGF will not consider the
|
108
|
+
# corresponding source.
|
109
|
+
# * If you add an element to `ARGV`, ARGF will consider the corresponding
|
110
|
+
# source.
|
111
|
+
#
|
112
|
+
# Each element in `ARGV` is removed when its corresponding source is accessed;
|
113
|
+
# when all sources have been accessed, the array is empty:
|
114
|
+
#
|
115
|
+
# * File `t.rb`:
|
116
|
+
#
|
117
|
+
# until ARGV.empty? && ARGF.eof?
|
118
|
+
# p "ARGV: #{ARGV}"
|
119
|
+
# p "Line: #{ARGF.readline}" # Read each line from each specified stream.
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
# * Command and output:
|
123
|
+
#
|
124
|
+
# $ ruby t.rb foo.txt bar.txt
|
125
|
+
# "ARGV: [\"foo.txt\", \"bar.txt\"]"
|
126
|
+
# "Line: Foo 0\n"
|
127
|
+
# "ARGV: [\"bar.txt\"]"
|
128
|
+
# "Line: Foo 1\n"
|
129
|
+
# "ARGV: [\"bar.txt\"]"
|
130
|
+
# "Line: Bar 0\n"
|
131
|
+
# "ARGV: []"
|
132
|
+
# "Line: Bar 1\n"
|
133
|
+
# "ARGV: []"
|
134
|
+
# "Line: Bar 2\n"
|
135
|
+
# "ARGV: []"
|
136
|
+
# "Line: Bar 3\n"
|
137
|
+
#
|
138
|
+
# #### Filepaths in `ARGV`
|
139
|
+
#
|
140
|
+
# The `ARGV` array may contain filepaths the specify sources for ARGF reading.
|
141
|
+
#
|
142
|
+
# This program prints what it reads from files at the paths specified on the
|
143
|
+
# command line:
|
144
|
+
#
|
145
|
+
# * File `t.rb`:
|
146
|
+
#
|
147
|
+
# p ['ARGV', ARGV]
|
148
|
+
# # Read and print all content from the specified sources.
|
149
|
+
# p ['ARGF.read', ARGF.read]
|
150
|
+
#
|
151
|
+
# * Command and output:
|
152
|
+
#
|
153
|
+
# $ ruby t.rb foo.txt bar.txt
|
154
|
+
# ["ARGV", [foo.txt, bar.txt]
|
155
|
+
# ["ARGF.read", "Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"]
|
156
|
+
#
|
157
|
+
# #### Specifying `$stdin` in `ARGV`
|
158
|
+
#
|
159
|
+
# To specify stream `$stdin` in `ARGV`, us the character `'-'`:
|
160
|
+
#
|
161
|
+
# * File `t.rb`:
|
162
|
+
#
|
163
|
+
# p ['ARGV', ARGV]
|
164
|
+
# p ['ARGF.read', ARGF.read]
|
165
|
+
#
|
166
|
+
# * Command and output:
|
167
|
+
#
|
168
|
+
# $ echo "Open the pod bay doors, Hal." | ruby t.rb -
|
169
|
+
# ["ARGV", ["-"]]
|
170
|
+
# ["ARGF.read", "Open the pod bay doors, Hal.\n"]
|
171
|
+
#
|
172
|
+
# When no character `'-'` is given, stream `$stdin` is ignored (exception: see
|
173
|
+
# [Specifying $stdin in ARGV](rdoc-ref:ARGF@Specifying+-24stdin+in+ARGV)):
|
174
|
+
#
|
175
|
+
# * Command and output:
|
176
|
+
#
|
177
|
+
# $ echo "Open the pod bay doors, Hal." | ruby t.rb foo.txt bar.txt
|
178
|
+
# "ARGV: [\"foo.txt\", \"bar.txt\"]"
|
179
|
+
# "Read: Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"
|
180
|
+
#
|
181
|
+
# #### Mixtures and Repetitions in `ARGV`
|
182
|
+
#
|
183
|
+
# For an ARGF reader, `ARGV` may contain any mixture of filepaths and character
|
184
|
+
# `'-'`, including repetitions.
|
185
|
+
#
|
186
|
+
# #### Modifications to `ARGV`
|
187
|
+
#
|
188
|
+
# The running Ruby program may make any modifications to the `ARGV` array; the
|
189
|
+
# current value of `ARGV` affects ARGF reading.
|
190
|
+
#
|
191
|
+
# #### Empty `ARGV`
|
192
|
+
#
|
193
|
+
# For an empty `ARGV`, an ARGF read method either returns `nil` or raises an
|
194
|
+
# exception, depending on the specific method.
|
195
|
+
#
|
196
|
+
# ### More Read Methods
|
197
|
+
#
|
198
|
+
# As seen above, method ARGF#read reads the content of all sources into a single
|
199
|
+
# string. Other ARGF methods provide other ways to access that content; these
|
200
|
+
# include:
|
201
|
+
#
|
202
|
+
# * Byte access: #each_byte, #getbyte, #readbyte.
|
203
|
+
# * Character access: #each_char, #getc, #readchar.
|
204
|
+
# * Codepoint access: #each_codepoint.
|
205
|
+
# * Line access: #each_line, #gets, #readline, #readlines.
|
206
|
+
# * Source access: #read, #read_nonblock, #readpartial.
|
207
|
+
#
|
208
|
+
# ### About Enumerable
|
209
|
+
#
|
210
|
+
# ARGF includes module Enumerable. Virtually all methods in Enumerable call
|
211
|
+
# method `#each` in the including class.
|
212
|
+
#
|
213
|
+
# **Note well**: In ARGF, method #each returns data from the *sources*, *not*
|
214
|
+
# from `ARGV`; therefore, for example, `ARGF#entries` returns an array of lines
|
215
|
+
# from the sources, not an array of the strings from `ARGV`:
|
216
|
+
#
|
217
|
+
# * File `t.rb`:
|
218
|
+
#
|
219
|
+
# p ['ARGV', ARGV]
|
220
|
+
# p ['ARGF.entries', ARGF.entries]
|
221
|
+
#
|
222
|
+
# * Command and output:
|
223
|
+
#
|
224
|
+
# $ ruby t.rb foo.txt bar.txt
|
225
|
+
# ["ARGV", ["foo.txt", "bar.txt"]]
|
226
|
+
# ["ARGF.entries", ["Foo 0\n", "Foo 1\n", "Bar 0\n", "Bar 1\n", "Bar 2\n", "Bar 3\n"]]
|
227
|
+
#
|
228
|
+
# ## Writing
|
229
|
+
#
|
230
|
+
# If *inplace mode* is in effect, ARGF may write to target streams, which at any
|
231
|
+
# particular time are determined by the content of ARGV.
|
232
|
+
#
|
233
|
+
# Methods about inplace mode:
|
234
|
+
#
|
235
|
+
# * #inplace_mode
|
236
|
+
# * #inplace_mode=
|
237
|
+
# * #to_write_io
|
238
|
+
#
|
239
|
+
# Methods for writing:
|
240
|
+
#
|
241
|
+
# * #print
|
242
|
+
# * #printf
|
243
|
+
# * #putc
|
244
|
+
# * #puts
|
245
|
+
# * #write
|
43
246
|
#
|
44
247
|
%a{annotate:rdoc:copy:ARGF}
|
45
248
|
class ARGFClass
|
@@ -585,7 +788,6 @@ module RBS
|
|
585
788
|
# * If not the last object, writes the output field separator
|
586
789
|
# `$OUTPUT_FIELD_SEPARATOR` (`$,`) if it is not `nil`.
|
587
790
|
#
|
588
|
-
#
|
589
791
|
# With default separators:
|
590
792
|
#
|
591
793
|
# f = File.open('t.tmp', 'w+')
|
@@ -678,7 +880,6 @@ module RBS
|
|
678
880
|
# * Neither string nor array: writes `object.to_s`.
|
679
881
|
# * Array: writes each element of the array; arrays may be nested.
|
680
882
|
#
|
681
|
-
#
|
682
883
|
# To keep these examples brief, we define this helper method:
|
683
884
|
#
|
684
885
|
# def show(*objects)
|
@@ -1009,9 +1210,9 @@ module RBS
|
|
1009
1210
|
|
1010
1211
|
# <!--
|
1011
1212
|
# rdoc-file=io.c
|
1012
|
-
# - ARGF.write(
|
1213
|
+
# - ARGF.write(*objects) -> integer
|
1013
1214
|
# -->
|
1014
|
-
# Writes
|
1215
|
+
# Writes each of the given `objects` if inplace mode.
|
1015
1216
|
#
|
1016
1217
|
%a{annotate:rdoc:copy:ARGF#write}
|
1017
1218
|
def write: (_ToS string) -> Integer
|
@@ -1,20 +1,19 @@
|
|
1
1
|
module RBS
|
2
2
|
module Unnamed
|
3
3
|
# <!-- rdoc-file=hash.c -->
|
4
|
-
# ENV is a hash-like accessor for environment variables.
|
4
|
+
# `ENV` is a hash-like accessor for environment variables.
|
5
5
|
#
|
6
6
|
# ### Interaction with the Operating System
|
7
7
|
#
|
8
|
-
# The ENV object interacts with the operating system's environment variables:
|
8
|
+
# The `ENV` object interacts with the operating system's environment variables:
|
9
9
|
#
|
10
|
-
# * When you get the value for a name in ENV
|
10
|
+
# * When you get the value for a name in `ENV`, the value is retrieved from
|
11
11
|
# among the current environment variables.
|
12
|
-
# * When you create or set a name-value pair in ENV
|
12
|
+
# * When you create or set a name-value pair in `ENV`, the name and value are
|
13
13
|
# immediately set in the environment variables.
|
14
|
-
# * When you delete a name-value pair in ENV
|
14
|
+
# * When you delete a name-value pair in `ENV`, it is immediately deleted from
|
15
15
|
# the environment variables.
|
16
16
|
#
|
17
|
-
#
|
18
17
|
# ### Names and Values
|
19
18
|
#
|
20
19
|
# Generally, a name or value is a String.
|
@@ -27,7 +26,6 @@ module RBS
|
|
27
26
|
# * An object that responds to #to_str by returning a String, in which case
|
28
27
|
# that String will be used as the name or value.
|
29
28
|
#
|
30
|
-
#
|
31
29
|
# #### Invalid Names and Values
|
32
30
|
#
|
33
31
|
# A new name:
|
@@ -40,7 +38,6 @@ module RBS
|
|
40
38
|
# ENV['='] = '0'
|
41
39
|
# # Raises Errno::EINVAL (Invalid argument - ruby_setenv(=))
|
42
40
|
#
|
43
|
-
#
|
44
41
|
# A new name or value:
|
45
42
|
#
|
46
43
|
# * May not be a non-String that does not respond to #to_str:
|
@@ -65,39 +62,36 @@ module RBS
|
|
65
62
|
# ENV["foo".force_encoding(Encoding::ISO_2022_JP)] = '0'
|
66
63
|
# # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP)
|
67
64
|
#
|
68
|
-
#
|
69
65
|
# ### About Ordering
|
70
66
|
#
|
71
|
-
# ENV enumerates its name/value pairs in the order found in the operating
|
72
|
-
# system's environment variables. Therefore the ordering of ENV content is
|
67
|
+
# `ENV` enumerates its name/value pairs in the order found in the operating
|
68
|
+
# system's environment variables. Therefore the ordering of `ENV` content is
|
73
69
|
# OS-dependent, and may be indeterminate.
|
74
70
|
#
|
75
71
|
# This will be seen in:
|
76
|
-
# * A Hash returned by an ENV method.
|
77
|
-
# * An Enumerator returned by an ENV method.
|
72
|
+
# * A Hash returned by an `ENV` method.
|
73
|
+
# * An Enumerator returned by an `ENV` method.
|
78
74
|
# * An Array returned by ENV.keys, ENV.values, or ENV.to_a.
|
79
75
|
# * The String returned by ENV.inspect.
|
80
76
|
# * The Array returned by ENV.shift.
|
81
77
|
# * The name returned by ENV.key.
|
82
78
|
#
|
83
|
-
#
|
84
79
|
# ### About the Examples
|
85
|
-
# Some methods in ENV return ENV itself. Typically, there are many
|
86
|
-
# variables. It's not useful to display a large ENV in the
|
87
|
-
# most example snippets begin by resetting the contents of
|
88
|
-
#
|
89
|
-
# * ENV.
|
80
|
+
# Some methods in `ENV` return `ENV` itself. Typically, there are many
|
81
|
+
# environment variables. It's not useful to display a large `ENV` in the
|
82
|
+
# examples here, so most example snippets begin by resetting the contents of
|
83
|
+
# `ENV`:
|
84
|
+
# * ENV.replace replaces `ENV` with a new collection of entries.
|
85
|
+
# * ENV.clear empties `ENV`.
|
90
86
|
#
|
87
|
+
# ### What's Here
|
91
88
|
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
# First, what's elsewhere. Class ENV:
|
89
|
+
# First, what's elsewhere. Class `ENV`:
|
95
90
|
#
|
96
91
|
# * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
|
97
92
|
# * Extends [module Enumerable](rdoc-ref:Enumerable@What-27s+Here),
|
98
93
|
#
|
99
|
-
#
|
100
|
-
# Here, class ENV provides methods that are useful for:
|
94
|
+
# Here, class `ENV` provides methods that are useful for:
|
101
95
|
#
|
102
96
|
# * [Querying](rdoc-ref:ENV@Methods+for+Querying)
|
103
97
|
# * [Assigning](rdoc-ref:ENV@Methods+for+Assigning)
|
@@ -106,31 +100,28 @@ module RBS
|
|
106
100
|
# * [Converting](rdoc-ref:ENV@Methods+for+Converting)
|
107
101
|
# * [And more ....](rdoc-ref:ENV@More+Methods)
|
108
102
|
#
|
109
|
-
#
|
110
|
-
# ### Methods for Querying
|
103
|
+
# #### Methods for Querying
|
111
104
|
#
|
112
105
|
# * ::[]: Returns the value for the given environment variable name if it
|
113
106
|
# exists:
|
114
|
-
# * ::empty?: Returns whether ENV is empty.
|
115
|
-
# * ::has_value?, ::value?: Returns whether the given value is in ENV
|
107
|
+
# * ::empty?: Returns whether `ENV` is empty.
|
108
|
+
# * ::has_value?, ::value?: Returns whether the given value is in `ENV`.
|
116
109
|
# * ::include?, ::has_key?, ::key?, ::member?: Returns whether the given name
|
117
|
-
# is in ENV
|
110
|
+
# is in `ENV`.
|
118
111
|
# * ::key: Returns the name of the first entry with the given value.
|
119
112
|
# * ::size, ::length: Returns the number of entries.
|
120
113
|
# * ::value?: Returns whether any entry has the given value.
|
121
114
|
#
|
122
|
-
#
|
123
|
-
# ### Methods for Assigning
|
115
|
+
# #### Methods for Assigning
|
124
116
|
#
|
125
117
|
# * ::[]=, ::store: Creates, updates, or deletes the named environment
|
126
118
|
# variable.
|
127
|
-
# * ::clear: Removes every environment variable; returns ENV
|
128
|
-
# * ::update, ::merge!: Adds to ENV each key/value pair in the given hash.
|
129
|
-
# * ::replace: Replaces the entire content of the ENV with the name/value
|
119
|
+
# * ::clear: Removes every environment variable; returns `ENV`:
|
120
|
+
# * ::update, ::merge!: Adds to `ENV` each key/value pair in the given hash.
|
121
|
+
# * ::replace: Replaces the entire content of the `ENV` with the name/value
|
130
122
|
# pairs in the given hash.
|
131
123
|
#
|
132
|
-
#
|
133
|
-
# ### Methods for Deleting
|
124
|
+
# #### Methods for Deleting
|
134
125
|
#
|
135
126
|
# * ::delete: Deletes the named environment variable name if it exists.
|
136
127
|
# * ::delete_if: Deletes entries selected by the block.
|
@@ -139,24 +130,22 @@ module RBS
|
|
139
130
|
# * ::select!, ::filter!: Deletes entries selected by the block.
|
140
131
|
# * ::shift: Removes and returns the first entry.
|
141
132
|
#
|
142
|
-
#
|
143
|
-
# ### Methods for Iterating
|
133
|
+
# #### Methods for Iterating
|
144
134
|
#
|
145
135
|
# * ::each, ::each_pair: Calls the block with each name/value pair.
|
146
136
|
# * ::each_key: Calls the block with each name.
|
147
137
|
# * ::each_value: Calls the block with each value.
|
148
138
|
#
|
149
|
-
#
|
150
|
-
# ### Methods for Converting
|
139
|
+
# #### Methods for Converting
|
151
140
|
#
|
152
141
|
# * ::assoc: Returns a 2-element array containing the name and value of the
|
153
142
|
# named environment variable if it exists:
|
154
|
-
# * ::clone: Returns ENV (and issues a warning).
|
143
|
+
# * ::clone: Returns `ENV` (and issues a warning).
|
155
144
|
# * ::except: Returns a hash of all name/value pairs except those given.
|
156
145
|
# * ::fetch: Returns the value for the given name.
|
157
|
-
# * ::inspect: Returns the contents of ENV as a string.
|
158
|
-
# * ::invert: Returns a hash whose keys are the ENV values, and whose values
|
159
|
-
# are the corresponding ENV names.
|
146
|
+
# * ::inspect: Returns the contents of `ENV` as a string.
|
147
|
+
# * ::invert: Returns a hash whose keys are the `ENV` values, and whose values
|
148
|
+
# are the corresponding `ENV` names.
|
160
149
|
# * ::keys: Returns an array of all names.
|
161
150
|
# * ::rassoc: Returns the name and value of the first found entry that has the
|
162
151
|
# given value.
|
@@ -171,12 +160,11 @@ module RBS
|
|
171
160
|
# * ::values: Returns all values as an array.
|
172
161
|
# * ::values_at: Returns an array of the values for the given name.
|
173
162
|
#
|
174
|
-
#
|
175
|
-
# ### More Methods
|
163
|
+
# #### More Methods
|
176
164
|
#
|
177
165
|
# * ::dup: Raises an exception.
|
178
166
|
# * ::freeze: Raises an exception.
|
179
|
-
# * ::rehash: Returns `nil`, without modifying ENV
|
167
|
+
# * ::rehash: Returns `nil`, without modifying `ENV`.
|
180
168
|
#
|
181
169
|
%a{annotate:rdoc:copy:ENV}
|
182
170
|
class ENVClass
|
@@ -260,7 +248,6 @@ module RBS
|
|
260
248
|
# ENV.store('bar', '1') # => '1'
|
261
249
|
# ENV['bar'] # => '1'
|
262
250
|
#
|
263
|
-
#
|
264
251
|
# * If the named environment variable exists:
|
265
252
|
# * If `value` is not `nil`, updates the environment variable with value
|
266
253
|
# `value`:
|
@@ -279,8 +266,6 @@ module RBS
|
|
279
266
|
# ENV.store('bar', nil) # => nil
|
280
267
|
# ENV.include?('bar') # => false
|
281
268
|
#
|
282
|
-
#
|
283
|
-
#
|
284
269
|
# Raises an exception if `name` or `value` is invalid. See [Invalid Names and
|
285
270
|
# Values](rdoc-ref:ENV@Invalid+Names+and+Values).
|
286
271
|
#
|
@@ -313,7 +298,6 @@ module RBS
|
|
313
298
|
# ENV.store('bar', '1') # => '1'
|
314
299
|
# ENV['bar'] # => '1'
|
315
300
|
#
|
316
|
-
#
|
317
301
|
# * If the named environment variable exists:
|
318
302
|
# * If `value` is not `nil`, updates the environment variable with value
|
319
303
|
# `value`:
|
@@ -332,8 +316,6 @@ module RBS
|
|
332
316
|
# ENV.store('bar', nil) # => nil
|
333
317
|
# ENV.include?('bar') # => false
|
334
318
|
#
|
335
|
-
#
|
336
|
-
#
|
337
319
|
# Raises an exception if `name` or `value` is invalid. See [Invalid Names and
|
338
320
|
# Values](rdoc-ref:ENV@Invalid+Names+and+Values).
|
339
321
|
#
|
data/core/rbs/unnamed/random.rbs
CHANGED
@@ -284,8 +284,7 @@ module RBS
|
|
284
284
|
#
|
285
285
|
# The result contains 122 random bits (15.25 random bytes).
|
286
286
|
#
|
287
|
-
# See [
|
288
|
-
# UUID.
|
287
|
+
# See [RFC9562](https://www.rfc-editor.org/rfc/rfc9562) for details of UUIDv4.
|
289
288
|
#
|
290
289
|
%a{annotate:rdoc:copy:Random::Formatter#uuid}
|
291
290
|
def uuid: () -> String
|