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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +1 -1
  3. data/.github/workflows/ruby.yml +3 -3
  4. data/CHANGELOG.md +44 -0
  5. data/Gemfile.lock +5 -5
  6. data/Rakefile +6 -38
  7. data/Steepfile +6 -2
  8. data/core/constants.rbs +1 -1
  9. data/core/env.rbs +1 -1323
  10. data/core/global_variables.rbs +1 -1
  11. data/core/hash.rbs +3 -3
  12. data/core/kernel.rbs +2 -2
  13. data/core/random.rbs +5 -220
  14. data/core/rational.rbs +3 -3
  15. data/core/rbs/unnamed/argf.rbs +965 -0
  16. data/core/rbs/unnamed/env_class.rbs +1325 -0
  17. data/core/rbs/unnamed/random.rbs +270 -0
  18. data/core/regexp.rbs +2 -3
  19. data/docs/CONTRIBUTING.md +2 -2
  20. data/ext/rbs_extension/lexer.c +1343 -1353
  21. data/ext/rbs_extension/lexer.re +2 -2
  22. data/ext/rbs_extension/rbs_extension.h +1 -1
  23. data/ext/rbs_extension/unescape.c +17 -10
  24. data/lib/rbs/ast/members.rb +6 -3
  25. data/lib/rbs/cli.rb +2 -0
  26. data/lib/rbs/factory.rb +2 -0
  27. data/lib/rbs/prototype/helpers.rb +1 -5
  28. data/lib/rbs/prototype/rb.rb +105 -56
  29. data/lib/rbs/prototype/rbi.rb +65 -30
  30. data/lib/rbs/prototype/runtime.rb +4 -3
  31. data/lib/rbs/test/setup_helper.rb +6 -1
  32. data/lib/rbs/version.rb +1 -1
  33. data/schema/members.json +4 -1
  34. data/sig/collection/config.rbs +3 -0
  35. data/sig/factory.rbs +5 -0
  36. data/sig/prototype/helpers.rbs +23 -0
  37. data/sig/prototype/rb.rbs +84 -0
  38. data/sig/prototype/rbi.rbs +73 -0
  39. data/sig/shims/abstract_syntax_tree.rbs +25 -0
  40. data/sig/shims/enumerable.rbs +5 -0
  41. data/sig/shims/pp.rbs +3 -0
  42. data/sig/shims/ripper.rbs +8 -0
  43. data/stdlib/cgi/0/manifest.yaml +2 -0
  44. data/stdlib/date/0/time.rbs +26 -0
  45. data/stdlib/etc/0/etc.rbs +745 -0
  46. data/stdlib/minitest/0/kernel.rbs +42 -0
  47. data/stdlib/minitest/0/manifest.yaml +2 -0
  48. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +49 -0
  49. data/stdlib/minitest/0/minitest/assertion.rbs +16 -0
  50. data/stdlib/minitest/0/minitest/assertions.rbs +545 -0
  51. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +16 -0
  52. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  53. data/stdlib/minitest/0/minitest/benchmark.rbs +258 -0
  54. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  55. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  56. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  57. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  58. data/stdlib/minitest/0/minitest/mock.rbs +60 -0
  59. data/stdlib/minitest/0/minitest/parallel/executor.rbs +42 -0
  60. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +6 -0
  61. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  62. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  63. data/stdlib/minitest/0/minitest/pride_io.rbs +54 -0
  64. data/stdlib/minitest/0/minitest/pride_lol.rbs +17 -0
  65. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  66. data/stdlib/minitest/0/minitest/reportable.rbs +51 -0
  67. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  68. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  69. data/stdlib/minitest/0/minitest/runnable.rbs +131 -0
  70. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  71. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  72. data/stdlib/minitest/0/minitest/spec/dsl.rbs +125 -0
  73. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  74. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +76 -0
  75. data/stdlib/minitest/0/minitest/summary_reporter.rbs +25 -0
  76. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  77. data/stdlib/minitest/0/minitest/test.rbs +76 -0
  78. data/stdlib/minitest/0/minitest/unexpected_error.rbs +10 -0
  79. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  80. data/stdlib/minitest/0/minitest/unit.rbs +5 -0
  81. data/stdlib/minitest/0/minitest.rbs +966 -0
  82. data/stdlib/rubygems/0/errors.rbs +113 -0
  83. metadata +54 -4
  84. data/lib/rbs/char_scanner.rb +0 -20
data/core/env.rbs CHANGED
@@ -1,1328 +1,6 @@
1
- # <!-- rdoc-file=hash.c -->
2
- # ENV is a hash-like accessor for environment variables.
3
- #
4
- # ### Interaction with the Operating System
5
- #
6
- # The ENV object interacts with the operating system's environment variables:
7
- #
8
- # * When you get the value for a name in ENV, the value is retrieved from
9
- # among the current environment variables.
10
- # * When you create or set a name-value pair in ENV, the name and value are
11
- # immediately set in the environment variables.
12
- # * When you delete a name-value pair in ENV, it is immediately deleted from
13
- # the environment variables.
14
- #
15
- #
16
- # ### Names and Values
17
- #
18
- # Generally, a name or value is a String.
19
- #
20
- # #### Valid Names and Values
21
- #
22
- # Each name or value must be one of the following:
23
- #
24
- # * A String.
25
- # * An object that responds to #to_str by returning a String, in which case
26
- # that String will be used as the name or value.
27
- #
28
- #
29
- # #### Invalid Names and Values
30
- #
31
- # A new name:
32
- #
33
- # * May not be the empty string:
34
- # ENV[''] = '0'
35
- # # Raises Errno::EINVAL (Invalid argument - ruby_setenv())
36
- #
37
- # * May not contain character `"="`:
38
- # ENV['='] = '0'
39
- # # Raises Errno::EINVAL (Invalid argument - ruby_setenv(=))
40
- #
41
- #
42
- # A new name or value:
43
- #
44
- # * May not be a non-String that does not respond to #to_str:
45
- #
46
- # ENV['foo'] = Object.new
47
- # # Raises TypeError (no implicit conversion of Object into String)
48
- # ENV[Object.new] = '0'
49
- # # Raises TypeError (no implicit conversion of Object into String)
50
- #
51
- # * May not contain the NUL character `"\0"`:
52
- #
53
- # ENV['foo'] = "\0"
54
- # # Raises ArgumentError (bad environment variable value: contains null byte)
55
- # ENV["\0"] == '0'
56
- # # Raises ArgumentError (bad environment variable name: contains null byte)
57
- #
58
- # * May not have an ASCII-incompatible encoding such as UTF-16LE or
59
- # ISO-2022-JP:
60
- #
61
- # ENV['foo'] = '0'.force_encoding(Encoding::ISO_2022_JP)
62
- # # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP)
63
- # ENV["foo".force_encoding(Encoding::ISO_2022_JP)] = '0'
64
- # # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP)
65
- #
66
- #
67
- # ### About Ordering
68
- #
69
- # ENV enumerates its name/value pairs in the order found in the operating
70
- # system's environment variables. Therefore the ordering of ENV content is
71
- # OS-dependent, and may be indeterminate.
72
- #
73
- # This will be seen in:
74
- # * A Hash returned by an ENV method.
75
- # * An Enumerator returned by an ENV method.
76
- # * An Array returned by ENV.keys, ENV.values, or ENV.to_a.
77
- # * The String returned by ENV.inspect.
78
- # * The Array returned by ENV.shift.
79
- # * The name returned by ENV.key.
80
- #
81
- #
82
- # ### About the Examples
83
- # Some methods in ENV return ENV itself. Typically, there are many environment
84
- # variables. It's not useful to display a large ENV in the examples here, so
85
- # most example snippets begin by resetting the contents of ENV:
86
- # * ENV.replace replaces ENV with a new collection of entries.
87
- # * ENV.clear empties ENV.
88
- #
89
- #
90
- # ## What's Here
91
- #
92
- # First, what's elsewhere. Class ENV:
93
- #
94
- # * Inherits from [class
95
- # Object](Object.html#class-Object-label-What-27s+Here).
96
- # * Extends [module
97
- # Enumerable](Enumerable.html#module-Enumerable-label-What-27s+Here),
98
- #
99
- #
100
- # Here, class ENV provides methods that are useful for:
101
- #
102
- # * [Querying](#class-ENV-label-Methods+for+Querying)
103
- # * [Assigning](#class-ENV-label-Methods+for+Assigning)
104
- # * [Deleting](#class-ENV-label-Methods+for+Deleting)
105
- # * [Iterating](#class-ENV-label-Methods+for+Iterating)
106
- # * [Converting](#class-ENV-label-Methods+for+Converting)
107
- # * [And more ....](#class-ENV-label-More+Methods)
108
- #
109
- #
110
- # ### Methods for Querying
111
- #
112
- # ::[]
113
- # : Returns the value for the given environment variable name if it
114
- # exists:
115
- #
116
- # ::empty?
117
- # : Returns whether ENV is empty.
118
- #
119
- # ::has_value?, ::value?
120
- # : Returns whether the given value is in ENV.
121
- #
122
- # ::include?, ::has_key?, ::key?, ::member?
123
- # : Returns whether the given name is in ENV.
124
- #
125
- # ::key
126
- # : Returns the name of the first entry with the given value.
127
- #
128
- # ::size, ::length
129
- # : Returns the number of entries.
130
- #
131
- # ::value?
132
- # : Returns whether any entry has the given value.
133
- #
134
- #
135
- #
136
- # ### Methods for Assigning
137
- #
138
- # ::[]=, ::store
139
- # : Creates, updates, or deletes the named environment variable.
140
- #
141
- # ::clear
142
- # : Removes every environment variable; returns ENV:
143
- #
144
- # ::update, ::merge!
145
- # : Adds to ENV each key/value pair in the given hash.
146
- #
147
- # ::replace
148
- # : Replaces the entire content of the ENV with the name/value pairs in
149
- # the given hash.
150
- #
151
- #
152
- #
153
- # ### Methods for Deleting
154
- #
155
- # ::delete
156
- # : Deletes the named environment variable name if it exists.
157
- #
158
- # ::delete_if
159
- # : Deletes entries selected by the block.
160
- #
161
- # ::keep_if
162
- # : Deletes entries not selected by the block.
163
- #
164
- # ::reject!
165
- # : Similar to #delete_if, but returns `nil` if no change was made.
166
- #
167
- # ::select!, ::filter!
168
- # : Deletes entries selected by the block.
169
- #
170
- # ::shift
171
- # : Removes and returns the first entry.
172
- #
173
- #
174
- #
175
- # ### Methods for Iterating
176
- #
177
- # ::each, ::each_pair
178
- # : Calls the block with each name/value pair.
179
- #
180
- # ::each_key
181
- # : Calls the block with each name.
182
- #
183
- # ::each_value
184
- # : Calls the block with each value.
185
- #
186
- #
187
- #
188
- # ### Methods for Converting
189
- #
190
- # ::assoc
191
- # : Returns a 2-element array containing the name and value of the named
192
- # environment variable if it exists:
193
- #
194
- # ::clone
195
- # : Returns ENV (and issues a warning).
196
- #
197
- # ::except
198
- # : Returns a hash of all name/value pairs except those given.
199
- #
200
- # ::fetch
201
- # : Returns the value for the given name.
202
- #
203
- # ::inspect
204
- # : Returns the contents of ENV as a string.
205
- #
206
- # ::invert
207
- # : Returns a hash whose keys are the ENV values, and whose values are the
208
- # corresponding ENV names.
209
- #
210
- # ::keys
211
- # : Returns an array of all names.
212
- #
213
- # ::rassoc
214
- # : Returns the name and value of the first found entry that has the given
215
- # value.
216
- #
217
- # ::reject
218
- # : Returns a hash of those entries not rejected by the block.
219
- #
220
- # ::select, ::filter
221
- # : Returns a hash of name/value pairs selected by the block.
222
- #
223
- # ::slice
224
- # : Returns a hash of the given names and their corresponding values.
225
- #
226
- # ::to_a
227
- # : Returns the entries as an array of 2-element Arrays.
228
- #
229
- # ::to_h
230
- # : Returns a hash of entries selected by the block.
231
- #
232
- # ::to_hash
233
- # : Returns a hash of all entries.
234
- #
235
- # ::to_s
236
- # : Returns the string `'ENV'`.
237
- #
238
- # ::values
239
- # : Returns all values as an array.
240
- #
241
- # ::values_at
242
- # : Returns an array of the values for the given name.
243
- #
244
- #
245
- #
246
- # ### More Methods
247
- #
248
- # ::dup
249
- # : Raises an exception.
250
- #
251
- # ::freeze
252
- # : Raises an exception.
253
- #
254
- # ::rehash
255
- # : Returns `nil`, without modifying ENV.
256
- #
257
- %a{annotate:rdoc:copy:ENV}
258
- class ENVClass
259
- include Enumerable[[ String, String ]]
260
-
261
- # <!--
262
- # rdoc-file=hash.c
263
- # - ENV[name] -> value
264
- # -->
265
- # Returns the value for the environment variable `name` if it exists:
266
- # ENV['foo'] = '0'
267
- # ENV['foo'] # => "0"
268
- #
269
- # Returns `nil` if the named variable does not exist.
270
- #
271
- # Raises an exception if `name` is invalid. See [Invalid Names and
272
- # Values](#class-ENV-label-Invalid+Names+and+Values).
273
- #
274
- %a{annotate:rdoc:copy:ENV.[]}
275
- def []: (String name) -> String?
276
-
277
- # <!--
278
- # rdoc-file=hash.c
279
- # - ENV.fetch(name) -> value
280
- # - ENV.fetch(name, default) -> value
281
- # - ENV.fetch(name) { |name| block } -> value
282
- # -->
283
- # If `name` is the name of an environment variable, returns its value:
284
- # ENV['foo'] = '0'
285
- # ENV.fetch('foo') # => '0'
286
- #
287
- # Otherwise if a block is given (but not a default value), yields `name` to the
288
- # block and returns the block's return value:
289
- # ENV.fetch('foo') { |name| :need_not_return_a_string } # => :need_not_return_a_string
290
- #
291
- # Otherwise if a default value is given (but not a block), returns the default
292
- # value:
293
- # ENV.delete('foo')
294
- # ENV.fetch('foo', :default_need_not_be_a_string) # => :default_need_not_be_a_string
295
- #
296
- # If the environment variable does not exist and both default and block are
297
- # given, issues a warning ("warning: block supersedes default value argument"),
298
- # yields `name` to the block, and returns the block's return value:
299
- # ENV.fetch('foo', :default) { |name| :block_return } # => :block_return
300
- #
301
- # Raises KeyError if `name` is valid, but not found, and neither default value
302
- # nor block is given:
303
- # ENV.fetch('foo') # Raises KeyError (key not found: "foo")
304
- #
305
- # Raises an exception if `name` is invalid. See [Invalid Names and
306
- # Values](#class-ENV-label-Invalid+Names+and+Values).
307
- #
308
- %a{annotate:rdoc:copy:ENV.fetch}
309
- def fetch: (String name) -> String
310
- | [X] (String name, X default) -> (String | X)
311
- | [X] (String name) { (String) -> X } -> (String | X)
312
-
313
- # <!--
314
- # rdoc-file=hash.c
315
- # - ENV[name] = value -> value
316
- # - ENV.store(name, value) -> value
317
- # -->
318
- # ENV.store is an alias for ENV.[]=.
319
- #
320
- # Creates, updates, or deletes the named environment variable, returning the
321
- # value. Both `name` and `value` may be instances of String. See [Valid Names
322
- # and Values](#class-ENV-label-Valid+Names+and+Values).
323
- #
324
- # * If the named environment variable does not exist:
325
- # * If `value` is `nil`, does nothing.
326
- # ENV.clear
327
- # ENV['foo'] = nil # => nil
328
- # ENV.include?('foo') # => false
329
- # ENV.store('bar', nil) # => nil
330
- # ENV.include?('bar') # => false
331
- #
332
- # * If `value` is not `nil`, creates the environment variable with `name`
333
- # and `value`:
334
- # # Create 'foo' using ENV.[]=.
335
- # ENV['foo'] = '0' # => '0'
336
- # ENV['foo'] # => '0'
337
- # # Create 'bar' using ENV.store.
338
- # ENV.store('bar', '1') # => '1'
339
- # ENV['bar'] # => '1'
340
- #
341
- #
342
- # * If the named environment variable exists:
343
- # * If `value` is not `nil`, updates the environment variable with value
344
- # `value`:
345
- # # Update 'foo' using ENV.[]=.
346
- # ENV['foo'] = '2' # => '2'
347
- # ENV['foo'] # => '2'
348
- # # Update 'bar' using ENV.store.
349
- # ENV.store('bar', '3') # => '3'
350
- # ENV['bar'] # => '3'
351
- #
352
- # * If `value` is `nil`, deletes the environment variable:
353
- # # Delete 'foo' using ENV.[]=.
354
- # ENV['foo'] = nil # => nil
355
- # ENV.include?('foo') # => false
356
- # # Delete 'bar' using ENV.store.
357
- # ENV.store('bar', nil) # => nil
358
- # ENV.include?('bar') # => false
359
- #
360
- #
361
- #
362
- # Raises an exception if `name` or `value` is invalid. See [Invalid Names and
363
- # Values](#class-ENV-label-Invalid+Names+and+Values).
364
- #
365
- %a{annotate:rdoc:copy:ENV.[]=}
366
- def []=: (String name, String? value) -> String?
367
-
368
- # <!--
369
- # rdoc-file=hash.c
370
- # - ENV[name] = value -> value
371
- # - ENV.store(name, value) -> value
372
- # -->
373
- # ENV.store is an alias for ENV.[]=.
374
- #
375
- # Creates, updates, or deletes the named environment variable, returning the
376
- # value. Both `name` and `value` may be instances of String. See [Valid Names
377
- # and Values](#class-ENV-label-Valid+Names+and+Values).
378
- #
379
- # * If the named environment variable does not exist:
380
- # * If `value` is `nil`, does nothing.
381
- # ENV.clear
382
- # ENV['foo'] = nil # => nil
383
- # ENV.include?('foo') # => false
384
- # ENV.store('bar', nil) # => nil
385
- # ENV.include?('bar') # => false
386
- #
387
- # * If `value` is not `nil`, creates the environment variable with `name`
388
- # and `value`:
389
- # # Create 'foo' using ENV.[]=.
390
- # ENV['foo'] = '0' # => '0'
391
- # ENV['foo'] # => '0'
392
- # # Create 'bar' using ENV.store.
393
- # ENV.store('bar', '1') # => '1'
394
- # ENV['bar'] # => '1'
395
- #
396
- #
397
- # * If the named environment variable exists:
398
- # * If `value` is not `nil`, updates the environment variable with value
399
- # `value`:
400
- # # Update 'foo' using ENV.[]=.
401
- # ENV['foo'] = '2' # => '2'
402
- # ENV['foo'] # => '2'
403
- # # Update 'bar' using ENV.store.
404
- # ENV.store('bar', '3') # => '3'
405
- # ENV['bar'] # => '3'
406
- #
407
- # * If `value` is `nil`, deletes the environment variable:
408
- # # Delete 'foo' using ENV.[]=.
409
- # ENV['foo'] = nil # => nil
410
- # ENV.include?('foo') # => false
411
- # # Delete 'bar' using ENV.store.
412
- # ENV.store('bar', nil) # => nil
413
- # ENV.include?('bar') # => false
414
- #
415
- #
416
- #
417
- # Raises an exception if `name` or `value` is invalid. See [Invalid Names and
418
- # Values](#class-ENV-label-Invalid+Names+and+Values).
419
- #
420
- %a{annotate:rdoc:copy:ENV.store}
421
- alias store []=
422
-
423
- # <!--
424
- # rdoc-file=hash.c
425
- # - ENV.each { |name, value| block } -> ENV
426
- # - ENV.each -> an_enumerator
427
- # - ENV.each_pair { |name, value| block } -> ENV
428
- # - ENV.each_pair -> an_enumerator
429
- # -->
430
- # Yields each environment variable name and its value as a 2-element Array:
431
- # h = {}
432
- # ENV.each_pair { |name, value| h[name] = value } # => ENV
433
- # h # => {"bar"=>"1", "foo"=>"0"}
434
- #
435
- # Returns an Enumerator if no block given:
436
- # h = {}
437
- # e = ENV.each_pair # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_pair>
438
- # e.each { |name, value| h[name] = value } # => ENV
439
- # h # => {"bar"=>"1", "foo"=>"0"}
440
- #
441
- %a{annotate:rdoc:copy:ENV.each}
442
- def each: () -> ::Enumerator[[ String, String ], self]
443
- | () { ([ String, String ]) -> void } -> self
444
-
445
- # <!--
446
- # rdoc-file=hash.c
447
- # - ENV.each { |name, value| block } -> ENV
448
- # - ENV.each -> an_enumerator
449
- # - ENV.each_pair { |name, value| block } -> ENV
450
- # - ENV.each_pair -> an_enumerator
451
- # -->
452
- # Yields each environment variable name and its value as a 2-element Array:
453
- # h = {}
454
- # ENV.each_pair { |name, value| h[name] = value } # => ENV
455
- # h # => {"bar"=>"1", "foo"=>"0"}
456
- #
457
- # Returns an Enumerator if no block given:
458
- # h = {}
459
- # e = ENV.each_pair # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_pair>
460
- # e.each { |name, value| h[name] = value } # => ENV
461
- # h # => {"bar"=>"1", "foo"=>"0"}
462
- #
463
- %a{annotate:rdoc:copy:ENV.each_pair}
464
- def each_pair: () -> ::Enumerator[[ String, String ], self]
465
- | () { ([ String, String ]) -> void } -> self
466
-
467
- # <!--
468
- # rdoc-file=hash.c
469
- # - ENV.each_key { |name| block } -> ENV
470
- # - ENV.each_key -> an_enumerator
471
- # -->
472
- # Yields each environment variable name:
473
- # ENV.replace('foo' => '0', 'bar' => '1') # => ENV
474
- # names = []
475
- # ENV.each_key { |name| names.push(name) } # => ENV
476
- # names # => ["bar", "foo"]
477
- #
478
- # Returns an Enumerator if no block given:
479
- # e = ENV.each_key # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_key>
480
- # names = []
481
- # e.each { |name| names.push(name) } # => ENV
482
- # names # => ["bar", "foo"]
483
- #
484
- %a{annotate:rdoc:copy:ENV.each_key}
485
- def each_key: () -> ::Enumerator[[ String ], self]
486
- | () { (String name) -> void } -> self
487
-
488
- # <!--
489
- # rdoc-file=hash.c
490
- # - ENV.each_value { |value| block } -> ENV
491
- # - ENV.each_value -> an_enumerator
492
- # -->
493
- # Yields each environment variable value:
494
- # ENV.replace('foo' => '0', 'bar' => '1') # => ENV
495
- # values = []
496
- # ENV.each_value { |value| values.push(value) } # => ENV
497
- # values # => ["1", "0"]
498
- #
499
- # Returns an Enumerator if no block given:
500
- # e = ENV.each_value # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_value>
501
- # values = []
502
- # e.each { |value| values.push(value) } # => ENV
503
- # values # => ["1", "0"]
504
- #
505
- %a{annotate:rdoc:copy:ENV.each_value}
506
- def each_value: () -> ::Enumerator[[ String ], self]
507
- | () { (String value) -> void } -> self
508
-
509
- # <!--
510
- # rdoc-file=hash.c
511
- # - ENV.delete(name) -> value
512
- # - ENV.delete(name) { |name| block } -> value
513
- # - ENV.delete(missing_name) -> nil
514
- # - ENV.delete(missing_name) { |name| block } -> block_value
515
- # -->
516
- # Deletes the environment variable with `name` if it exists and returns its
517
- # value:
518
- # ENV['foo'] = '0'
519
- # ENV.delete('foo') # => '0'
520
- #
521
- # If a block is not given and the named environment variable does not exist,
522
- # returns `nil`.
523
- #
524
- # If a block given and the environment variable does not exist, yields `name` to
525
- # the block and returns the value of the block:
526
- # ENV.delete('foo') { |name| name * 2 } # => "foofoo"
527
- #
528
- # If a block given and the environment variable exists, deletes the environment
529
- # variable and returns its value (ignoring the block):
530
- # ENV['foo'] = '0'
531
- # ENV.delete('foo') { |name| raise 'ignored' } # => "0"
532
- #
533
- # Raises an exception if `name` is invalid. See [Invalid Names and
534
- # Values](#class-ENV-label-Invalid+Names+and+Values).
535
- #
536
- %a{annotate:rdoc:copy:ENV.delete}
537
- def delete: (String name) -> String?
538
- | (String name) { (String) -> String } -> String
539
-
540
- # <!--
541
- # rdoc-file=hash.c
542
- # - ENV.delete_if { |name, value| block } -> ENV
543
- # - ENV.delete_if -> an_enumerator
544
- # -->
545
- # Yields each environment variable name and its value as a 2-element Array,
546
- # deleting each environment variable for which the block returns a truthy value,
547
- # and returning ENV (regardless of whether any deletions):
548
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
549
- # ENV.delete_if { |name, value| name.start_with?('b') } # => ENV
550
- # ENV # => {"foo"=>"0"}
551
- # ENV.delete_if { |name, value| name.start_with?('b') } # => ENV
552
- #
553
- # Returns an Enumerator if no block given:
554
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
555
- # e = ENV.delete_if # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:delete_if!>
556
- # e.each { |name, value| name.start_with?('b') } # => ENV
557
- # ENV # => {"foo"=>"0"}
558
- # e.each { |name, value| name.start_with?('b') } # => ENV
559
- #
560
- %a{annotate:rdoc:copy:ENV.delete_if}
561
- def delete_if: () -> ::Enumerator[[ String, String ], self]
562
- | () { (String name, String value) -> boolish } -> self
563
-
564
- # <!--
565
- # rdoc-file=hash.c
566
- # - ENV.keep_if { |name, value| block } -> ENV
567
- # - ENV.keep_if -> an_enumerator
568
- # -->
569
- # Yields each environment variable name and its value as a 2-element Array,
570
- # deleting each environment variable for which the block returns `false` or
571
- # `nil`, and returning ENV:
572
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
573
- # ENV.keep_if { |name, value| name.start_with?('b') } # => ENV
574
- # ENV # => {"bar"=>"1", "baz"=>"2"}
575
- #
576
- # Returns an Enumerator if no block given:
577
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
578
- # e = ENV.keep_if # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:keep_if>
579
- # e.each { |name, value| name.start_with?('b') } # => ENV
580
- # ENV # => {"bar"=>"1", "baz"=>"2"}
581
- #
582
- %a{annotate:rdoc:copy:ENV.keep_if}
583
- def keep_if: () -> ::Enumerator[[ String, String ], self]
584
- | () { (String name, String value) -> boolish } -> self
585
-
586
- # <!--
587
- # rdoc-file=hash.c
588
- # - ENV.slice(*names) -> hash of name/value pairs
589
- # -->
590
- # Returns a Hash of the given ENV names and their corresponding values:
591
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2', 'bat' => '3')
592
- # ENV.slice('foo', 'baz') # => {"foo"=>"0", "baz"=>"2"}
593
- # ENV.slice('baz', 'foo') # => {"baz"=>"2", "foo"=>"0"}
594
- #
595
- # Raises an exception if any of the `names` is invalid (see [Invalid Names and
596
- # Values](#class-ENV-label-Invalid+Names+and+Values)):
597
- # ENV.slice('foo', 'bar', :bat) # Raises TypeError (no implicit conversion of Symbol into String)
598
- #
599
- %a{annotate:rdoc:copy:ENV.slice}
600
- def slice: (*String names) -> ::Hash[String, String]
601
-
602
- # <!--
603
- # rdoc-file=hash.c
604
- # - ENV.except(*keys) -> a_hash
605
- # -->
606
- # Returns a hash except the given keys from ENV and their values.
607
- #
608
- # ENV #=> {"LANG"=>"en_US.UTF-8", "TERM"=>"xterm-256color", "HOME"=>"/Users/rhc"}
609
- # ENV.except("TERM","HOME") #=> {"LANG"=>"en_US.UTF-8"}
610
- #
611
- %a{annotate:rdoc:copy:ENV.except}
612
- def except: (*String names) -> ::Hash[String, String]
613
-
614
- # <!--
615
- # rdoc-file=hash.c
616
- # - ENV.clear -> ENV
617
- # -->
618
- # Removes every environment variable; returns ENV:
619
- # ENV.replace('foo' => '0', 'bar' => '1')
620
- # ENV.size # => 2
621
- # ENV.clear # => ENV
622
- # ENV.size # => 0
623
- #
624
- %a{annotate:rdoc:copy:ENV.clear}
625
- def clear: () -> self
626
-
627
- # <!--
628
- # rdoc-file=hash.c
629
- # - ENV.reject { |name, value| block } -> hash of name/value pairs
630
- # - ENV.reject -> an_enumerator
631
- # -->
632
- # Yields each environment variable name and its value as a 2-element Array.
633
- # Returns a Hash whose items are determined by the block. When the block returns
634
- # a truthy value, the name/value pair is added to the return Hash; otherwise the
635
- # pair is ignored:
636
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
637
- # ENV.reject { |name, value| name.start_with?('b') } # => {"foo"=>"0"}
638
- #
639
- # Returns an Enumerator if no block given:
640
- # e = ENV.reject
641
- # e.each { |name, value| name.start_with?('b') } # => {"foo"=>"0"}
642
- #
643
- %a{annotate:rdoc:copy:ENV.reject}
644
- def reject: () -> ::Enumerator[[ String, String ], self]
645
- | () { (String name, String value) -> boolish } -> self
646
-
647
- # <!--
648
- # rdoc-file=hash.c
649
- # - ENV.reject! { |name, value| block } -> ENV or nil
650
- # - ENV.reject! -> an_enumerator
651
- # -->
652
- # Similar to ENV.delete_if, but returns `nil` if no changes were made.
653
- #
654
- # Yields each environment variable name and its value as a 2-element Array,
655
- # deleting each environment variable for which the block returns a truthy value,
656
- # and returning ENV (if any deletions) or `nil` (if not):
657
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
658
- # ENV.reject! { |name, value| name.start_with?('b') } # => ENV
659
- # ENV # => {"foo"=>"0"}
660
- # ENV.reject! { |name, value| name.start_with?('b') } # => nil
661
- #
662
- # Returns an Enumerator if no block given:
663
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
664
- # e = ENV.reject! # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:reject!>
665
- # e.each { |name, value| name.start_with?('b') } # => ENV
666
- # ENV # => {"foo"=>"0"}
667
- # e.each { |name, value| name.start_with?('b') } # => nil
668
- #
669
- %a{annotate:rdoc:copy:ENV.reject!}
670
- def reject!: () -> ::Enumerator[[ String, String ], self?]
671
- | () { (String name, String value) -> boolish } -> self?
672
-
673
- # <!--
674
- # rdoc-file=hash.c
675
- # - ENV.select { |name, value| block } -> hash of name/value pairs
676
- # - ENV.select -> an_enumerator
677
- # - ENV.filter { |name, value| block } -> hash of name/value pairs
678
- # - ENV.filter -> an_enumerator
679
- # -->
680
- # ENV.filter is an alias for ENV.select.
681
- #
682
- # Yields each environment variable name and its value as a 2-element Array,
683
- # returning a Hash of the names and values for which the block returns a truthy
684
- # value:
685
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
686
- # ENV.select { |name, value| name.start_with?('b') } # => {"bar"=>"1", "baz"=>"2"}
687
- # ENV.filter { |name, value| name.start_with?('b') } # => {"bar"=>"1", "baz"=>"2"}
688
- #
689
- # Returns an Enumerator if no block given:
690
- # e = ENV.select # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:select>
691
- # e.each { |name, value | name.start_with?('b') } # => {"bar"=>"1", "baz"=>"2"}
692
- # e = ENV.filter # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:filter>
693
- # e.each { |name, value | name.start_with?('b') } # => {"bar"=>"1", "baz"=>"2"}
694
- #
695
- %a{annotate:rdoc:copy:ENV.select}
696
- def select: () -> ::Enumerator[[ String, String ], ::Hash[String, String]]
697
- | () { (String name, String value) -> boolish } -> ::Hash[String, String]
698
-
699
- # <!--
700
- # rdoc-file=hash.c
701
- # - ENV.select { |name, value| block } -> hash of name/value pairs
702
- # - ENV.select -> an_enumerator
703
- # - ENV.filter { |name, value| block } -> hash of name/value pairs
704
- # - ENV.filter -> an_enumerator
705
- # -->
706
- # ENV.filter is an alias for ENV.select.
707
- #
708
- # Yields each environment variable name and its value as a 2-element Array,
709
- # returning a Hash of the names and values for which the block returns a truthy
710
- # value:
711
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
712
- # ENV.select { |name, value| name.start_with?('b') } # => {"bar"=>"1", "baz"=>"2"}
713
- # ENV.filter { |name, value| name.start_with?('b') } # => {"bar"=>"1", "baz"=>"2"}
714
- #
715
- # Returns an Enumerator if no block given:
716
- # e = ENV.select # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:select>
717
- # e.each { |name, value | name.start_with?('b') } # => {"bar"=>"1", "baz"=>"2"}
718
- # e = ENV.filter # => #<Enumerator: {"bar"=>"1", "baz"=>"2", "foo"=>"0"}:filter>
719
- # e.each { |name, value | name.start_with?('b') } # => {"bar"=>"1", "baz"=>"2"}
720
- #
721
- %a{annotate:rdoc:copy:ENV.filter}
722
- alias filter select
723
-
724
- # <!--
725
- # rdoc-file=hash.c
726
- # - ENV.select! { |name, value| block } -> ENV or nil
727
- # - ENV.select! -> an_enumerator
728
- # - ENV.filter! { |name, value| block } -> ENV or nil
729
- # - ENV.filter! -> an_enumerator
730
- # -->
731
- # ENV.filter! is an alias for ENV.select!.
732
- #
733
- # Yields each environment variable name and its value as a 2-element Array,
734
- # deleting each entry for which the block returns `false` or `nil`, and
735
- # returning ENV if any deletions made, or `nil` otherwise:
736
- #
737
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
738
- # ENV.select! { |name, value| name.start_with?('b') } # => ENV
739
- # ENV # => {"bar"=>"1", "baz"=>"2"}
740
- # ENV.select! { |name, value| true } # => nil
741
- #
742
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
743
- # ENV.filter! { |name, value| name.start_with?('b') } # => ENV
744
- # ENV # => {"bar"=>"1", "baz"=>"2"}
745
- # ENV.filter! { |name, value| true } # => nil
746
- #
747
- # Returns an Enumerator if no block given:
748
- #
749
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
750
- # e = ENV.select! # => #<Enumerator: {"bar"=>"1", "baz"=>"2"}:select!>
751
- # e.each { |name, value| name.start_with?('b') } # => ENV
752
- # ENV # => {"bar"=>"1", "baz"=>"2"}
753
- # e.each { |name, value| true } # => nil
754
- #
755
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
756
- # e = ENV.filter! # => #<Enumerator: {"bar"=>"1", "baz"=>"2"}:filter!>
757
- # e.each { |name, value| name.start_with?('b') } # => ENV
758
- # ENV # => {"bar"=>"1", "baz"=>"2"}
759
- # e.each { |name, value| true } # => nil
760
- #
761
- %a{annotate:rdoc:copy:ENV.select!}
762
- def select!: () -> ::Enumerator[[ String, String ], self?]
763
- | () { (String name, String value) -> boolish } -> self?
764
-
765
- # <!--
766
- # rdoc-file=hash.c
767
- # - ENV.select! { |name, value| block } -> ENV or nil
768
- # - ENV.select! -> an_enumerator
769
- # - ENV.filter! { |name, value| block } -> ENV or nil
770
- # - ENV.filter! -> an_enumerator
771
- # -->
772
- # ENV.filter! is an alias for ENV.select!.
773
- #
774
- # Yields each environment variable name and its value as a 2-element Array,
775
- # deleting each entry for which the block returns `false` or `nil`, and
776
- # returning ENV if any deletions made, or `nil` otherwise:
777
- #
778
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
779
- # ENV.select! { |name, value| name.start_with?('b') } # => ENV
780
- # ENV # => {"bar"=>"1", "baz"=>"2"}
781
- # ENV.select! { |name, value| true } # => nil
782
- #
783
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
784
- # ENV.filter! { |name, value| name.start_with?('b') } # => ENV
785
- # ENV # => {"bar"=>"1", "baz"=>"2"}
786
- # ENV.filter! { |name, value| true } # => nil
787
- #
788
- # Returns an Enumerator if no block given:
789
- #
790
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
791
- # e = ENV.select! # => #<Enumerator: {"bar"=>"1", "baz"=>"2"}:select!>
792
- # e.each { |name, value| name.start_with?('b') } # => ENV
793
- # ENV # => {"bar"=>"1", "baz"=>"2"}
794
- # e.each { |name, value| true } # => nil
795
- #
796
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
797
- # e = ENV.filter! # => #<Enumerator: {"bar"=>"1", "baz"=>"2"}:filter!>
798
- # e.each { |name, value| name.start_with?('b') } # => ENV
799
- # ENV # => {"bar"=>"1", "baz"=>"2"}
800
- # e.each { |name, value| true } # => nil
801
- #
802
- %a{annotate:rdoc:copy:ENV.filter!}
803
- alias filter! select!
804
-
805
- # <!--
806
- # rdoc-file=hash.c
807
- # - ENV.shift -> [name, value] or nil
808
- # -->
809
- # Removes the first environment variable from ENV and returns a 2-element Array
810
- # containing its name and value:
811
- # ENV.replace('foo' => '0', 'bar' => '1')
812
- # ENV.to_hash # => {'bar' => '1', 'foo' => '0'}
813
- # ENV.shift # => ['bar', '1']
814
- # ENV.to_hash # => {'foo' => '0'}
815
- #
816
- # Exactly which environment variable is "first" is OS-dependent. See [About
817
- # Ordering](#class-ENV-label-About+Ordering).
818
- #
819
- # Returns `nil` if the environment is empty.
820
- #
821
- %a{annotate:rdoc:copy:ENV.shift}
822
- def shift: () -> [ String, String ]?
823
-
824
- # <!--
825
- # rdoc-file=hash.c
826
- # - ENV.invert -> hash of value/name pairs
827
- # -->
828
- # Returns a Hash whose keys are the ENV values, and whose values are the
829
- # corresponding ENV names:
830
- # ENV.replace('foo' => '0', 'bar' => '1')
831
- # ENV.invert # => {"1"=>"bar", "0"=>"foo"}
832
- #
833
- # For a duplicate ENV value, overwrites the hash entry:
834
- # ENV.replace('foo' => '0', 'bar' => '0')
835
- # ENV.invert # => {"0"=>"foo"}
836
- #
837
- # Note that the order of the ENV processing is OS-dependent, which means that
838
- # the order of overwriting is also OS-dependent. See [About
839
- # Ordering](#class-ENV-label-About+Ordering).
840
- #
841
- %a{annotate:rdoc:copy:ENV.invert}
842
- def invert: () -> ::Hash[String, String]
843
-
844
- # <!--
845
- # rdoc-file=hash.c
846
- # - ENV.replace(hash) -> ENV
847
- # -->
848
- # Replaces the entire content of the environment variables with the name/value
849
- # pairs in the given `hash`; returns ENV.
850
- #
851
- # Replaces the content of ENV with the given pairs:
852
- # ENV.replace('foo' => '0', 'bar' => '1') # => ENV
853
- # ENV.to_hash # => {"bar"=>"1", "foo"=>"0"}
854
- #
855
- # Raises an exception if a name or value is invalid (see [Invalid Names and
856
- # Values](#class-ENV-label-Invalid+Names+and+Values)):
857
- # ENV.replace('foo' => '0', :bar => '1') # Raises TypeError (no implicit conversion of Symbol into String)
858
- # ENV.replace('foo' => '0', 'bar' => 1) # Raises TypeError (no implicit conversion of Integer into String)
859
- # ENV.to_hash # => {"bar"=>"1", "foo"=>"0"}
860
- #
861
- %a{annotate:rdoc:copy:ENV.replace}
862
- def replace: (Hash[String, String]) -> self
863
-
864
- # <!--
865
- # rdoc-file=hash.c
866
- # - ENV.update(hash) -> ENV
867
- # - ENV.update(hash) { |name, env_val, hash_val| block } -> ENV
868
- # - ENV.merge!(hash) -> ENV
869
- # - ENV.merge!(hash) { |name, env_val, hash_val| block } -> ENV
870
- # -->
871
- # ENV.update is an alias for ENV.merge!.
872
- #
873
- # Adds to ENV each key/value pair in the given `hash`; returns ENV:
874
- # ENV.replace('foo' => '0', 'bar' => '1')
875
- # ENV.merge!('baz' => '2', 'bat' => '3') # => {"bar"=>"1", "bat"=>"3", "baz"=>"2", "foo"=>"0"}
876
- #
877
- # Deletes the ENV entry for a hash value that is `nil`:
878
- # ENV.merge!('baz' => nil, 'bat' => nil) # => {"bar"=>"1", "foo"=>"0"}
879
- #
880
- # For an already-existing name, if no block given, overwrites the ENV value:
881
- # ENV.merge!('foo' => '4') # => {"bar"=>"1", "foo"=>"4"}
882
- #
883
- # For an already-existing name, if block given, yields the name, its ENV value,
884
- # and its hash value; the block's return value becomes the new name:
885
- # ENV.merge!('foo' => '5') { |name, env_val, hash_val | env_val + hash_val } # => {"bar"=>"1", "foo"=>"45"}
886
- #
887
- # Raises an exception if a name or value is invalid (see [Invalid Names and
888
- # Values](#class-ENV-label-Invalid+Names+and+Values));
889
- # ENV.replace('foo' => '0', 'bar' => '1')
890
- # ENV.merge!('foo' => '6', :bar => '7', 'baz' => '9') # Raises TypeError (no implicit conversion of Symbol into String)
891
- # ENV # => {"bar"=>"1", "foo"=>"6"}
892
- # ENV.merge!('foo' => '7', 'bar' => 8, 'baz' => '9') # Raises TypeError (no implicit conversion of Integer into String)
893
- # ENV # => {"bar"=>"1", "foo"=>"7"}
894
- #
895
- # Raises an exception if the block returns an invalid name: (see [Invalid Names
896
- # and Values](#class-ENV-label-Invalid+Names+and+Values)):
897
- # ENV.merge!('bat' => '8', 'foo' => '9') { |name, env_val, hash_val | 10 } # Raises TypeError (no implicit conversion of Integer into String)
898
- # ENV # => {"bar"=>"1", "bat"=>"8", "foo"=>"7"}
899
- #
900
- # Note that for the exceptions above, hash pairs preceding an invalid name or
901
- # value are processed normally; those following are ignored.
902
- #
903
- %a{annotate:rdoc:copy:ENV.update}
904
- def update: (Hash[String, String?]) -> self
905
- | (Hash[String, String?]) { (String name, String env_val, String? hash_val) -> String } -> self
906
-
907
- # <!--
908
- # rdoc-file=hash.c
909
- # - ENV.update(hash) -> ENV
910
- # - ENV.update(hash) { |name, env_val, hash_val| block } -> ENV
911
- # - ENV.merge!(hash) -> ENV
912
- # - ENV.merge!(hash) { |name, env_val, hash_val| block } -> ENV
913
- # -->
914
- # ENV.update is an alias for ENV.merge!.
915
- #
916
- # Adds to ENV each key/value pair in the given `hash`; returns ENV:
917
- # ENV.replace('foo' => '0', 'bar' => '1')
918
- # ENV.merge!('baz' => '2', 'bat' => '3') # => {"bar"=>"1", "bat"=>"3", "baz"=>"2", "foo"=>"0"}
919
- #
920
- # Deletes the ENV entry for a hash value that is `nil`:
921
- # ENV.merge!('baz' => nil, 'bat' => nil) # => {"bar"=>"1", "foo"=>"0"}
922
- #
923
- # For an already-existing name, if no block given, overwrites the ENV value:
924
- # ENV.merge!('foo' => '4') # => {"bar"=>"1", "foo"=>"4"}
925
- #
926
- # For an already-existing name, if block given, yields the name, its ENV value,
927
- # and its hash value; the block's return value becomes the new name:
928
- # ENV.merge!('foo' => '5') { |name, env_val, hash_val | env_val + hash_val } # => {"bar"=>"1", "foo"=>"45"}
929
- #
930
- # Raises an exception if a name or value is invalid (see [Invalid Names and
931
- # Values](#class-ENV-label-Invalid+Names+and+Values));
932
- # ENV.replace('foo' => '0', 'bar' => '1')
933
- # ENV.merge!('foo' => '6', :bar => '7', 'baz' => '9') # Raises TypeError (no implicit conversion of Symbol into String)
934
- # ENV # => {"bar"=>"1", "foo"=>"6"}
935
- # ENV.merge!('foo' => '7', 'bar' => 8, 'baz' => '9') # Raises TypeError (no implicit conversion of Integer into String)
936
- # ENV # => {"bar"=>"1", "foo"=>"7"}
937
- #
938
- # Raises an exception if the block returns an invalid name: (see [Invalid Names
939
- # and Values](#class-ENV-label-Invalid+Names+and+Values)):
940
- # ENV.merge!('bat' => '8', 'foo' => '9') { |name, env_val, hash_val | 10 } # Raises TypeError (no implicit conversion of Integer into String)
941
- # ENV # => {"bar"=>"1", "bat"=>"8", "foo"=>"7"}
942
- #
943
- # Note that for the exceptions above, hash pairs preceding an invalid name or
944
- # value are processed normally; those following are ignored.
945
- #
946
- %a{annotate:rdoc:copy:ENV.merge!}
947
- alias merge! update
948
-
949
- # <!--
950
- # rdoc-file=hash.c
951
- # - ENV.rehash -> nil
952
- # -->
953
- # (Provided for compatibility with Hash.)
954
- #
955
- # Does not modify ENV; returns `nil`.
956
- #
957
- %a{annotate:rdoc:copy:ENV.rehash}
958
- def rehash: () -> nil
959
-
960
- # <!--
961
- # rdoc-file=hash.c
962
- # - ENV.to_a -> array of 2-element arrays
963
- # -->
964
- # Returns the contents of ENV as an Array of 2-element Arrays, each of which is
965
- # a name/value pair:
966
- # ENV.replace('foo' => '0', 'bar' => '1')
967
- # ENV.to_a # => [["bar", "1"], ["foo", "0"]]
968
- #
969
- %a{annotate:rdoc:copy:ENV.to_a}
970
- def to_a: () -> ::Array[[ String, String ]]
971
-
972
- # <!--
973
- # rdoc-file=hash.c
974
- # - ENV.to_s -> "ENV"
975
- # -->
976
- # Returns String 'ENV':
977
- # ENV.to_s # => "ENV"
978
- #
979
- %a{annotate:rdoc:copy:ENV.to_s}
980
- def to_s: () -> "ENV"
981
-
982
- # <!--
983
- # rdoc-file=hash.c
984
- # - ENV.key(value) -> name or nil
985
- # -->
986
- # Returns the name of the first environment variable with `value`, if it exists:
987
- # ENV.replace('foo' => '0', 'bar' => '0')
988
- # ENV.key('0') # => "foo"
989
- #
990
- # The order in which environment variables are examined is OS-dependent. See
991
- # [About Ordering](#class-ENV-label-About+Ordering).
992
- #
993
- # Returns `nil` if there is no such value.
994
- #
995
- # Raises an exception if `value` is invalid:
996
- # ENV.key(Object.new) # raises TypeError (no implicit conversion of Object into String)
997
- #
998
- # See [Invalid Names and Values](#class-ENV-label-Invalid+Names+and+Values).
999
- #
1000
- %a{annotate:rdoc:copy:ENV.key}
1001
- def key: (String value) -> String?
1002
-
1003
- # <!--
1004
- # rdoc-file=hash.c
1005
- # - ENV.length -> an_integer
1006
- # - ENV.size -> an_integer
1007
- # -->
1008
- # Returns the count of environment variables:
1009
- # ENV.replace('foo' => '0', 'bar' => '1')
1010
- # ENV.length # => 2
1011
- # ENV.size # => 2
1012
- #
1013
- %a{annotate:rdoc:copy:ENV.size}
1014
- def size: () -> Integer
1015
-
1016
- # <!--
1017
- # rdoc-file=hash.c
1018
- # - ENV.length -> an_integer
1019
- # - ENV.size -> an_integer
1020
- # -->
1021
- # Returns the count of environment variables:
1022
- # ENV.replace('foo' => '0', 'bar' => '1')
1023
- # ENV.length # => 2
1024
- # ENV.size # => 2
1025
- #
1026
- %a{annotate:rdoc:copy:ENV.length}
1027
- alias length size
1028
-
1029
- # <!--
1030
- # rdoc-file=hash.c
1031
- # - ENV.empty? -> true or false
1032
- # -->
1033
- # Returns `true` when there are no environment variables, `false` otherwise:
1034
- # ENV.clear
1035
- # ENV.empty? # => true
1036
- # ENV['foo'] = '0'
1037
- # ENV.empty? # => false
1038
- #
1039
- %a{annotate:rdoc:copy:ENV.empty?}
1040
- def empty?: () -> bool
1041
-
1042
- # <!--
1043
- # rdoc-file=hash.c
1044
- # - ENV.keys -> array of names
1045
- # -->
1046
- # Returns all variable names in an Array:
1047
- # ENV.replace('foo' => '0', 'bar' => '1')
1048
- # ENV.keys # => ['bar', 'foo']
1049
- #
1050
- # The order of the names is OS-dependent. See [About
1051
- # Ordering](#class-ENV-label-About+Ordering).
1052
- #
1053
- # Returns the empty Array if ENV is empty.
1054
- #
1055
- %a{annotate:rdoc:copy:ENV.keys}
1056
- def keys: () -> ::Array[String]
1057
-
1058
- # <!--
1059
- # rdoc-file=hash.c
1060
- # - ENV.values -> array of values
1061
- # -->
1062
- # Returns all environment variable values in an Array:
1063
- # ENV.replace('foo' => '0', 'bar' => '1')
1064
- # ENV.values # => ['1', '0']
1065
- #
1066
- # The order of the values is OS-dependent. See [About
1067
- # Ordering](#class-ENV-label-About+Ordering).
1068
- #
1069
- # Returns the empty Array if ENV is empty.
1070
- #
1071
- %a{annotate:rdoc:copy:ENV.values}
1072
- def values: () -> ::Array[String]
1073
-
1074
- # <!--
1075
- # rdoc-file=hash.c
1076
- # - ENV.values_at(*names) -> array of values
1077
- # -->
1078
- # Returns an Array containing the environment variable values associated with
1079
- # the given names:
1080
- # ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
1081
- # ENV.values_at('foo', 'baz') # => ["0", "2"]
1082
- #
1083
- # Returns `nil` in the Array for each name that is not an ENV name:
1084
- # ENV.values_at('foo', 'bat', 'bar', 'bam') # => ["0", nil, "1", nil]
1085
- #
1086
- # Returns an empty Array if no names given.
1087
- #
1088
- # Raises an exception if any name is invalid. See [Invalid Names and
1089
- # Values](#class-ENV-label-Invalid+Names+and+Values).
1090
- #
1091
- %a{annotate:rdoc:copy:ENV.values_at}
1092
- def values_at: (*String names) -> ::Array[String?]
1093
-
1094
- # <!--
1095
- # rdoc-file=hash.c
1096
- # - ENV.include?(name) -> true or false
1097
- # - ENV.has_key?(name) -> true or false
1098
- # - ENV.member?(name) -> true or false
1099
- # - ENV.key?(name) -> true or false
1100
- # -->
1101
- # ENV.has_key?, ENV.member?, and ENV.key? are aliases for ENV.include?.
1102
- #
1103
- # Returns `true` if there is an environment variable with the given `name`:
1104
- # ENV.replace('foo' => '0', 'bar' => '1')
1105
- # ENV.include?('foo') # => true
1106
- #
1107
- # Returns `false` if `name` is a valid String and there is no such environment
1108
- # variable:
1109
- # ENV.include?('baz') # => false
1110
- #
1111
- # Returns `false` if `name` is the empty String or is a String containing
1112
- # character `'='`:
1113
- # ENV.include?('') # => false
1114
- # ENV.include?('=') # => false
1115
- #
1116
- # Raises an exception if `name` is a String containing the NUL character `"\0"`:
1117
- # ENV.include?("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
1118
- #
1119
- # Raises an exception if `name` has an encoding that is not ASCII-compatible:
1120
- # ENV.include?("\xa1\xa1".force_encoding(Encoding::UTF_16LE))
1121
- # # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
1122
- #
1123
- # Raises an exception if `name` is not a String:
1124
- # ENV.include?(Object.new) # TypeError (no implicit conversion of Object into String)
1125
- #
1126
- %a{annotate:rdoc:copy:ENV.include?}
1127
- def include?: (String name) -> bool
1128
-
1129
- # <!--
1130
- # rdoc-file=hash.c
1131
- # - ENV.include?(name) -> true or false
1132
- # - ENV.has_key?(name) -> true or false
1133
- # - ENV.member?(name) -> true or false
1134
- # - ENV.key?(name) -> true or false
1135
- # -->
1136
- # ENV.has_key?, ENV.member?, and ENV.key? are aliases for ENV.include?.
1137
- #
1138
- # Returns `true` if there is an environment variable with the given `name`:
1139
- # ENV.replace('foo' => '0', 'bar' => '1')
1140
- # ENV.include?('foo') # => true
1141
- #
1142
- # Returns `false` if `name` is a valid String and there is no such environment
1143
- # variable:
1144
- # ENV.include?('baz') # => false
1145
- #
1146
- # Returns `false` if `name` is the empty String or is a String containing
1147
- # character `'='`:
1148
- # ENV.include?('') # => false
1149
- # ENV.include?('=') # => false
1150
- #
1151
- # Raises an exception if `name` is a String containing the NUL character `"\0"`:
1152
- # ENV.include?("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
1153
- #
1154
- # Raises an exception if `name` has an encoding that is not ASCII-compatible:
1155
- # ENV.include?("\xa1\xa1".force_encoding(Encoding::UTF_16LE))
1156
- # # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
1157
- #
1158
- # Raises an exception if `name` is not a String:
1159
- # ENV.include?(Object.new) # TypeError (no implicit conversion of Object into String)
1160
- #
1161
- %a{annotate:rdoc:copy:ENV.member?}
1162
- alias member? include?
1163
-
1164
- # <!--
1165
- # rdoc-file=hash.c
1166
- # - ENV.include?(name) -> true or false
1167
- # - ENV.has_key?(name) -> true or false
1168
- # - ENV.member?(name) -> true or false
1169
- # - ENV.key?(name) -> true or false
1170
- # -->
1171
- # ENV.has_key?, ENV.member?, and ENV.key? are aliases for ENV.include?.
1172
- #
1173
- # Returns `true` if there is an environment variable with the given `name`:
1174
- # ENV.replace('foo' => '0', 'bar' => '1')
1175
- # ENV.include?('foo') # => true
1176
- #
1177
- # Returns `false` if `name` is a valid String and there is no such environment
1178
- # variable:
1179
- # ENV.include?('baz') # => false
1180
- #
1181
- # Returns `false` if `name` is the empty String or is a String containing
1182
- # character `'='`:
1183
- # ENV.include?('') # => false
1184
- # ENV.include?('=') # => false
1185
- #
1186
- # Raises an exception if `name` is a String containing the NUL character `"\0"`:
1187
- # ENV.include?("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
1188
- #
1189
- # Raises an exception if `name` has an encoding that is not ASCII-compatible:
1190
- # ENV.include?("\xa1\xa1".force_encoding(Encoding::UTF_16LE))
1191
- # # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
1192
- #
1193
- # Raises an exception if `name` is not a String:
1194
- # ENV.include?(Object.new) # TypeError (no implicit conversion of Object into String)
1195
- #
1196
- %a{annotate:rdoc:copy:ENV.has_key?}
1197
- alias has_key? include?
1198
-
1199
- # <!--
1200
- # rdoc-file=hash.c
1201
- # - ENV.value?(value) -> true or false
1202
- # - ENV.has_value?(value) -> true or false
1203
- # -->
1204
- # Returns `true` if `value` is the value for some environment variable name,
1205
- # `false` otherwise:
1206
- # ENV.replace('foo' => '0', 'bar' => '1')
1207
- # ENV.value?('0') # => true
1208
- # ENV.has_value?('0') # => true
1209
- # ENV.value?('2') # => false
1210
- # ENV.has_value?('2') # => false
1211
- #
1212
- %a{annotate:rdoc:copy:ENV.has_value?}
1213
- def has_value?: (String value) -> bool
1214
-
1215
- # <!--
1216
- # rdoc-file=hash.c
1217
- # - ENV.value?(value) -> true or false
1218
- # - ENV.has_value?(value) -> true or false
1219
- # -->
1220
- # Returns `true` if `value` is the value for some environment variable name,
1221
- # `false` otherwise:
1222
- # ENV.replace('foo' => '0', 'bar' => '1')
1223
- # ENV.value?('0') # => true
1224
- # ENV.has_value?('0') # => true
1225
- # ENV.value?('2') # => false
1226
- # ENV.has_value?('2') # => false
1227
- #
1228
- %a{annotate:rdoc:copy:ENV.value?}
1229
- alias value? has_value?
1230
-
1231
- # <!--
1232
- # rdoc-file=hash.c
1233
- # - ENV.include?(name) -> true or false
1234
- # - ENV.has_key?(name) -> true or false
1235
- # - ENV.member?(name) -> true or false
1236
- # - ENV.key?(name) -> true or false
1237
- # -->
1238
- # ENV.has_key?, ENV.member?, and ENV.key? are aliases for ENV.include?.
1239
- #
1240
- # Returns `true` if there is an environment variable with the given `name`:
1241
- # ENV.replace('foo' => '0', 'bar' => '1')
1242
- # ENV.include?('foo') # => true
1243
- #
1244
- # Returns `false` if `name` is a valid String and there is no such environment
1245
- # variable:
1246
- # ENV.include?('baz') # => false
1247
- #
1248
- # Returns `false` if `name` is the empty String or is a String containing
1249
- # character `'='`:
1250
- # ENV.include?('') # => false
1251
- # ENV.include?('=') # => false
1252
- #
1253
- # Raises an exception if `name` is a String containing the NUL character `"\0"`:
1254
- # ENV.include?("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
1255
- #
1256
- # Raises an exception if `name` has an encoding that is not ASCII-compatible:
1257
- # ENV.include?("\xa1\xa1".force_encoding(Encoding::UTF_16LE))
1258
- # # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
1259
- #
1260
- # Raises an exception if `name` is not a String:
1261
- # ENV.include?(Object.new) # TypeError (no implicit conversion of Object into String)
1262
- #
1263
- %a{annotate:rdoc:copy:ENV.key?}
1264
- alias key? include?
1265
-
1266
- # <!--
1267
- # rdoc-file=hash.c
1268
- # - ENV.to_hash -> hash of name/value pairs
1269
- # -->
1270
- # Returns a Hash containing all name/value pairs from ENV:
1271
- # ENV.replace('foo' => '0', 'bar' => '1')
1272
- # ENV.to_hash # => {"bar"=>"1", "foo"=>"0"}
1273
- #
1274
- %a{annotate:rdoc:copy:ENV.to_hash}
1275
- def to_hash: () -> ::Hash[String, String]
1276
-
1277
- # <!--
1278
- # rdoc-file=hash.c
1279
- # - ENV.assoc(name) -> [name, value] or nil
1280
- # -->
1281
- # Returns a 2-element Array containing the name and value of the environment
1282
- # variable for `name` if it exists:
1283
- # ENV.replace('foo' => '0', 'bar' => '1')
1284
- # ENV.assoc('foo') # => ['foo', '0']
1285
- #
1286
- # Returns `nil` if `name` is a valid String and there is no such environment
1287
- # variable.
1288
- #
1289
- # Returns `nil` if `name` is the empty String or is a String containing
1290
- # character `'='`.
1291
- #
1292
- # Raises an exception if `name` is a String containing the NUL character `"\0"`:
1293
- # ENV.assoc("\0") # Raises ArgumentError (bad environment variable name: contains null byte)
1294
- #
1295
- # Raises an exception if `name` has an encoding that is not ASCII-compatible:
1296
- # ENV.assoc("\xa1\xa1".force_encoding(Encoding::UTF_16LE))
1297
- # # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: UTF-16LE)
1298
- #
1299
- # Raises an exception if `name` is not a String:
1300
- # ENV.assoc(Object.new) # TypeError (no implicit conversion of Object into String)
1301
- #
1302
- %a{annotate:rdoc:copy:ENV.assoc}
1303
- def assoc: (String name) -> [ String, String ]?
1304
-
1305
- # <!--
1306
- # rdoc-file=hash.c
1307
- # - ENV.rassoc(value) -> [name, value] or nil
1308
- # -->
1309
- # Returns a 2-element Array containing the name and value of the **first**
1310
- # **found** environment variable that has value `value`, if one exists:
1311
- # ENV.replace('foo' => '0', 'bar' => '0')
1312
- # ENV.rassoc('0') # => ["bar", "0"]
1313
- #
1314
- # The order in which environment variables are examined is OS-dependent. See
1315
- # [About Ordering](#class-ENV-label-About+Ordering).
1316
- #
1317
- # Returns `nil` if there is no such environment variable.
1318
- #
1319
- %a{annotate:rdoc:copy:ENV.rassoc}
1320
- def rassoc: (String value) -> [ String, String ]?
1321
- end
1322
-
1323
1
  # <!-- rdoc-file=hash.c -->
1324
2
  # ENV is a Hash-like accessor for environment variables.
1325
3
  #
1326
4
  # See ENV (the class) for more details.
1327
5
  #
1328
- ENV: ENVClass
6
+ ENV: RBS::Unnamed::ENVClass