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