rbs 0.2.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 (132) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +28 -0
  3. data/.gitignore +12 -0
  4. data/.rubocop.yml +15 -0
  5. data/BSDL +22 -0
  6. data/CHANGELOG.md +9 -0
  7. data/COPYING +56 -0
  8. data/Gemfile +6 -0
  9. data/README.md +93 -0
  10. data/Rakefile +142 -0
  11. data/bin/annotate-with-rdoc +157 -0
  12. data/bin/console +14 -0
  13. data/bin/query-rdoc +103 -0
  14. data/bin/setup +10 -0
  15. data/bin/sort +89 -0
  16. data/bin/test_runner.rb +16 -0
  17. data/docs/CONTRIBUTING.md +97 -0
  18. data/docs/sigs.md +148 -0
  19. data/docs/stdlib.md +152 -0
  20. data/docs/syntax.md +528 -0
  21. data/exe/rbs +7 -0
  22. data/lib/rbs.rb +64 -0
  23. data/lib/rbs/ast/annotation.rb +27 -0
  24. data/lib/rbs/ast/comment.rb +27 -0
  25. data/lib/rbs/ast/declarations.rb +395 -0
  26. data/lib/rbs/ast/members.rb +362 -0
  27. data/lib/rbs/buffer.rb +50 -0
  28. data/lib/rbs/builtin_names.rb +55 -0
  29. data/lib/rbs/cli.rb +558 -0
  30. data/lib/rbs/constant.rb +26 -0
  31. data/lib/rbs/constant_table.rb +150 -0
  32. data/lib/rbs/definition.rb +170 -0
  33. data/lib/rbs/definition_builder.rb +919 -0
  34. data/lib/rbs/environment.rb +281 -0
  35. data/lib/rbs/environment_loader.rb +136 -0
  36. data/lib/rbs/environment_walker.rb +124 -0
  37. data/lib/rbs/errors.rb +187 -0
  38. data/lib/rbs/location.rb +102 -0
  39. data/lib/rbs/method_type.rb +123 -0
  40. data/lib/rbs/namespace.rb +91 -0
  41. data/lib/rbs/parser.y +1344 -0
  42. data/lib/rbs/prototype/rb.rb +553 -0
  43. data/lib/rbs/prototype/rbi.rb +587 -0
  44. data/lib/rbs/prototype/runtime.rb +381 -0
  45. data/lib/rbs/substitution.rb +46 -0
  46. data/lib/rbs/test.rb +26 -0
  47. data/lib/rbs/test/errors.rb +61 -0
  48. data/lib/rbs/test/hook.rb +294 -0
  49. data/lib/rbs/test/setup.rb +58 -0
  50. data/lib/rbs/test/spy.rb +325 -0
  51. data/lib/rbs/test/test_helper.rb +183 -0
  52. data/lib/rbs/test/type_check.rb +254 -0
  53. data/lib/rbs/type_name.rb +70 -0
  54. data/lib/rbs/types.rb +936 -0
  55. data/lib/rbs/variance_calculator.rb +138 -0
  56. data/lib/rbs/vendorer.rb +47 -0
  57. data/lib/rbs/version.rb +3 -0
  58. data/lib/rbs/writer.rb +269 -0
  59. data/lib/ruby/signature.rb +7 -0
  60. data/rbs.gemspec +46 -0
  61. data/stdlib/abbrev/abbrev.rbs +60 -0
  62. data/stdlib/base64/base64.rbs +71 -0
  63. data/stdlib/benchmark/benchmark.rbs +372 -0
  64. data/stdlib/builtin/array.rbs +1997 -0
  65. data/stdlib/builtin/basic_object.rbs +280 -0
  66. data/stdlib/builtin/binding.rbs +177 -0
  67. data/stdlib/builtin/builtin.rbs +45 -0
  68. data/stdlib/builtin/class.rbs +145 -0
  69. data/stdlib/builtin/comparable.rbs +116 -0
  70. data/stdlib/builtin/complex.rbs +400 -0
  71. data/stdlib/builtin/constants.rbs +37 -0
  72. data/stdlib/builtin/data.rbs +5 -0
  73. data/stdlib/builtin/deprecated.rbs +2 -0
  74. data/stdlib/builtin/dir.rbs +413 -0
  75. data/stdlib/builtin/encoding.rbs +607 -0
  76. data/stdlib/builtin/enumerable.rbs +404 -0
  77. data/stdlib/builtin/enumerator.rbs +260 -0
  78. data/stdlib/builtin/errno.rbs +781 -0
  79. data/stdlib/builtin/errors.rbs +582 -0
  80. data/stdlib/builtin/exception.rbs +194 -0
  81. data/stdlib/builtin/false_class.rbs +40 -0
  82. data/stdlib/builtin/fiber.rbs +68 -0
  83. data/stdlib/builtin/fiber_error.rbs +12 -0
  84. data/stdlib/builtin/file.rbs +1076 -0
  85. data/stdlib/builtin/file_test.rbs +59 -0
  86. data/stdlib/builtin/float.rbs +696 -0
  87. data/stdlib/builtin/gc.rbs +243 -0
  88. data/stdlib/builtin/hash.rbs +1029 -0
  89. data/stdlib/builtin/integer.rbs +707 -0
  90. data/stdlib/builtin/io.rbs +683 -0
  91. data/stdlib/builtin/kernel.rbs +576 -0
  92. data/stdlib/builtin/marshal.rbs +161 -0
  93. data/stdlib/builtin/match_data.rbs +271 -0
  94. data/stdlib/builtin/math.rbs +369 -0
  95. data/stdlib/builtin/method.rbs +185 -0
  96. data/stdlib/builtin/module.rbs +1104 -0
  97. data/stdlib/builtin/nil_class.rbs +82 -0
  98. data/stdlib/builtin/numeric.rbs +409 -0
  99. data/stdlib/builtin/object.rbs +824 -0
  100. data/stdlib/builtin/proc.rbs +429 -0
  101. data/stdlib/builtin/process.rbs +1227 -0
  102. data/stdlib/builtin/random.rbs +267 -0
  103. data/stdlib/builtin/range.rbs +226 -0
  104. data/stdlib/builtin/rational.rbs +424 -0
  105. data/stdlib/builtin/rb_config.rbs +57 -0
  106. data/stdlib/builtin/regexp.rbs +1083 -0
  107. data/stdlib/builtin/ruby_vm.rbs +14 -0
  108. data/stdlib/builtin/signal.rbs +55 -0
  109. data/stdlib/builtin/string.rbs +1901 -0
  110. data/stdlib/builtin/string_io.rbs +284 -0
  111. data/stdlib/builtin/struct.rbs +40 -0
  112. data/stdlib/builtin/symbol.rbs +228 -0
  113. data/stdlib/builtin/thread.rbs +1108 -0
  114. data/stdlib/builtin/thread_group.rbs +23 -0
  115. data/stdlib/builtin/time.rbs +1047 -0
  116. data/stdlib/builtin/trace_point.rbs +290 -0
  117. data/stdlib/builtin/true_class.rbs +46 -0
  118. data/stdlib/builtin/unbound_method.rbs +153 -0
  119. data/stdlib/builtin/warning.rbs +17 -0
  120. data/stdlib/coverage/coverage.rbs +62 -0
  121. data/stdlib/csv/csv.rbs +773 -0
  122. data/stdlib/erb/erb.rbs +392 -0
  123. data/stdlib/find/find.rbs +40 -0
  124. data/stdlib/ipaddr/ipaddr.rbs +247 -0
  125. data/stdlib/json/json.rbs +335 -0
  126. data/stdlib/pathname/pathname.rbs +1093 -0
  127. data/stdlib/prime/integer-extension.rbs +23 -0
  128. data/stdlib/prime/prime.rbs +188 -0
  129. data/stdlib/securerandom/securerandom.rbs +9 -0
  130. data/stdlib/set/set.rbs +301 -0
  131. data/stdlib/tmpdir/tmpdir.rbs +53 -0
  132. metadata +292 -0
@@ -0,0 +1,576 @@
1
+ # The [Kernel](Kernel) module is included by class
2
+ # [Object](https://ruby-doc.org/core-2.6.3/Object.html), so its methods
3
+ # are available in every Ruby object.
4
+ #
5
+ # The [Kernel](Kernel) instance methods are documented
6
+ # in class [Object](https://ruby-doc.org/core-2.6.3/Object.html) while the
7
+ # module methods are documented here. These methods are called without a
8
+ # receiver and thus can be called in functional form:
9
+ #
10
+ # ```ruby
11
+ # sprintf "%.1f", 1.234 #=> "1.2"
12
+ # ```
13
+ module Kernel
14
+ def caller: (?Integer start_or_range, ?Integer length) -> ::Array[String]?
15
+ | (?::Range[Integer] start_or_range) -> ::Array[String]?
16
+ | () -> ::Array[String]
17
+
18
+ def caller_locations: (?Integer start_or_range, ?Integer length) -> ::Array[Thread::Backtrace::Location]?
19
+ | (?::Range[Integer] start_or_range) -> ::Array[Thread::Backtrace::Location]?
20
+
21
+ def catch: [T] (T tag) { (T tag) -> untyped } -> untyped
22
+ | () { (Object tag) -> untyped } -> untyped
23
+
24
+ # In a perfect world this should be:
25
+ #
26
+ # returns(T.class_of(T.self_type))
27
+ #
28
+ # but that doesn't work (yet). Even making it:
29
+ #
30
+ # returns(Class)
31
+ #
32
+ # is very surprising since users expect their methods to be present.
33
+ # So we settle for untyped.
34
+ def `class`: () -> untyped
35
+
36
+ def define_singleton_method: (Symbol | String symbol, ?Proc | Method | UnboundMethod method) -> Symbol
37
+ | (Symbol | String symbol) { () -> untyped } -> Symbol
38
+
39
+ def eval: (String arg0, ?Binding arg1, ?String filename, ?Integer lineno) -> untyped
40
+
41
+ # Returns `true` if `yield` would execute a block in the current context.
42
+ # The `iterator?` form is mildly deprecated.
43
+ #
44
+ # ```ruby
45
+ # def try
46
+ # if block_given?
47
+ # yield
48
+ # else
49
+ # "no block"
50
+ # end
51
+ # end
52
+ # try #=> "no block"
53
+ # try { "hello" } #=> "hello"
54
+ # try do "hello" end #=> "hello"
55
+ # ```
56
+ def iterator?: () -> bool
57
+ alias block_given? iterator?
58
+
59
+ # Returns the names of the current local variables.
60
+ #
61
+ # ```ruby
62
+ # fred = 1
63
+ # for i in 1..10
64
+ # # ...
65
+ # end
66
+ # local_variables #=> [:fred, :i]
67
+ # ```
68
+ def local_variables: () -> ::Array[Symbol]
69
+
70
+ def srand: (?Numeric number) -> Numeric
71
+
72
+ def !~: (untyped other) -> bool
73
+
74
+ def <=>: (untyped other) -> Integer?
75
+
76
+ def ===: (untyped other) -> bool
77
+
78
+ def =~: (untyped other) -> NilClass
79
+
80
+ def clone: (?freeze: (TrueClass | FalseClass)) -> self
81
+
82
+ def display: (?IO port) -> NilClass
83
+
84
+ def dup: () -> self
85
+
86
+ def enum_for: (Symbol method, *untyped args) -> ::Enumerator[untyped, untyped]
87
+ | (Symbol method, *untyped args) { (*untyped args) -> (Integer|Float|nil) } -> ::Enumerator[untyped, untyped]
88
+ alias to_enum enum_for
89
+
90
+ def eql?: (untyped other) -> bool
91
+
92
+ def `extend`: (*Module mod) -> self
93
+
94
+ # Creates a subprocess. If a block is specified, that block is run in the
95
+ # subprocess, and the subprocess terminates with a status of zero.
96
+ # Otherwise, the `fork` call returns twice, once in the parent, returning
97
+ # the process ID of the child, and once in the child, returning *nil* .
98
+ # The child process can exit using `Kernel.exit!` to avoid running any
99
+ # `at_exit` functions. The parent process should use `Process.wait` to
100
+ # collect the termination statuses of its children or use `Process.detach`
101
+ # to register disinterest in their status; otherwise, the operating system
102
+ # may accumulate zombie processes.
103
+ #
104
+ # The thread calling fork is the only thread in the created child process.
105
+ # fork doesn’t copy other threads.
106
+ #
107
+ # If fork is not usable, Process.respond\_to?(:fork) returns false.
108
+ #
109
+ # Note that fork(2) is not available on some platforms like Windows and
110
+ # NetBSD 4. Therefore you should use spawn() instead of fork().
111
+ def fork: () -> Integer?
112
+ | () { () -> untyped } -> Integer?
113
+
114
+ def freeze: () -> self
115
+
116
+ def frozen?: () -> bool
117
+
118
+ def hash: () -> Integer
119
+
120
+ def initialize_copy: (self object) -> self
121
+
122
+ def inspect: () -> String
123
+
124
+ def instance_of?: (Class arg0) -> bool
125
+
126
+ def instance_variable_defined?: (Symbol | String arg0) -> bool
127
+
128
+ def instance_variable_get: (Symbol | String arg0) -> untyped
129
+
130
+ def instance_variable_set: [T] (Symbol | String arg0, T arg1) -> T
131
+
132
+ def instance_variables: () -> ::Array[Symbol]
133
+
134
+ def is_a?: (Class | Module arg0) -> bool
135
+ alias kind_of? is_a?
136
+
137
+ def method: (Symbol | String arg0) -> Method
138
+
139
+ def methods: (?bool regular) -> ::Array[Symbol]
140
+
141
+ def `nil?`: () -> FalseClass
142
+
143
+ def private_methods: (?bool all) -> ::Array[Symbol]
144
+
145
+ def protected_methods: (?bool all) -> ::Array[Symbol]
146
+
147
+ def public_method: (Symbol | String arg0) -> Method
148
+
149
+ def public_methods: (?bool all) -> ::Array[Symbol]
150
+
151
+ def `public_send`: (Symbol | String arg0, *untyped args) -> untyped
152
+ | (Symbol | String arg0, *untyped args) { (*untyped) -> untyped } -> untyped
153
+
154
+ def remove_instance_variable: (Symbol | String arg0) -> untyped
155
+
156
+ def `send`: (String | Symbol arg0, *untyped arg1) -> untyped
157
+ | (String | Symbol arg0, *untyped arg1) { (*untyped) -> untyped } -> untyped
158
+
159
+ def `singleton_class`: () -> Class
160
+
161
+ def singleton_method: (Symbol | String arg0) -> Method
162
+
163
+ def singleton_methods: (?bool all) -> ::Array[Symbol]
164
+
165
+ def taint: () -> self
166
+ alias untrust taint
167
+
168
+ def tainted?: () -> bool
169
+ alias untrusted? tainted?
170
+
171
+ def tap: () { (untyped x) -> void } -> self
172
+
173
+ def to_s: () -> String
174
+
175
+ def untaint: () -> self
176
+ alias trust untaint
177
+
178
+ # Returns `arg` as an [Array](https://ruby-doc.org/core-2.6.3/Array.html)
179
+ # .
180
+ #
181
+ # First tries to call `to_ary` on `arg`, then `to_a` . If `arg` does not
182
+ # respond to `to_ary` or `to_a`, returns an
183
+ # [Array](https://ruby-doc.org/core-2.6.3/Array.html) of length 1
184
+ # containing `arg` .
185
+ #
186
+ # If `to_ary` or `to_a` returns something other than an
187
+ # [Array](https://ruby-doc.org/core-2.6.3/Array.html), raises a
188
+ # `TypeError` .
189
+ #
190
+ # ```ruby
191
+ # Array(["a", "b"]) #=> ["a", "b"]
192
+ # Array(1..5) #=> [1, 2, 3, 4, 5]
193
+ # Array(key: :value) #=> [[:key, :value]]
194
+ # Array(nil) #=> []
195
+ # Array(1) #=> [1]
196
+ # ```
197
+ def Array: (NilClass x) -> [ ]
198
+ | [T] (::Array[T] x) -> ::Array[T]
199
+ | [T] (::Range[T] x) -> ::Array[T]
200
+ | [K, V] (::Hash[K, V] x) -> ::Array[[K, V]]
201
+ | [T] (T x) -> ::Array[T]
202
+
203
+ def Complex: (Numeric | String x, ?Numeric | String y, ?exception: bool exception) -> Complex
204
+
205
+ def Float: (Numeric | String x, ?exception: bool exception) -> Float
206
+
207
+ def Hash: [K, V] (Object x) -> ::Hash[K, V]
208
+
209
+ def Integer: (Numeric | String arg, ?exception: bool exception) -> Integer
210
+ | (String arg, ?Integer base, ?exception: bool exception) -> Integer
211
+
212
+ def Rational: (Numeric | String | Object x, ?Numeric | String y, ?exception: bool exception) -> Rational
213
+
214
+ def String: (Object x) -> String
215
+
216
+ # Returns the called name of the current method as a
217
+ # [Symbol](https://ruby-doc.org/core-2.6.3/Symbol.html). If called
218
+ # outside of a method, it returns `nil` .
219
+ def __callee__: () -> Symbol?
220
+
221
+ # Returns the canonicalized absolute path of the directory of the file
222
+ # from which this method is called. It means symlinks in the path is
223
+ # resolved. If `__FILE__` is `nil`, it returns `nil` . The return value
224
+ # equals to `File.dirname(File.realpath(__FILE__))` .
225
+ def __dir__: () -> String?
226
+
227
+ # Returns the name at the definition of the current method as a
228
+ # [Symbol](https://ruby-doc.org/core-2.6.3/Symbol.html). If called
229
+ # outside of a method, it returns `nil` .
230
+ def __method__: () -> Symbol?
231
+
232
+ def `: (String arg0) -> String
233
+
234
+ def abort: (?String msg) -> bot
235
+
236
+ def at_exit: () { () -> untyped } -> Proc
237
+
238
+ def autoload: (String | Symbol _module, String filename) -> NilClass
239
+
240
+ def autoload?: (Symbol | String name) -> String?
241
+
242
+ # Returns a `Binding` object, describing the variable and method bindings
243
+ # at the point of call. This object can be used when calling `eval` to
244
+ # execute the evaluated command in this environment. See also the
245
+ # description of class `Binding` .
246
+ #
247
+ # ```ruby
248
+ # def get_binding(param)
249
+ # binding
250
+ # end
251
+ # b = get_binding("hello")
252
+ # eval("param", b) #=> "hello"
253
+ # ```
254
+ def binding: () -> Binding
255
+
256
+ # Initiates the termination of the Ruby script by raising the `SystemExit`
257
+ # exception. This exception may be caught. The optional parameter is used
258
+ # to return a status code to the invoking environment. `true` and `FALSE`
259
+ # of *status* means success and failure respectively. The interpretation
260
+ # of other integer values are system dependent.
261
+ #
262
+ # ```ruby
263
+ # begin
264
+ # exit
265
+ # puts "never get here"
266
+ # rescue SystemExit
267
+ # puts "rescued a SystemExit exception"
268
+ # end
269
+ # puts "after begin block"
270
+ # ```
271
+ #
272
+ # *produces:*
273
+ #
274
+ # rescued a SystemExit exception
275
+ # after begin block
276
+ #
277
+ # Just prior to termination, Ruby executes any `at_exit` functions (see
278
+ # Kernel::at\_exit) and runs any object finalizers (see
279
+ # [ObjectSpace.define\_finalizer](https://ruby-doc.org/core-2.6.3/ObjectSpace.html#method-c-define_finalizer)
280
+ # ).
281
+ #
282
+ # ```ruby
283
+ # at_exit { puts "at_exit function" }
284
+ # ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
285
+ # exit
286
+ # ```
287
+ #
288
+ # *produces:*
289
+ #
290
+ # at_exit function
291
+ # in finalizer
292
+ def exit: () -> bot
293
+ | (?Integer | TrueClass | FalseClass status) -> bot
294
+
295
+ def exit!: (Integer | TrueClass | FalseClass status) -> bot
296
+
297
+ # With no arguments, raises the exception in `$!` or raises a
298
+ # `RuntimeError` if `$!` is `nil` . With a single `String` argument,
299
+ # raises a `RuntimeError` with the string as a message. Otherwise, the
300
+ # first parameter should be the name of an `Exception` class (or an object
301
+ # that returns an `Exception` object when sent an `exception` message).
302
+ # The optional second parameter sets the message associated with the
303
+ # exception, and the third parameter is an array of callback information.
304
+ # Exceptions are caught by the `rescue` clause of `begin...end` blocks.
305
+ #
306
+ # ```ruby
307
+ # raise "Failed to create socket"
308
+ # raise ArgumentError, "No parameters", caller
309
+ # ```
310
+ #
311
+ # The `cause` of the generated exception is automatically set to the
312
+ # “current” exception ( `$!` ) if any. An alternative value, either an
313
+ # `Exception` object or `nil`, can be specified via the `:cause`
314
+ # argument.
315
+ def fail: () -> bot
316
+ | (String arg0) -> bot
317
+ | (_Exception arg0, ?untyped arg1, ?::Array[String] arg2) -> bot
318
+ alias raise fail
319
+
320
+ def format: (String format, *untyped args) -> String
321
+ alias sprintf format
322
+
323
+ def gets: (?String arg0, ?Integer arg1) -> String?
324
+
325
+ # Returns an array of the names of global variables.
326
+ #
327
+ # ```ruby
328
+ # global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
329
+ # ```
330
+ def global_variables: () -> ::Array[Symbol]
331
+
332
+ def load: (String filename, ?bool arg0) -> bool
333
+
334
+ # Repeatedly executes the block.
335
+ #
336
+ # If no block is given, an enumerator is returned instead.
337
+ #
338
+ # ```ruby
339
+ # loop do
340
+ # print "Input: "
341
+ # line = gets
342
+ # break if !line or line =~ /^qQ/
343
+ # # ...
344
+ # end
345
+ # ```
346
+ #
347
+ # [StopIteration](https://ruby-doc.org/core-2.6.3/StopIteration.html)
348
+ # raised in the block breaks the loop. In this case, loop returns the
349
+ # "result" value stored in the exception.
350
+ #
351
+ # ```ruby
352
+ # enum = Enumerator.new { |y|
353
+ # y << "one"
354
+ # y << "two"
355
+ # :ok
356
+ # }
357
+ #
358
+ # result = loop {
359
+ # puts enum.next
360
+ # } #=> :ok
361
+ # ```
362
+ def loop: () { (nil) -> untyped } -> bot
363
+ | () -> ::Enumerator[nil, bot]
364
+
365
+ def open: (String name, ?String mode, ?Integer perm) -> IO?
366
+ | [T] (String name, ?String mode, ?Integer perm) { (IO) -> T } -> T
367
+
368
+ # Prints each object in turn to `$stdout` . If the output field separator
369
+ # ( `$,` ) is not `nil`, its contents will appear between each field. If
370
+ # the output record separator ( `$\` ) is not `nil`, it will be appended
371
+ # to the output. If no arguments are given, prints `$_` . Objects that
372
+ # aren’t strings will be converted by calling their `to_s` method.
373
+ #
374
+ # ```ruby
375
+ # print "cat", [1,2,3], 99, "\n"
376
+ # $, = ", "
377
+ # $\ = "\n"
378
+ # print "cat", [1,2,3], 99
379
+ # ```
380
+ #
381
+ # *produces:*
382
+ #
383
+ # cat12399
384
+ # cat, 1, 2, 3, 99
385
+ def print: (*Kernel args) -> nil
386
+
387
+ def printf: (IO arg0, String arg1, *untyped args) -> nil
388
+ | (String arg1, *untyped args) -> nil
389
+ | -> nil
390
+
391
+ def proc: () { () -> untyped } -> Proc
392
+
393
+ def lambda: () { () -> untyped } -> Proc
394
+
395
+ def putc: (Integer arg0) -> Integer
396
+ | (String arg0) -> String
397
+
398
+ def puts: (*untyped arg0) -> NilClass
399
+
400
+ def p: [T] (T arg0) -> T
401
+ | (*untyped arg0) -> Array[untyped]
402
+
403
+ def pp: [T] (T arg0) -> T
404
+ | (*untyped arg0) -> Array[untyped]
405
+
406
+ # If called without an argument, or if `max.to_i.abs == 0`, rand returns
407
+ # a pseudo-random floating point number between 0.0 and 1.0, including 0.0
408
+ # and excluding 1.0.
409
+ #
410
+ # ```ruby
411
+ # rand #=> 0.2725926052826416
412
+ # ```
413
+ #
414
+ # When `max.abs` is greater than or equal to 1, `rand` returns a
415
+ # pseudo-random integer greater than or equal to 0 and less than
416
+ # `max.to_i.abs` .
417
+ #
418
+ # ```ruby
419
+ # rand(100) #=> 12
420
+ # ```
421
+ #
422
+ # When `max` is a [Range](https://ruby-doc.org/core-2.6.3/Range.html),
423
+ # `rand` returns a random number where range.member?(number) == true.
424
+ #
425
+ # Negative or floating point values for `max` are allowed, but may give
426
+ # surprising results.
427
+ #
428
+ # ```ruby
429
+ # rand(-100) # => 87
430
+ # rand(-0.5) # => 0.8130921818028143
431
+ # rand(1.9) # equivalent to rand(1), which is always 0
432
+ # ```
433
+ #
434
+ # [\#srand](Kernel.downloaded.ruby_doc#method-i-srand) may be used to
435
+ # ensure that sequences of random numbers are reproducible between
436
+ # different runs of a program.
437
+ #
438
+ # See also
439
+ # [Random\#rand](https://ruby-doc.org/core-2.6.3/Random.html#method-i-rand)
440
+ # .
441
+ def rand: () -> Float
442
+ | (Integer arg0) -> Integer
443
+ | (::Range[Integer] arg0) -> Integer
444
+ | (::Range[Float] arg0) -> Float
445
+
446
+ def readline: (?String arg0, ?Integer arg1) -> String
447
+
448
+ def readlines: (?String arg0, ?Integer arg1) -> ::Array[String]
449
+
450
+ def require: (String path) -> bool
451
+
452
+ def require_relative: (String feature) -> bool
453
+
454
+ def select: (::Array[IO] read, ?::Array[IO] write, ?::Array[IO] error, ?Integer timeout) -> ::Array[String]
455
+
456
+ def sleep: () -> bot
457
+ | (Numeric duration) -> Integer
458
+
459
+ def syscall: (Integer num, *untyped args) -> untyped
460
+
461
+ def test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
462
+
463
+ def throw: (Object tag, ?untyped obj) -> bot
464
+
465
+ def warn: (*untyped msg, ?uplevel: Integer | nil) -> NilClass
466
+
467
+ # Replaces the current process by running the given external *command* ,
468
+ # which can take one of the following forms:
469
+ #
470
+ # - `exec(commandline)`
471
+ # command line string which is passed to the standard shell
472
+ #
473
+ # - `exec(cmdname, arg1, ...)`
474
+ # command name and one or more arguments (no shell)
475
+ #
476
+ # - `exec([cmdname, argv0], arg1, ...)`
477
+ # command name, [argv](https://ruby-doc.org/core-2.6.3/0) and zero or
478
+ # more arguments (no shell)
479
+ #
480
+ # In the first form, the string is taken as a command line that is subject
481
+ # to shell expansion before being executed.
482
+ #
483
+ # The standard shell always means `"/bin/sh"` on Unix-like systems, same
484
+ # as `ENV["RUBYSHELL"]` (or `ENV["COMSPEC"]` on Windows NT series), and
485
+ # similar.
486
+ #
487
+ # If the string from the first form ( `exec("command")` ) follows these
488
+ # simple rules:
489
+ #
490
+ # - no meta characters
491
+ #
492
+ # - no shell reserved word and no special built-in
493
+ #
494
+ # - Ruby invokes the command directly without shell
495
+ #
496
+ # You can force shell invocation by adding “;” to the string (because “;”
497
+ # is a meta character).
498
+ #
499
+ # Note that this behavior is observable by pid obtained (return value of
500
+ # spawn() and
501
+ # [IO\#pid](https://ruby-doc.org/core-2.6.3/IO.html#method-i-pid) for
502
+ # [IO.popen](https://ruby-doc.org/core-2.6.3/IO.html#method-c-popen) ) is
503
+ # the pid of the invoked command, not shell.
504
+ #
505
+ # In the second form ( `exec("command1", "arg1", ...)` ), the first is
506
+ # taken as a command name and the rest are passed as parameters to command
507
+ # with no shell expansion.
508
+ #
509
+ # In the third form ( `exec(["command", "argv0"], "arg1", ...)` ),
510
+ # starting a two-element array at the beginning of the command, the first
511
+ # element is the command to be executed, and the second argument is used
512
+ # as the `argv[0]` value, which may show up in process listings.
513
+ #
514
+ # In order to execute the command, one of the `exec(2)` system calls are
515
+ # used, so the running command may inherit some of the environment of the
516
+ # original program (including open file descriptors).
517
+ #
518
+ # This behavior is modified by the given `env` and `options` parameters.
519
+ # See ::spawn for details.
520
+ #
521
+ # If the command fails to execute (typically `Errno::ENOENT` when it was
522
+ # not found) a
523
+ # [SystemCallError](https://ruby-doc.org/core-2.6.3/SystemCallError.html)
524
+ # exception is raised.
525
+ #
526
+ # This method modifies process attributes according to given `options`
527
+ # before `exec(2)` system call. See ::spawn for more details about the
528
+ # given `options` .
529
+ #
530
+ # The modified attributes may be retained when `exec(2)` system call
531
+ # fails.
532
+ #
533
+ # For example, hard resource limits are not restorable.
534
+ #
535
+ # Consider to create a child process using ::spawn or
536
+ # [\#system](Kernel.downloaded.ruby_doc#method-i-system) if this is not
537
+ # acceptable.
538
+ #
539
+ # ```ruby
540
+ # exec "echo *" # echoes list of files in current directory
541
+ # # never get here
542
+ #
543
+ # exec "echo", "*" # echoes an asterisk
544
+ # # never get here
545
+ # ```
546
+ def exec: (*String args) -> bot
547
+
548
+ # Executes *command…* in a subshell. *command…* is one of following forms.
549
+ #
550
+ # commandline : command line string which is passed to the standard shell
551
+ # cmdname, arg1, ... : command name and one or more arguments (no shell)
552
+ # [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
553
+ #
554
+ # system returns `true` if the command gives zero exit status, `false` for
555
+ # non zero exit status. Returns `nil` if command execution fails. An error
556
+ # status is available in `$?` . The arguments are processed in the same
557
+ # way as for `Kernel.spawn` .
558
+ #
559
+ # The hash arguments, env and options, are same as `exec` and `spawn` .
560
+ # See `Kernel.spawn` for details.
561
+ #
562
+ # ```ruby
563
+ # system("echo *")
564
+ # system("echo", "*")
565
+ # ```
566
+ #
567
+ # *produces:*
568
+ #
569
+ # config.h main.rb
570
+ # *
571
+ #
572
+ # See `Kernel.exec` for the standard shell.
573
+ def system: (*String args) -> (NilClass | FalseClass | TrueClass)
574
+ end
575
+
576
+ Kernel::RUBYGEMS_ACTIVATION_MONITOR: untyped