rbs 4.1.0.pre.2-java

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 (574) hide show
  1. checksums.yaml +7 -0
  2. data/.clang-format +75 -0
  3. data/.clangd +2 -0
  4. data/.github/dependabot.yml +24 -0
  5. data/.github/workflows/bundle-update.yml +63 -0
  6. data/.github/workflows/c-check.yml +61 -0
  7. data/.github/workflows/comments.yml +37 -0
  8. data/.github/workflows/dependabot.yml +30 -0
  9. data/.github/workflows/jruby.yml +67 -0
  10. data/.github/workflows/milestone.yml +83 -0
  11. data/.github/workflows/ruby.yml +158 -0
  12. data/.github/workflows/rust.yml +184 -0
  13. data/.github/workflows/truffleruby.yml +54 -0
  14. data/.github/workflows/typecheck.yml +39 -0
  15. data/.github/workflows/wasm.yml +53 -0
  16. data/.github/workflows/windows.yml +49 -0
  17. data/.gitignore +38 -0
  18. data/.rubocop.yml +72 -0
  19. data/BSDL +22 -0
  20. data/CHANGELOG.md +2292 -0
  21. data/COPYING +56 -0
  22. data/README.md +240 -0
  23. data/Rakefile +869 -0
  24. data/Steepfile +53 -0
  25. data/config.yml +913 -0
  26. data/core/array.rbs +4142 -0
  27. data/core/basic_object.rbs +376 -0
  28. data/core/binding.rbs +148 -0
  29. data/core/builtin.rbs +278 -0
  30. data/core/class.rbs +223 -0
  31. data/core/comparable.rbs +192 -0
  32. data/core/complex.rbs +812 -0
  33. data/core/constants.rbs +96 -0
  34. data/core/data.rbs +415 -0
  35. data/core/dir.rbs +993 -0
  36. data/core/encoding.rbs +1368 -0
  37. data/core/enumerable.rbs +2506 -0
  38. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  39. data/core/enumerator/product.rbs +92 -0
  40. data/core/enumerator.rbs +705 -0
  41. data/core/env.rbs +6 -0
  42. data/core/errno.rbs +682 -0
  43. data/core/errors.rbs +789 -0
  44. data/core/exception.rbs +485 -0
  45. data/core/false_class.rbs +82 -0
  46. data/core/fiber.rbs +570 -0
  47. data/core/fiber_error.rbs +11 -0
  48. data/core/file.rbs +2045 -0
  49. data/core/file_constants.rbs +463 -0
  50. data/core/file_stat.rbs +534 -0
  51. data/core/file_test.rbs +331 -0
  52. data/core/float.rbs +1316 -0
  53. data/core/gc.rbs +788 -0
  54. data/core/global_variables.rbs +184 -0
  55. data/core/hash.rbs +2183 -0
  56. data/core/integer.rbs +1374 -0
  57. data/core/io/buffer.rbs +995 -0
  58. data/core/io/wait.rbs +48 -0
  59. data/core/io.rbs +3472 -0
  60. data/core/kernel.rbs +3172 -0
  61. data/core/marshal.rbs +207 -0
  62. data/core/match_data.rbs +637 -0
  63. data/core/math.rbs +770 -0
  64. data/core/method.rbs +422 -0
  65. data/core/module.rbs +1856 -0
  66. data/core/nil_class.rbs +210 -0
  67. data/core/numeric.rbs +832 -0
  68. data/core/object.rbs +108 -0
  69. data/core/object_space/weak_key_map.rbs +166 -0
  70. data/core/object_space.rbs +197 -0
  71. data/core/pathname.rbs +1322 -0
  72. data/core/proc.rbs +905 -0
  73. data/core/process.rbs +2316 -0
  74. data/core/ractor.rbs +924 -0
  75. data/core/random.rbs +255 -0
  76. data/core/range.rbs +1209 -0
  77. data/core/rational.rbs +502 -0
  78. data/core/rb_config.rbs +88 -0
  79. data/core/rbs/ops.rbs +154 -0
  80. data/core/rbs/unnamed/argf.rbs +1236 -0
  81. data/core/rbs/unnamed/env_class.rbs +1214 -0
  82. data/core/rbs/unnamed/main_class.rbs +123 -0
  83. data/core/rbs/unnamed/random.rbs +186 -0
  84. data/core/refinement.rbs +59 -0
  85. data/core/regexp.rbs +1974 -0
  86. data/core/ruby.rbs +53 -0
  87. data/core/ruby_vm.rbs +809 -0
  88. data/core/rubygems/basic_specification.rbs +6 -0
  89. data/core/rubygems/config_file.rbs +38 -0
  90. data/core/rubygems/dependency_installer.rbs +6 -0
  91. data/core/rubygems/errors.rbs +109 -0
  92. data/core/rubygems/installer.rbs +15 -0
  93. data/core/rubygems/path_support.rbs +6 -0
  94. data/core/rubygems/platform.rbs +7 -0
  95. data/core/rubygems/request_set.rbs +49 -0
  96. data/core/rubygems/requirement.rbs +148 -0
  97. data/core/rubygems/rubygems.rbs +1105 -0
  98. data/core/rubygems/source_list.rbs +15 -0
  99. data/core/rubygems/specification.rbs +23 -0
  100. data/core/rubygems/stream_ui.rbs +5 -0
  101. data/core/rubygems/uninstaller.rbs +10 -0
  102. data/core/rubygems/version.rbs +293 -0
  103. data/core/set.rbs +751 -0
  104. data/core/signal.rbs +110 -0
  105. data/core/string.rbs +5532 -0
  106. data/core/struct.rbs +668 -0
  107. data/core/symbol.rbs +482 -0
  108. data/core/thread.rbs +1826 -0
  109. data/core/thread_group.rbs +79 -0
  110. data/core/time.rbs +1793 -0
  111. data/core/trace_point.rbs +483 -0
  112. data/core/true_class.rbs +98 -0
  113. data/core/unbound_method.rbs +337 -0
  114. data/core/warning.rbs +87 -0
  115. data/docs/CONTRIBUTING.md +107 -0
  116. data/docs/aliases.md +79 -0
  117. data/docs/architecture.md +110 -0
  118. data/docs/collection.md +192 -0
  119. data/docs/config.md +171 -0
  120. data/docs/data_and_struct.md +86 -0
  121. data/docs/encoding.md +56 -0
  122. data/docs/gem.md +56 -0
  123. data/docs/inline.md +634 -0
  124. data/docs/rbs_by_example.md +309 -0
  125. data/docs/repo.md +125 -0
  126. data/docs/rust.md +96 -0
  127. data/docs/sigs.md +167 -0
  128. data/docs/stdlib.md +147 -0
  129. data/docs/syntax.md +940 -0
  130. data/docs/tools.md +17 -0
  131. data/docs/type_fingerprint.md +21 -0
  132. data/docs/wasm_serialization.md +80 -0
  133. data/exe/rbs +7 -0
  134. data/ext/rbs_extension/ast_translation.c +1855 -0
  135. data/ext/rbs_extension/ast_translation.h +41 -0
  136. data/ext/rbs_extension/class_constants.c +187 -0
  137. data/ext/rbs_extension/class_constants.h +104 -0
  138. data/ext/rbs_extension/compat.h +10 -0
  139. data/ext/rbs_extension/extconf.rb +40 -0
  140. data/ext/rbs_extension/legacy_location.c +294 -0
  141. data/ext/rbs_extension/legacy_location.h +82 -0
  142. data/ext/rbs_extension/main.c +613 -0
  143. data/ext/rbs_extension/rbs_extension.h +16 -0
  144. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  145. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  146. data/goodcheck.yml +91 -0
  147. data/include/rbs/ast.h +1047 -0
  148. data/include/rbs/defines.h +99 -0
  149. data/include/rbs/lexer.h +207 -0
  150. data/include/rbs/location.h +40 -0
  151. data/include/rbs/parser.h +153 -0
  152. data/include/rbs/serialize.h +39 -0
  153. data/include/rbs/string.h +47 -0
  154. data/include/rbs/util/rbs_allocator.h +59 -0
  155. data/include/rbs/util/rbs_assert.h +20 -0
  156. data/include/rbs/util/rbs_buffer.h +83 -0
  157. data/include/rbs/util/rbs_constant_pool.h +155 -0
  158. data/include/rbs/util/rbs_encoding.h +282 -0
  159. data/include/rbs/util/rbs_unescape.h +24 -0
  160. data/include/rbs.h +14 -0
  161. data/lib/rbs/ancestor_graph.rb +92 -0
  162. data/lib/rbs/annotate/annotations.rb +199 -0
  163. data/lib/rbs/annotate/formatter.rb +82 -0
  164. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  165. data/lib/rbs/annotate/rdoc_source.rb +131 -0
  166. data/lib/rbs/annotate.rb +8 -0
  167. data/lib/rbs/ast/annotation.rb +29 -0
  168. data/lib/rbs/ast/comment.rb +29 -0
  169. data/lib/rbs/ast/declarations.rb +472 -0
  170. data/lib/rbs/ast/directives.rb +49 -0
  171. data/lib/rbs/ast/members.rb +451 -0
  172. data/lib/rbs/ast/ruby/annotations.rb +451 -0
  173. data/lib/rbs/ast/ruby/comment_block.rb +247 -0
  174. data/lib/rbs/ast/ruby/declarations.rb +291 -0
  175. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  176. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  177. data/lib/rbs/ast/ruby/members.rb +762 -0
  178. data/lib/rbs/ast/type_param.rb +235 -0
  179. data/lib/rbs/ast/visitor.rb +137 -0
  180. data/lib/rbs/buffer.rb +189 -0
  181. data/lib/rbs/builtin_names.rb +58 -0
  182. data/lib/rbs/cli/colored_io.rb +48 -0
  183. data/lib/rbs/cli/diff.rb +84 -0
  184. data/lib/rbs/cli/validate.rb +294 -0
  185. data/lib/rbs/cli.rb +1253 -0
  186. data/lib/rbs/collection/cleaner.rb +38 -0
  187. data/lib/rbs/collection/config/lockfile.rb +92 -0
  188. data/lib/rbs/collection/config/lockfile_generator.rb +269 -0
  189. data/lib/rbs/collection/config.rb +81 -0
  190. data/lib/rbs/collection/installer.rb +32 -0
  191. data/lib/rbs/collection/sources/base.rb +14 -0
  192. data/lib/rbs/collection/sources/git.rb +265 -0
  193. data/lib/rbs/collection/sources/local.rb +81 -0
  194. data/lib/rbs/collection/sources/rubygems.rb +48 -0
  195. data/lib/rbs/collection/sources/stdlib.rb +50 -0
  196. data/lib/rbs/collection/sources.rb +38 -0
  197. data/lib/rbs/collection.rb +16 -0
  198. data/lib/rbs/constant.rb +28 -0
  199. data/lib/rbs/definition.rb +415 -0
  200. data/lib/rbs/definition_builder/ancestor_builder.rb +678 -0
  201. data/lib/rbs/definition_builder/method_builder.rb +295 -0
  202. data/lib/rbs/definition_builder.rb +1054 -0
  203. data/lib/rbs/diff.rb +131 -0
  204. data/lib/rbs/environment/class_entry.rb +69 -0
  205. data/lib/rbs/environment/module_entry.rb +66 -0
  206. data/lib/rbs/environment/use_map.rb +77 -0
  207. data/lib/rbs/environment.rb +1028 -0
  208. data/lib/rbs/environment_loader.rb +167 -0
  209. data/lib/rbs/environment_walker.rb +155 -0
  210. data/lib/rbs/errors.rb +634 -0
  211. data/lib/rbs/factory.rb +18 -0
  212. data/lib/rbs/file_finder.rb +28 -0
  213. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  214. data/lib/rbs/inline_parser.rb +568 -0
  215. data/lib/rbs/location_aux.rb +170 -0
  216. data/lib/rbs/locator.rb +247 -0
  217. data/lib/rbs/method_type.rb +145 -0
  218. data/lib/rbs/namespace.rb +154 -0
  219. data/lib/rbs/parser/lex_result.rb +15 -0
  220. data/lib/rbs/parser/token.rb +23 -0
  221. data/lib/rbs/parser_aux.rb +142 -0
  222. data/lib/rbs/prototype/helpers.rb +197 -0
  223. data/lib/rbs/prototype/node_usage.rb +99 -0
  224. data/lib/rbs/prototype/rb.rb +816 -0
  225. data/lib/rbs/prototype/rbi.rb +625 -0
  226. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  227. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  228. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  229. data/lib/rbs/prototype/runtime.rb +680 -0
  230. data/lib/rbs/repository.rb +127 -0
  231. data/lib/rbs/resolver/constant_resolver.rb +219 -0
  232. data/lib/rbs/resolver/type_name_resolver.rb +167 -0
  233. data/lib/rbs/rewriter.rb +70 -0
  234. data/lib/rbs/sorter.rb +198 -0
  235. data/lib/rbs/source.rb +99 -0
  236. data/lib/rbs/substitution.rb +83 -0
  237. data/lib/rbs/subtractor.rb +204 -0
  238. data/lib/rbs/test/errors.rb +80 -0
  239. data/lib/rbs/test/guaranteed.rb +30 -0
  240. data/lib/rbs/test/hook.rb +212 -0
  241. data/lib/rbs/test/observer.rb +19 -0
  242. data/lib/rbs/test/setup.rb +84 -0
  243. data/lib/rbs/test/setup_helper.rb +50 -0
  244. data/lib/rbs/test/tester.rb +167 -0
  245. data/lib/rbs/test/type_check.rb +457 -0
  246. data/lib/rbs/test.rb +112 -0
  247. data/lib/rbs/type_alias_dependency.rb +100 -0
  248. data/lib/rbs/type_alias_regularity.rb +126 -0
  249. data/lib/rbs/type_name.rb +122 -0
  250. data/lib/rbs/types.rb +1604 -0
  251. data/lib/rbs/unit_test/convertibles.rb +177 -0
  252. data/lib/rbs/unit_test/spy.rb +138 -0
  253. data/lib/rbs/unit_test/type_assertions.rb +383 -0
  254. data/lib/rbs/unit_test/with_aliases.rb +145 -0
  255. data/lib/rbs/unit_test.rb +6 -0
  256. data/lib/rbs/validator.rb +186 -0
  257. data/lib/rbs/variance_calculator.rb +189 -0
  258. data/lib/rbs/vendorer.rb +71 -0
  259. data/lib/rbs/version.rb +5 -0
  260. data/lib/rbs/wasm/deserializer.rb +213 -0
  261. data/lib/rbs/wasm/jars/asm-analysis.jar +0 -0
  262. data/lib/rbs/wasm/jars/asm-commons.jar +0 -0
  263. data/lib/rbs/wasm/jars/asm-tree.jar +0 -0
  264. data/lib/rbs/wasm/jars/asm-util.jar +0 -0
  265. data/lib/rbs/wasm/jars/asm.jar +0 -0
  266. data/lib/rbs/wasm/jars/compiler.jar +0 -0
  267. data/lib/rbs/wasm/jars/log.jar +0 -0
  268. data/lib/rbs/wasm/jars/runtime.jar +0 -0
  269. data/lib/rbs/wasm/jars/wasi.jar +0 -0
  270. data/lib/rbs/wasm/jars/wasm.jar +0 -0
  271. data/lib/rbs/wasm/location.rb +61 -0
  272. data/lib/rbs/wasm/parser.rb +137 -0
  273. data/lib/rbs/wasm/rbs_parser.wasm +0 -0
  274. data/lib/rbs/wasm/runtime.rb +217 -0
  275. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  276. data/lib/rbs/writer.rb +424 -0
  277. data/lib/rbs.rb +117 -0
  278. data/lib/rdoc/discover.rb +20 -0
  279. data/lib/rdoc_plugin/parser.rb +163 -0
  280. data/rbs.gemspec +68 -0
  281. data/schema/annotation.json +14 -0
  282. data/schema/comment.json +26 -0
  283. data/schema/decls.json +326 -0
  284. data/schema/function.json +87 -0
  285. data/schema/location.json +56 -0
  286. data/schema/members.json +266 -0
  287. data/schema/methodType.json +50 -0
  288. data/schema/typeParam.json +52 -0
  289. data/schema/types.json +317 -0
  290. data/sig/ancestor_builder.rbs +163 -0
  291. data/sig/ancestor_graph.rbs +60 -0
  292. data/sig/annotate/annotations.rbs +102 -0
  293. data/sig/annotate/formatter.rbs +24 -0
  294. data/sig/annotate/rdoc_annotater.rbs +85 -0
  295. data/sig/annotate/rdoc_source.rbs +32 -0
  296. data/sig/annotation.rbs +27 -0
  297. data/sig/ast/ruby/annotations.rbs +470 -0
  298. data/sig/ast/ruby/comment_block.rbs +127 -0
  299. data/sig/ast/ruby/declarations.rbs +158 -0
  300. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  301. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  302. data/sig/ast/ruby/members.rbs +198 -0
  303. data/sig/buffer.rbs +108 -0
  304. data/sig/builtin_names.rbs +44 -0
  305. data/sig/cli/colored_io.rbs +15 -0
  306. data/sig/cli/diff.rbs +15 -0
  307. data/sig/cli/validate.rbs +47 -0
  308. data/sig/cli.rbs +89 -0
  309. data/sig/collection/cleaner.rbs +13 -0
  310. data/sig/collection/config/lockfile.rbs +74 -0
  311. data/sig/collection/config/lockfile_generator.rbs +68 -0
  312. data/sig/collection/config.rbs +46 -0
  313. data/sig/collection/installer.rbs +17 -0
  314. data/sig/collection/sources.rbs +214 -0
  315. data/sig/collection.rbs +4 -0
  316. data/sig/comment.rbs +26 -0
  317. data/sig/constant.rbs +21 -0
  318. data/sig/declarations.rbs +274 -0
  319. data/sig/definition.rbs +232 -0
  320. data/sig/definition_builder.rbs +181 -0
  321. data/sig/diff.rbs +28 -0
  322. data/sig/directives.rbs +77 -0
  323. data/sig/environment/class_entry.rbs +50 -0
  324. data/sig/environment/module_entry.rbs +50 -0
  325. data/sig/environment.rbs +286 -0
  326. data/sig/environment_loader.rbs +111 -0
  327. data/sig/environment_walker.rbs +65 -0
  328. data/sig/errors.rbs +408 -0
  329. data/sig/factory.rbs +5 -0
  330. data/sig/file_finder.rbs +28 -0
  331. data/sig/inline_parser/comment_association.rbs +71 -0
  332. data/sig/inline_parser.rbs +126 -0
  333. data/sig/location.rbs +135 -0
  334. data/sig/locator.rbs +56 -0
  335. data/sig/manifest.yaml +5 -0
  336. data/sig/members.rbs +258 -0
  337. data/sig/method_builder.rbs +89 -0
  338. data/sig/method_types.rbs +58 -0
  339. data/sig/namespace.rbs +161 -0
  340. data/sig/parser.rbs +164 -0
  341. data/sig/prototype/helpers.rbs +29 -0
  342. data/sig/prototype/node_usage.rbs +20 -0
  343. data/sig/prototype/rb.rbs +96 -0
  344. data/sig/prototype/rbi.rbs +75 -0
  345. data/sig/prototype/runtime.rbs +182 -0
  346. data/sig/rbs.rbs +21 -0
  347. data/sig/rdoc/rbs.rbs +67 -0
  348. data/sig/repository.rbs +85 -0
  349. data/sig/resolver/constant_resolver.rbs +92 -0
  350. data/sig/resolver/context.rbs +34 -0
  351. data/sig/resolver/type_name_resolver.rbs +61 -0
  352. data/sig/rewriter.rbs +45 -0
  353. data/sig/shims/bundler.rbs +38 -0
  354. data/sig/shims/enumerable.rbs +5 -0
  355. data/sig/shims/rubygems.rbs +19 -0
  356. data/sig/sorter.rbs +41 -0
  357. data/sig/source.rbs +48 -0
  358. data/sig/substitution.rbs +48 -0
  359. data/sig/subtractor.rbs +37 -0
  360. data/sig/test/errors.rbs +52 -0
  361. data/sig/test/guranteed.rbs +9 -0
  362. data/sig/test/type_check.rbs +19 -0
  363. data/sig/test.rbs +82 -0
  364. data/sig/type_alias_dependency.rbs +53 -0
  365. data/sig/type_alias_regularity.rbs +98 -0
  366. data/sig/type_param.rbs +115 -0
  367. data/sig/typename.rbs +89 -0
  368. data/sig/types.rbs +578 -0
  369. data/sig/unit_test/convertibles.rbs +154 -0
  370. data/sig/unit_test/spy.rbs +22 -0
  371. data/sig/unit_test/type_assertions.rbs +211 -0
  372. data/sig/unit_test/with_aliases.rbs +136 -0
  373. data/sig/use_map.rbs +35 -0
  374. data/sig/util.rbs +9 -0
  375. data/sig/validator.rbs +63 -0
  376. data/sig/variance_calculator.rbs +87 -0
  377. data/sig/vendorer.rbs +51 -0
  378. data/sig/version.rbs +3 -0
  379. data/sig/visitor.rbs +47 -0
  380. data/sig/wasm/deserializer.rbs +66 -0
  381. data/sig/wasm/serialization_schema.rbs +13 -0
  382. data/sig/writer.rbs +127 -0
  383. data/src/ast.c +1628 -0
  384. data/src/lexer.c +3217 -0
  385. data/src/lexer.re +155 -0
  386. data/src/lexstate.c +217 -0
  387. data/src/location.c +31 -0
  388. data/src/parser.c +4255 -0
  389. data/src/serialize.c +958 -0
  390. data/src/string.c +41 -0
  391. data/src/util/rbs_allocator.c +162 -0
  392. data/src/util/rbs_assert.c +19 -0
  393. data/src/util/rbs_buffer.c +54 -0
  394. data/src/util/rbs_constant_pool.c +268 -0
  395. data/src/util/rbs_encoding.c +21308 -0
  396. data/src/util/rbs_unescape.c +167 -0
  397. data/stdlib/abbrev/0/abbrev.rbs +66 -0
  398. data/stdlib/abbrev/0/array.rbs +26 -0
  399. data/stdlib/base64/0/base64.rbs +355 -0
  400. data/stdlib/benchmark/0/benchmark.rbs +452 -0
  401. data/stdlib/bigdecimal/0/big_decimal.rbs +1647 -0
  402. data/stdlib/bigdecimal-math/0/big_math.rbs +280 -0
  403. data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
  404. data/stdlib/cgi/0/core.rbs +911 -0
  405. data/stdlib/cgi/0/manifest.yaml +4 -0
  406. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  407. data/stdlib/coverage/0/coverage.rbs +266 -0
  408. data/stdlib/csv/0/csv.rbs +3776 -0
  409. data/stdlib/csv/0/manifest.yaml +3 -0
  410. data/stdlib/date/0/date.rbs +1598 -0
  411. data/stdlib/date/0/date_time.rbs +617 -0
  412. data/stdlib/date/0/time.rbs +26 -0
  413. data/stdlib/dbm/0/dbm.rbs +421 -0
  414. data/stdlib/delegate/0/delegator.rbs +187 -0
  415. data/stdlib/delegate/0/kernel.rbs +47 -0
  416. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  417. data/stdlib/did_you_mean/0/did_you_mean.rbs +344 -0
  418. data/stdlib/digest/0/digest.rbs +687 -0
  419. data/stdlib/erb/0/erb.rbs +933 -0
  420. data/stdlib/etc/0/etc.rbs +884 -0
  421. data/stdlib/fileutils/0/fileutils.rbs +1753 -0
  422. data/stdlib/find/0/find.rbs +49 -0
  423. data/stdlib/forwardable/0/forwardable.rbs +271 -0
  424. data/stdlib/io-console/0/io-console.rbs +414 -0
  425. data/stdlib/ipaddr/0/ipaddr.rbs +436 -0
  426. data/stdlib/json/0/json.rbs +1963 -0
  427. data/stdlib/kconv/0/kconv.rbs +166 -0
  428. data/stdlib/logger/0/formatter.rbs +45 -0
  429. data/stdlib/logger/0/log_device.rbs +100 -0
  430. data/stdlib/logger/0/logger.rbs +796 -0
  431. data/stdlib/logger/0/manifest.yaml +2 -0
  432. data/stdlib/logger/0/period.rbs +17 -0
  433. data/stdlib/logger/0/severity.rbs +34 -0
  434. data/stdlib/minitest/0/kernel.rbs +42 -0
  435. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
  436. data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
  437. data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
  438. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
  439. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  440. data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
  441. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  442. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  443. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  444. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  445. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  446. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  447. data/stdlib/minitest/0/minitest/mock.rbs +64 -0
  448. data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
  449. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
  450. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  451. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  452. data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
  453. data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
  454. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  455. data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
  456. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  457. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  458. data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
  459. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  460. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  461. data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
  462. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  463. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
  464. data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
  465. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  466. data/stdlib/minitest/0/minitest/test.rbs +69 -0
  467. data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
  468. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  469. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  470. data/stdlib/minitest/0/minitest/unit.rbs +4 -0
  471. data/stdlib/minitest/0/minitest.rbs +115 -0
  472. data/stdlib/monitor/0/monitor.rbs +363 -0
  473. data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
  474. data/stdlib/net-http/0/manifest.yaml +3 -0
  475. data/stdlib/net-http/0/net-http.rbs +5580 -0
  476. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  477. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  478. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  479. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  480. data/stdlib/nkf/0/nkf.rbs +402 -0
  481. data/stdlib/objspace/0/objspace.rbs +470 -0
  482. data/stdlib/observable/0/observable.rbs +217 -0
  483. data/stdlib/open-uri/0/manifest.yaml +4 -0
  484. data/stdlib/open-uri/0/open-uri.rbs +433 -0
  485. data/stdlib/open3/0/open3.rbs +606 -0
  486. data/stdlib/openssl/0/manifest.yaml +3 -0
  487. data/stdlib/openssl/0/openssl.rbs +12231 -0
  488. data/stdlib/optparse/0/optparse.rbs +1734 -0
  489. data/stdlib/pathname/0/pathname.rbs +36 -0
  490. data/stdlib/pp/0/manifest.yaml +2 -0
  491. data/stdlib/pp/0/pp.rbs +301 -0
  492. data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
  493. data/stdlib/pstore/0/pstore.rbs +608 -0
  494. data/stdlib/psych/0/core_ext.rbs +12 -0
  495. data/stdlib/psych/0/dbm.rbs +237 -0
  496. data/stdlib/psych/0/manifest.yaml +3 -0
  497. data/stdlib/psych/0/psych.rbs +455 -0
  498. data/stdlib/psych/0/store.rbs +57 -0
  499. data/stdlib/pty/0/pty.rbs +240 -0
  500. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  501. data/stdlib/rdoc/0/code_object.rbs +52 -0
  502. data/stdlib/rdoc/0/comment.rbs +61 -0
  503. data/stdlib/rdoc/0/context.rbs +153 -0
  504. data/stdlib/rdoc/0/markup.rbs +117 -0
  505. data/stdlib/rdoc/0/options.rbs +76 -0
  506. data/stdlib/rdoc/0/parser.rbs +56 -0
  507. data/stdlib/rdoc/0/rdoc.rbs +393 -0
  508. data/stdlib/rdoc/0/ri.rbs +17 -0
  509. data/stdlib/rdoc/0/store.rbs +48 -0
  510. data/stdlib/rdoc/0/top_level.rbs +97 -0
  511. data/stdlib/resolv/0/manifest.yaml +3 -0
  512. data/stdlib/resolv/0/resolv.rbs +1787 -0
  513. data/stdlib/ripper/0/ripper.rbs +1654 -0
  514. data/stdlib/securerandom/0/manifest.yaml +2 -0
  515. data/stdlib/securerandom/0/securerandom.rbs +49 -0
  516. data/stdlib/shellwords/0/shellwords.rbs +229 -0
  517. data/stdlib/singleton/0/singleton.rbs +134 -0
  518. data/stdlib/socket/0/addrinfo.rbs +666 -0
  519. data/stdlib/socket/0/basic_socket.rbs +590 -0
  520. data/stdlib/socket/0/constants.rbs +2295 -0
  521. data/stdlib/socket/0/ip_socket.rbs +94 -0
  522. data/stdlib/socket/0/socket.rbs +4170 -0
  523. data/stdlib/socket/0/socket_error.rbs +5 -0
  524. data/stdlib/socket/0/tcp_server.rbs +192 -0
  525. data/stdlib/socket/0/tcp_socket.rbs +87 -0
  526. data/stdlib/socket/0/udp_socket.rbs +133 -0
  527. data/stdlib/socket/0/unix_server.rbs +169 -0
  528. data/stdlib/socket/0/unix_socket.rbs +172 -0
  529. data/stdlib/stringio/0/stringio.rbs +1681 -0
  530. data/stdlib/strscan/0/string_scanner.rbs +1648 -0
  531. data/stdlib/tempfile/0/tempfile.rbs +483 -0
  532. data/stdlib/time/0/time.rbs +434 -0
  533. data/stdlib/timeout/0/timeout.rbs +137 -0
  534. data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
  535. data/stdlib/tsort/0/cyclic.rbs +8 -0
  536. data/stdlib/tsort/0/interfaces.rbs +20 -0
  537. data/stdlib/tsort/0/tsort.rbs +410 -0
  538. data/stdlib/uri/0/common.rbs +621 -0
  539. data/stdlib/uri/0/file.rbs +118 -0
  540. data/stdlib/uri/0/ftp.rbs +13 -0
  541. data/stdlib/uri/0/generic.rbs +1116 -0
  542. data/stdlib/uri/0/http.rbs +104 -0
  543. data/stdlib/uri/0/https.rbs +14 -0
  544. data/stdlib/uri/0/ldap.rbs +230 -0
  545. data/stdlib/uri/0/ldaps.rbs +14 -0
  546. data/stdlib/uri/0/mailto.rbs +92 -0
  547. data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
  548. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  549. data/stdlib/uri/0/ws.rbs +13 -0
  550. data/stdlib/uri/0/wss.rbs +9 -0
  551. data/stdlib/yaml/0/manifest.yaml +2 -0
  552. data/stdlib/yaml/0/yaml.rbs +1 -0
  553. data/stdlib/zlib/0/buf_error.rbs +10 -0
  554. data/stdlib/zlib/0/data_error.rbs +10 -0
  555. data/stdlib/zlib/0/deflate.rbs +211 -0
  556. data/stdlib/zlib/0/error.rbs +20 -0
  557. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  558. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  559. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  560. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  561. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  562. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  563. data/stdlib/zlib/0/gzip_writer.rbs +168 -0
  564. data/stdlib/zlib/0/inflate.rbs +180 -0
  565. data/stdlib/zlib/0/mem_error.rbs +10 -0
  566. data/stdlib/zlib/0/need_dict.rbs +13 -0
  567. data/stdlib/zlib/0/stream_end.rbs +11 -0
  568. data/stdlib/zlib/0/stream_error.rbs +11 -0
  569. data/stdlib/zlib/0/version_error.rbs +11 -0
  570. data/stdlib/zlib/0/zlib.rbs +449 -0
  571. data/stdlib/zlib/0/zstream.rbs +201 -0
  572. data/wasm/README.md +59 -0
  573. data/wasm/rbs_wasm.c +411 -0
  574. metadata +660 -0
data/core/kernel.rbs ADDED
@@ -0,0 +1,3172 @@
1
+ # <!-- rdoc-file=object.c -->
2
+ # The Kernel module is included by class Object, so its methods are available in
3
+ # every Ruby object.
4
+ #
5
+ # The Kernel instance methods are documented in class Object while the module
6
+ # methods are documented here. These methods are called without a receiver and
7
+ # thus can be called in functional form:
8
+ #
9
+ # sprintf "%.1f", 1.234 #=> "1.2"
10
+ #
11
+ # ## What's Here
12
+ #
13
+ # Module Kernel provides methods that are useful for:
14
+ #
15
+ # * [Converting](rdoc-ref:Kernel@Converting)
16
+ # * [Querying](rdoc-ref:Kernel@Querying)
17
+ # * [Exiting](rdoc-ref:Kernel@Exiting)
18
+ # * [Exceptions](rdoc-ref:Kernel@Exceptions)
19
+ # * [IO](rdoc-ref:Kernel@IO)
20
+ # * [Procs](rdoc-ref:Kernel@Procs)
21
+ # * [Tracing](rdoc-ref:Kernel@Tracing)
22
+ # * [Subprocesses](rdoc-ref:Kernel@Subprocesses)
23
+ # * [Loading](rdoc-ref:Kernel@Loading)
24
+ # * [Yielding](rdoc-ref:Kernel@Yielding)
25
+ # * [Random Values](rdoc-ref:Kernel@Random+Values)
26
+ # * [Other](rdoc-ref:Kernel@Other)
27
+ #
28
+ # ### Converting
29
+ #
30
+ # * #Array: Returns an Array based on the given argument.
31
+ # * #Complex: Returns a Complex based on the given arguments.
32
+ # * #Float: Returns a Float based on the given arguments.
33
+ # * #Hash: Returns a Hash based on the given argument.
34
+ # * #Integer: Returns an Integer based on the given arguments.
35
+ # * #Rational: Returns a Rational based on the given arguments.
36
+ # * #String: Returns a String based on the given argument.
37
+ #
38
+ # ### Querying
39
+ #
40
+ # * #__callee__: Returns the called name of the current method as a symbol.
41
+ # * #__dir__: Returns the path to the directory from which the current method
42
+ # is called.
43
+ # * #__method__: Returns the name of the current method as a symbol.
44
+ # * #autoload?: Returns the file to be loaded when the given module is
45
+ # referenced.
46
+ # * #binding: Returns a Binding for the context at the point of call.
47
+ # * #block_given?: Returns `true` if a block was passed to the calling method.
48
+ # * #caller: Returns the current execution stack as an array of strings.
49
+ # * #caller_locations: Returns the current execution stack as an array of
50
+ # Thread::Backtrace::Location objects.
51
+ # * #class: Returns the class of `self`.
52
+ # * #frozen?: Returns whether `self` is frozen.
53
+ # * #global_variables: Returns an array of global variables as symbols.
54
+ # * #local_variables: Returns an array of local variables as symbols.
55
+ # * #test: Performs specified tests on the given single file or pair of files.
56
+ #
57
+ # ### Exiting
58
+ #
59
+ # * #abort: Exits the current process after printing the given arguments.
60
+ # * #at_exit: Executes the given block when the process exits.
61
+ # * #exit: Exits the current process after calling any registered `at_exit`
62
+ # handlers.
63
+ # * #exit!: Exits the current process without calling any registered `at_exit`
64
+ # handlers.
65
+ #
66
+ # ### Exceptions
67
+ #
68
+ # * #catch: Executes the given block, possibly catching a thrown object.
69
+ # * #raise (aliased as #fail): Raises an exception based on the given
70
+ # arguments.
71
+ # * #throw: Returns from the active catch block waiting for the given tag.
72
+ #
73
+ # ### IO
74
+ #
75
+ # * ::pp: Prints the given objects in pretty form.
76
+ # * #gets: Returns and assigns to <code>$_</code> the next line from the
77
+ # current input.
78
+ # * #open: Creates an IO object connected to the given stream, file, or
79
+ # subprocess.
80
+ # * #p: Prints the given objects' inspect output to the standard output.
81
+ # * #print: Prints the given objects to standard output without a newline.
82
+ # * #printf: Prints the string resulting from applying the given format string
83
+ # to any additional arguments.
84
+ # * #putc: Equivalent to <code>$stdout.putc(object)</code> for the given
85
+ # object.
86
+ # * #puts: Equivalent to <code>$stdout.puts(*objects)</code> for the given
87
+ # objects.
88
+ # * #readline: Similar to #gets, but raises an exception at the end of file.
89
+ # * #readlines: Returns an array of the remaining lines from the current
90
+ # input.
91
+ # * #select: Same as IO.select.
92
+ #
93
+ # ### Procs
94
+ #
95
+ # * #lambda: Returns a lambda proc for the given block.
96
+ # * #proc: Returns a new Proc; equivalent to Proc.new.
97
+ #
98
+ # ### Tracing
99
+ #
100
+ # * #set_trace_func: Sets the given proc as the handler for tracing, or
101
+ # disables tracing if given `nil`.
102
+ # * #trace_var: Starts tracing assignments to the given global variable.
103
+ # * #untrace_var: Disables tracing of assignments to the given global
104
+ # variable.
105
+ #
106
+ # ### Subprocesses
107
+ #
108
+ # * [`command`](rdoc-ref:Kernel#`): Returns the standard output of running
109
+ # `command` in a subshell.
110
+ # * #exec: Replaces current process with a new process.
111
+ # * #fork: Forks the current process into two processes.
112
+ # * #spawn: Executes the given command and returns its pid without waiting for
113
+ # completion.
114
+ # * #system: Executes the given command in a subshell.
115
+ #
116
+ # ### Loading
117
+ #
118
+ # * #autoload: Registers the given file to be loaded when the given constant
119
+ # is first referenced.
120
+ # * #load: Loads the given Ruby file.
121
+ # * #require: Loads the given Ruby file unless it has already been loaded.
122
+ # * #require_relative: Loads the Ruby file path relative to the calling file,
123
+ # unless it has already been loaded.
124
+ #
125
+ # ### Yielding
126
+ #
127
+ # * #tap: Yields `self` to the given block; returns `self`.
128
+ # * #then (aliased as #yield_self): Yields `self` to the block and returns the
129
+ # result of the block.
130
+ #
131
+ # ### Random Values
132
+ #
133
+ # * #rand: Returns a pseudo-random floating point number strictly between 0.0
134
+ # and 1.0.
135
+ # * #srand: Seeds the pseudo-random number generator with the given number.
136
+ #
137
+ # ### Other
138
+ #
139
+ # * #eval: Evaluates the given string as Ruby code.
140
+ # * #loop: Repeatedly executes the given block.
141
+ # * #sleep: Suspends the current thread for the given number of seconds.
142
+ # * #sprintf (aliased as #format): Returns the string resulting from applying
143
+ # the given format string to any additional arguments.
144
+ # * #syscall: Runs an operating system call.
145
+ # * #trap: Specifies the handling of system signals.
146
+ # * #warn: Issue a warning based on the given messages and options.
147
+ #
148
+ %a{annotate:rdoc:source:from=object.c}
149
+ module Kernel : BasicObject
150
+ # <!--
151
+ # rdoc-file=vm_backtrace.c
152
+ # - caller(start=1, length=nil) -> array or nil
153
+ # - caller(range) -> array or nil
154
+ # -->
155
+ # Returns the current execution stack---an array containing strings in the form
156
+ # <code>file:line</code> or <code>file:line: in `method'</code>.
157
+ #
158
+ # The optional *start* parameter determines the number of initial stack entries
159
+ # to omit from the top of the stack.
160
+ #
161
+ # A second optional `length` parameter can be used to limit how many entries are
162
+ # returned from the stack.
163
+ #
164
+ # Returns `nil` if *start* is greater than the size of current execution stack.
165
+ #
166
+ # Optionally you can pass a range, which will return an array containing the
167
+ # entries within the specified range.
168
+ #
169
+ # def a(skip)
170
+ # caller(skip)
171
+ # end
172
+ # def b(skip)
173
+ # a(skip)
174
+ # end
175
+ # def c(skip)
176
+ # b(skip)
177
+ # end
178
+ # c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `<main>'"]
179
+ # c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `<main>'"]
180
+ # c(2) #=> ["prog:8:in `c'", "prog:12:in `<main>'"]
181
+ # c(3) #=> ["prog:13:in `<main>'"]
182
+ # c(4) #=> []
183
+ # c(5) #=> nil
184
+ #
185
+ def self?.caller: () -> Array[String]
186
+ | (int start, ?int? length) -> Array[String]?
187
+ | (range[int] range) -> Array[String]?
188
+
189
+ # <!--
190
+ # rdoc-file=vm_backtrace.c
191
+ # - caller_locations(start=1, length=nil) -> array or nil
192
+ # - caller_locations(range) -> array or nil
193
+ # -->
194
+ # Returns the current execution stack---an array containing backtrace location
195
+ # objects.
196
+ #
197
+ # See Thread::Backtrace::Location for more information.
198
+ #
199
+ # The optional *start* parameter determines the number of initial stack entries
200
+ # to omit from the top of the stack.
201
+ #
202
+ # A second optional `length` parameter can be used to limit how many entries are
203
+ # returned from the stack.
204
+ #
205
+ # Returns `nil` if *start* is greater than the size of current execution stack.
206
+ #
207
+ # Optionally you can pass a range, which will return an array containing the
208
+ # entries within the specified range.
209
+ #
210
+ def self?.caller_locations: () -> Array[Thread::Backtrace::Location]
211
+ | (int start, ?int? length) -> Array[Thread::Backtrace::Location]?
212
+ | (range[int] range) -> Array[Thread::Backtrace::Location]?
213
+
214
+ # <!--
215
+ # rdoc-file=vm_eval.c
216
+ # - catch([tag]) {|tag| block } -> obj
217
+ # -->
218
+ # `catch` executes its block. If `throw` is not called, the block executes
219
+ # normally, and `catch` returns the value of the last expression evaluated.
220
+ #
221
+ # catch(1) { 123 } # => 123
222
+ #
223
+ # If <code>throw(tag2, val)</code> is called, Ruby searches up its stack for a
224
+ # `catch` block whose `tag` has the same `object_id` as *tag2*. When found, the
225
+ # block stops executing and returns *val* (or `nil` if no second argument was
226
+ # given to `throw`).
227
+ #
228
+ # catch(1) { throw(1, 456) } # => 456
229
+ # catch(1) { throw(1) } # => nil
230
+ #
231
+ # When `tag` is passed as the first argument, `catch` yields it as the parameter
232
+ # of the block.
233
+ #
234
+ # catch(1) {|x| x + 2 } # => 3
235
+ #
236
+ # When no `tag` is given, `catch` yields a new unique object (as from
237
+ # <code>Object.new</code>) as the block parameter. This object can then be used
238
+ # as the argument to `throw`, and will match the correct `catch` block.
239
+ #
240
+ # catch do |obj_A|
241
+ # catch do |obj_B|
242
+ # throw(obj_B, 123)
243
+ # puts "This puts is not reached"
244
+ # end
245
+ #
246
+ # puts "This puts is displayed"
247
+ # 456
248
+ # end
249
+ #
250
+ # # => 456
251
+ #
252
+ # catch do |obj_A|
253
+ # catch do |obj_B|
254
+ # throw(obj_A, 123)
255
+ # puts "This puts is still not reached"
256
+ # end
257
+ #
258
+ # puts "Now this puts is also not reached"
259
+ # 456
260
+ # end
261
+ #
262
+ # # => 123
263
+ #
264
+ def self?.catch: [T] (T tag) { (T tag) -> untyped } -> untyped
265
+ | () { (Object tag) -> untyped } -> untyped
266
+
267
+ # <!--
268
+ # rdoc-file=kernel.rb
269
+ # - obj.class -> class
270
+ # -->
271
+ # Returns the class of *obj*. This method must always be called with an explicit
272
+ # receiver, as #class is also a reserved word in Ruby.
273
+ #
274
+ # 1.class #=> Integer
275
+ # self.class #=> Object
276
+ #
277
+ def class: () -> Class
278
+
279
+ # <!--
280
+ # rdoc-file=vm_eval.c
281
+ # - eval(string [, binding [, filename [,lineno]]]) -> obj
282
+ # -->
283
+ # Evaluates the Ruby expression(s) in *string*. If *binding* is given, which
284
+ # must be a Binding object, the evaluation is performed in its context. If the
285
+ # optional *filename* and *lineno* parameters are present, they will be used
286
+ # when reporting syntax errors.
287
+ #
288
+ # def get_binding(str)
289
+ # return binding
290
+ # end
291
+ # str = "hello"
292
+ # eval "str + ' Fred'" #=> "hello Fred"
293
+ # eval "str + ' Fred'", get_binding("bye") #=> "bye Fred"
294
+ #
295
+ def self?.eval: (string src, ?Binding? scope, ?string filename, ?int lineno) -> untyped
296
+
297
+ # <!--
298
+ # rdoc-file=vm_eval.c
299
+ # - block_given? -> true or false
300
+ # -->
301
+ # Returns `true` if `yield` would execute a block in the current context. The
302
+ # <code>iterator?</code> form is mildly deprecated.
303
+ #
304
+ # def try
305
+ # if block_given?
306
+ # yield
307
+ # else
308
+ # "no block"
309
+ # end
310
+ # end
311
+ # try #=> "no block"
312
+ # try { "hello" } #=> "hello"
313
+ # try do "hello" end #=> "hello"
314
+ #
315
+ def self?.block_given?: () -> bool
316
+
317
+ alias self.iterator? self.block_given?
318
+
319
+ # <!--
320
+ # rdoc-file=vm_eval.c
321
+ # - iterator? -> true or false
322
+ # -->
323
+ # Deprecated. Use block_given? instead.
324
+ #
325
+ alias iterator? block_given?
326
+
327
+ # <!--
328
+ # rdoc-file=vm_eval.c
329
+ # - local_variables -> array
330
+ # -->
331
+ # Returns the names of the current local variables.
332
+ #
333
+ # fred = 1
334
+ # for i in 1..10
335
+ # # ...
336
+ # end
337
+ # local_variables #=> [:fred, :i]
338
+ #
339
+ def self?.local_variables: () -> Array[Symbol]
340
+
341
+ # <!--
342
+ # rdoc-file=random.c
343
+ # - srand(number = Random.new_seed) -> old_seed
344
+ # -->
345
+ # Seeds the system pseudo-random number generator, with `number`. The previous
346
+ # seed value is returned.
347
+ #
348
+ # If `number` is omitted, seeds the generator using a source of entropy provided
349
+ # by the operating system, if available (/dev/urandom on Unix systems or the RSA
350
+ # cryptographic provider on Windows), which is then combined with the time, the
351
+ # process id, and a sequence number.
352
+ #
353
+ # srand may be used to ensure repeatable sequences of pseudo-random numbers
354
+ # between different runs of the program. By setting the seed to a known value,
355
+ # programs can be made deterministic during testing.
356
+ #
357
+ # srand 1234 # => 268519324636777531569100071560086917274
358
+ # [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319]
359
+ # [ rand(10), rand(1000) ] # => [4, 664]
360
+ # srand 1234 # => 1234
361
+ # [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319]
362
+ #
363
+ def self?.srand: (?int number) -> Integer
364
+
365
+ # <!--
366
+ # rdoc-file=process.c
367
+ # - Process.fork { ... } -> integer or nil
368
+ # - Process.fork -> integer or nil
369
+ # -->
370
+ # Creates a child process.
371
+ #
372
+ # With a block given, runs the block in the child process; on block exit, the
373
+ # child terminates with a status of zero:
374
+ #
375
+ # puts "Before the fork: #{Process.pid}"
376
+ # fork do
377
+ # puts "In the child process: #{Process.pid}"
378
+ # end # => 382141
379
+ # puts "After the fork: #{Process.pid}"
380
+ #
381
+ # Output:
382
+ #
383
+ # Before the fork: 420496
384
+ # After the fork: 420496
385
+ # In the child process: 420520
386
+ #
387
+ # With no block given, the `fork` call returns twice:
388
+ #
389
+ # * Once in the parent process, returning the pid of the child process.
390
+ # * Once in the child process, returning `nil`.
391
+ #
392
+ # Example:
393
+ #
394
+ # puts "This is the first line before the fork (pid #{Process.pid})"
395
+ # puts fork
396
+ # puts "This is the second line after the fork (pid #{Process.pid})"
397
+ #
398
+ # Output:
399
+ #
400
+ # This is the first line before the fork (pid 420199)
401
+ # 420223
402
+ # This is the second line after the fork (pid 420199)
403
+ #
404
+ # This is the second line after the fork (pid 420223)
405
+ #
406
+ # In either case, the child process may exit using Kernel.exit! to avoid the
407
+ # call to Kernel#at_exit.
408
+ #
409
+ # To avoid zombie processes, the parent process should call either:
410
+ #
411
+ # * Process.wait, to collect the termination statuses of its children.
412
+ # * Process.detach, to register disinterest in their status.
413
+ #
414
+ # The thread calling `fork` is the only thread in the created child process;
415
+ # `fork` doesn't copy other threads.
416
+ #
417
+ # Note that method `fork` is available on some platforms, but not on others:
418
+ #
419
+ # Process.respond_to?(:fork) # => true # Would be false on some.
420
+ #
421
+ # If not, you may use ::spawn instead of `fork`.
422
+ #
423
+ def self?.fork: () -> Integer?
424
+ | () { () -> void } -> Integer
425
+
426
+ # <!--
427
+ # rdoc-file=object.c
428
+ # - Array(object) -> object or new_array
429
+ # -->
430
+ # Returns an array converted from `object`.
431
+ #
432
+ # Tries to convert `object` to an array using `to_ary` first and `to_a` second:
433
+ #
434
+ # Array([0, 1, 2]) # => [0, 1, 2]
435
+ # Array({foo: 0, bar: 1}) # => [[:foo, 0], [:bar, 1]]
436
+ # Array(0..4) # => [0, 1, 2, 3, 4]
437
+ #
438
+ # Returns `object` in an array, <code>[object]</code>, if `object` cannot be
439
+ # converted:
440
+ #
441
+ # Array(:foo) # => [:foo]
442
+ #
443
+ def self?.Array: (nil) -> []
444
+ | [T] (array[T] | _ToA[T] array_like) -> Array[T]
445
+ | [T] (T ele) -> [T]
446
+
447
+ # <!--
448
+ # rdoc-file=complex.c
449
+ # - Complex(real, imag = 0, exception: true) -> complex or nil
450
+ # - Complex(s, exception: true) -> complex or nil
451
+ # -->
452
+ # Returns a new Complex object if the arguments are valid; otherwise raises an
453
+ # exception if `exception` is `true`; otherwise returns `nil`.
454
+ #
455
+ # With Numeric arguments `real` and `imag`, returns <code>Complex.rect(real,
456
+ # imag)</code> if the arguments are valid.
457
+ #
458
+ # With string argument `s`, returns a new Complex object if the argument is
459
+ # valid; the string may have:
460
+ #
461
+ # * One or two numeric substrings, each of which specifies a Complex, Float,
462
+ # Integer, Numeric, or Rational value, specifying [rectangular
463
+ # coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
464
+ #
465
+ # * Sign-separated real and imaginary numeric substrings (with trailing
466
+ # character <code>'i'</code>):
467
+ #
468
+ # Complex('1+2i') # => (1+2i)
469
+ # Complex('+1+2i') # => (1+2i)
470
+ # Complex('+1-2i') # => (1-2i)
471
+ # Complex('-1+2i') # => (-1+2i)
472
+ # Complex('-1-2i') # => (-1-2i)
473
+ #
474
+ # * Real-only numeric string (without trailing character
475
+ # <code>'i'</code>):
476
+ #
477
+ # Complex('1') # => (1+0i)
478
+ # Complex('+1') # => (1+0i)
479
+ # Complex('-1') # => (-1+0i)
480
+ #
481
+ # * Imaginary-only numeric string (with trailing character
482
+ # <code>'i'</code>):
483
+ #
484
+ # Complex('1i') # => (0+1i)
485
+ # Complex('+1i') # => (0+1i)
486
+ # Complex('-1i') # => (0-1i)
487
+ #
488
+ # * At-sign separated real and imaginary rational substrings, each of which
489
+ # specifies a Rational value, specifying [polar
490
+ # coordinates](rdoc-ref:Complex@Polar+Coordinates):
491
+ #
492
+ # Complex('1/2@3/4') # => (0.36584443443691045+0.34081938001166706i)
493
+ # Complex('+1/2@+3/4') # => (0.36584443443691045+0.34081938001166706i)
494
+ # Complex('+1/2@-3/4') # => (0.36584443443691045-0.34081938001166706i)
495
+ # Complex('-1/2@+3/4') # => (-0.36584443443691045-0.34081938001166706i)
496
+ # Complex('-1/2@-3/4') # => (-0.36584443443691045+0.34081938001166706i)
497
+ #
498
+ def self?.Complex: (_ToC complex_like, ?exception: true) -> Complex
499
+ | (_ToC complex_like, exception: bool) -> Complex?
500
+ | (Numeric | String real, ?Numeric | String imag, ?exception: true) -> Complex
501
+ | (Numeric | String real, ?Numeric | String imag, exception: bool) -> Complex?
502
+ | (untyped, ?untyped, ?exception: bool) -> Complex?
503
+
504
+ # <!--
505
+ # rdoc-file=kernel.rb
506
+ # - Float(arg, exception: true) -> float or nil
507
+ # -->
508
+ # Returns *arg* converted to a float. Numeric types are converted directly, and
509
+ # with exception to String and `nil`, the rest are converted using
510
+ # *arg*<code>.to_f</code>. Converting a String with invalid characters will
511
+ # result in an ArgumentError. Converting `nil` generates a TypeError. Exceptions
512
+ # can be suppressed by passing <code>exception: false</code>.
513
+ #
514
+ # Float(1) #=> 1.0
515
+ # Float("123.456") #=> 123.456
516
+ # Float("123.0_badstring") #=> ArgumentError: invalid value for Float(): "123.0_badstring"
517
+ # Float(nil) #=> TypeError: can't convert nil into Float
518
+ # Float("123.0_badstring", exception: false) #=> nil
519
+ #
520
+ def self?.Float: (_ToF float_like, ?exception: true) -> Float
521
+ | (_ToF float_like, exception: bool) -> Float?
522
+ | (untyped, ?exception: bool) -> Float?
523
+
524
+ # <!--
525
+ # rdoc-file=object.c
526
+ # - Hash(object) -> object or new_hash
527
+ # -->
528
+ # Returns a hash converted from `object`.
529
+ #
530
+ # * If `object` is:
531
+ #
532
+ # * A hash, returns `object`.
533
+ # * An empty array or `nil`, returns an empty hash.
534
+ #
535
+ # * Otherwise, if <code>object.to_hash</code> returns a hash, returns that
536
+ # hash.
537
+ # * Otherwise, returns TypeError.
538
+ #
539
+ # Examples:
540
+ #
541
+ # Hash({foo: 0, bar: 1}) # => {:foo=>0, :bar=>1}
542
+ # Hash(nil) # => {}
543
+ # Hash([]) # => {}
544
+ #
545
+ def self?.Hash: [K, V] (nil | [] _empty) -> Hash[K, V]
546
+ | [K, V] (hash[K, V] hash_like) -> Hash[K, V]
547
+
548
+ # <!--
549
+ # rdoc-file=kernel.rb
550
+ # - Integer(object, base = 0, exception: true) -> integer or nil
551
+ # -->
552
+ # Returns an integer converted from `object`.
553
+ #
554
+ # Tries to convert `object` to an integer using `to_int` first and `to_i`
555
+ # second; see below for exceptions.
556
+ #
557
+ # With a non-zero `base`, `object` must be a string or convertible to a string.
558
+ #
559
+ # #### Numeric objects
560
+ #
561
+ # With an integer argument `object` given, returns `object`:
562
+ #
563
+ # Integer(1) # => 1
564
+ # Integer(-1) # => -1
565
+ #
566
+ # With a floating-point argument `object` given, returns `object` truncated to
567
+ # an integer:
568
+ #
569
+ # Integer(1.9) # => 1 # Rounds toward zero.
570
+ # Integer(-1.9) # => -1 # Rounds toward zero.
571
+ #
572
+ # #### String objects
573
+ #
574
+ # With a string argument `object` and zero `base` given, returns `object`
575
+ # converted to an integer in base 10:
576
+ #
577
+ # Integer('100') # => 100
578
+ # Integer('-100') # => -100
579
+ #
580
+ # With `base` zero, string `object` may contain leading characters to specify
581
+ # the actual base (radix indicator):
582
+ #
583
+ # Integer('0100') # => 64 # Leading '0' specifies base 8.
584
+ # Integer('0b100') # => 4 # Leading '0b' specifies base 2.
585
+ # Integer('0x100') # => 256 # Leading '0x' specifies base 16.
586
+ #
587
+ # With a positive `base` (in range 2..36) given, returns `object` converted to
588
+ # an integer in the given base:
589
+ #
590
+ # Integer('100', 2) # => 4
591
+ # Integer('100', 8) # => 64
592
+ # Integer('-100', 16) # => -256
593
+ #
594
+ # With a negative `base` (in range -36..-2) given, returns `object` converted to
595
+ # the radix indicator if it exists or `base`:
596
+ #
597
+ # Integer('0x100', -2) # => 256
598
+ # Integer('100', -2) # => 4
599
+ # Integer('0b100', -8) # => 4
600
+ # Integer('100', -8) # => 64
601
+ # Integer('0o100', -10) # => 64
602
+ # Integer('100', -10) # => 100
603
+ #
604
+ # `base` -1 is equivalent to the -10 case.
605
+ #
606
+ # When converting strings, surrounding whitespace and embedded underscores are
607
+ # allowed and ignored:
608
+ #
609
+ # Integer(' 100 ') # => 100
610
+ # Integer('-1_0_0', 16) # => -256
611
+ #
612
+ # #### Other classes
613
+ #
614
+ # Examples with `object` of various other classes:
615
+ #
616
+ # Integer(Rational(9, 10)) # => 0 # Rounds toward zero.
617
+ # Integer(Complex(2, 0)) # => 2 # Imaginary part must be zero.
618
+ # Integer(Time.now) # => 1650974042
619
+ #
620
+ # #### Keywords
621
+ #
622
+ # With the optional keyword argument `exception` given as `true` (the default):
623
+ #
624
+ # * Raises TypeError if `object` does not respond to `to_int` or `to_i`.
625
+ # * Raises TypeError if `object` is `nil`.
626
+ # * Raises ArgumentError if `object` is an invalid string.
627
+ #
628
+ # With `exception` given as `false`, an exception of any kind is suppressed and
629
+ # `nil` is returned.
630
+ #
631
+ def self?.Integer: (int | _ToI int_like, ?exception: true) -> Integer
632
+ | (int | _ToI int_like, exception: bool) -> Integer?
633
+ | (string str, int base, ?exception: true) -> Integer
634
+ | (string str, int base, exception: bool) -> Integer?
635
+ | (untyped, ?untyped, ?exception: bool) -> Integer?
636
+
637
+ # <!--
638
+ # rdoc-file=rational.c
639
+ # - Rational(x, y, exception: true) -> rational or nil
640
+ # - Rational(arg, exception: true) -> rational or nil
641
+ # -->
642
+ # Returns <code>x/y</code> or `arg` as a Rational.
643
+ #
644
+ # Rational(2, 3) #=> (2/3)
645
+ # Rational(5) #=> (5/1)
646
+ # Rational(0.5) #=> (1/2)
647
+ # Rational(0.3) #=> (5404319552844595/18014398509481984)
648
+ #
649
+ # Rational("2/3") #=> (2/3)
650
+ # Rational("0.3") #=> (3/10)
651
+ #
652
+ # Rational("10 cents") #=> ArgumentError
653
+ # Rational(nil) #=> TypeError
654
+ # Rational(1, nil) #=> TypeError
655
+ #
656
+ # Rational("10 cents", exception: false) #=> nil
657
+ #
658
+ # Syntax of the string form:
659
+ #
660
+ # string form = extra spaces , rational , extra spaces ;
661
+ # rational = [ sign ] , unsigned rational ;
662
+ # unsigned rational = numerator | numerator , "/" , denominator ;
663
+ # numerator = integer part | fractional part | integer part , fractional part ;
664
+ # denominator = digits ;
665
+ # integer part = digits ;
666
+ # fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
667
+ # sign = "-" | "+" ;
668
+ # digits = digit , { digit | "_" , digit } ;
669
+ # digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
670
+ # extra spaces = ? \s* ? ;
671
+ #
672
+ # See also String#to_r.
673
+ #
674
+ def self?.Rational: (int | _ToR rational_like, ?exception: true) -> Rational
675
+ | (int | _ToR rational_like, exception: bool) -> Rational?
676
+ | (int | _ToR numer, ?int | _ToR denom, ?exception: true) -> Rational
677
+ | (int | _ToR numer, ?int | _ToR denom, exception: bool) -> Rational?
678
+ | [T] (Numeric & _RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T
679
+ | [T < Numeric] (T value, 1, ?exception: bool) -> T
680
+ | (untyped, ?untyped, ?exception: bool) -> Rational?
681
+
682
+ interface _RationalDiv[T]
683
+ def /: (Numeric) -> T
684
+ end
685
+
686
+ # <!--
687
+ # rdoc-file=object.c
688
+ # - String(object) -> object or new_string
689
+ # -->
690
+ # Returns a string converted from `object`.
691
+ #
692
+ # Tries to convert `object` to a string using `to_str` first and `to_s` second:
693
+ #
694
+ # String([0, 1, 2]) # => "[0, 1, 2]"
695
+ # String(0..5) # => "0..5"
696
+ # String({foo: 0, bar: 1}) # => "{foo: 0, bar: 1}"
697
+ #
698
+ # Raises `TypeError` if `object` cannot be converted to a string.
699
+ #
700
+ def self?.String: (string | _ToS string_like) -> String
701
+
702
+ # <!--
703
+ # rdoc-file=eval.c
704
+ # - __callee__ -> symbol
705
+ # -->
706
+ # Returns the called name of the current method as a Symbol. If called outside
707
+ # of a method, it returns `nil`.
708
+ #
709
+ def self?.__callee__: () -> Symbol?
710
+
711
+ # <!--
712
+ # rdoc-file=eval.c
713
+ # - __dir__ -> string
714
+ # -->
715
+ # Returns the canonicalized absolute path of the directory of the file from
716
+ # which this method is called. It means symlinks in the path is resolved. If
717
+ # `__FILE__` is `nil`, it returns `nil`. The return value equals to
718
+ # <code>File.dirname(File.realpath(__FILE__))</code>.
719
+ #
720
+ def self?.__dir__: () -> String?
721
+
722
+ # <!--
723
+ # rdoc-file=eval.c
724
+ # - __method__ -> symbol
725
+ # -->
726
+ # Returns the name at the definition of the current method as a Symbol. If
727
+ # called outside of a method, it returns `nil`.
728
+ #
729
+ def self?.__method__: () -> Symbol?
730
+
731
+ # <!--
732
+ # rdoc-file=io.c
733
+ # - `command` -> string
734
+ # -->
735
+ # Returns the <code>$stdout</code> output from running `command` in a subshell;
736
+ # sets global variable <code>$?</code> to the process status.
737
+ #
738
+ # This method has potential security vulnerabilities if called with untrusted
739
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
740
+ #
741
+ # Examples:
742
+ #
743
+ # $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n"
744
+ # $ `echo oops && exit 99` # => "oops\n"
745
+ # $ $? # => #<Process::Status: pid 17088 exit 99>
746
+ # $ $?.exitstatus # => 99
747
+ #
748
+ # The built-in syntax <code>%x{...}</code> uses this method.
749
+ #
750
+ def self?.`: (String arg0) -> String
751
+
752
+ # <!--
753
+ # rdoc-file=process.c
754
+ # - abort
755
+ # - Process.abort(msg = nil)
756
+ # -->
757
+ # Terminates execution immediately, effectively by calling
758
+ # <code>Kernel.exit(false)</code>.
759
+ #
760
+ # If string argument `msg` is given, it is written to STDERR prior to
761
+ # termination; otherwise, if an exception was raised, prints its message and
762
+ # backtrace.
763
+ #
764
+ def self?.abort: (?string msg) -> bot
765
+
766
+ # <!--
767
+ # rdoc-file=eval_jump.c
768
+ # - at_exit { block } -> proc
769
+ # -->
770
+ # Converts *block* to a `Proc` object (and therefore binds it at the point of
771
+ # call) and registers it for execution when the program exits. If multiple
772
+ # handlers are registered, they are executed in reverse order of registration.
773
+ #
774
+ # def do_at_exit(str1)
775
+ # at_exit { print str1 }
776
+ # end
777
+ # at_exit { puts "cruel world" }
778
+ # do_at_exit("goodbye ")
779
+ # exit
780
+ #
781
+ # <em>produces:</em>
782
+ #
783
+ # goodbye cruel world
784
+ #
785
+ def self?.at_exit: () { () -> void } -> Proc
786
+
787
+ # <!--
788
+ # rdoc-file=load.c
789
+ # - autoload(const, filename) -> nil
790
+ # -->
791
+ # Registers *filename* to be loaded (using Kernel::require) the first time that
792
+ # *const* (which may be a String or a symbol) is accessed.
793
+ #
794
+ # autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
795
+ #
796
+ # If *const* is defined as autoload, the file name to be loaded is replaced with
797
+ # *filename*. If *const* is defined but not as autoload, does nothing.
798
+ #
799
+ # Files that are currently being loaded must not be registered for autoload.
800
+ #
801
+ def self?.autoload: (interned const, path filename) -> nil
802
+
803
+ # <!--
804
+ # rdoc-file=load.c
805
+ # - autoload?(name, inherit=true) -> String or nil
806
+ # -->
807
+ # Returns *filename* to be loaded if *name* is registered as `autoload` in the
808
+ # current namespace or one of its ancestors.
809
+ #
810
+ # autoload(:B, "b")
811
+ # autoload?(:B) #=> "b"
812
+ #
813
+ # module C
814
+ # autoload(:D, "d")
815
+ # autoload?(:D) #=> "d"
816
+ # autoload?(:B) #=> nil
817
+ # end
818
+ #
819
+ # class E
820
+ # autoload(:F, "f")
821
+ # autoload?(:F) #=> "f"
822
+ # autoload?(:B) #=> "b"
823
+ # end
824
+ #
825
+ def self?.autoload?: (interned name, ?boolish inherit) -> String?
826
+
827
+ # <!--
828
+ # rdoc-file=proc.c
829
+ # - binding -> a_binding
830
+ # -->
831
+ # Returns a Binding object, describing the variable and method bindings at the
832
+ # point of call. This object can be used when calling Binding#eval to execute
833
+ # the evaluated command in this environment, or extracting its local variables.
834
+ #
835
+ # class User
836
+ # def initialize(name, position)
837
+ # @name = name
838
+ # @position = position
839
+ # end
840
+ #
841
+ # def get_binding
842
+ # binding
843
+ # end
844
+ # end
845
+ #
846
+ # user = User.new('Joan', 'manager')
847
+ # template = '{name: @name, position: @position}'
848
+ #
849
+ # # evaluate template in context of the object
850
+ # eval(template, user.get_binding)
851
+ # #=> {:name=>"Joan", :position=>"manager"}
852
+ #
853
+ # Binding#local_variable_get can be used to access the variables whose names are
854
+ # reserved Ruby keywords:
855
+ #
856
+ # # This is valid parameter declaration, but `if` parameter can't
857
+ # # be accessed by name, because it is a reserved word.
858
+ # def validate(field, validation, if: nil)
859
+ # condition = binding.local_variable_get('if')
860
+ # return unless condition
861
+ #
862
+ # # ...Some implementation ...
863
+ # end
864
+ #
865
+ # validate(:name, :empty?, if: false) # skips validation
866
+ # validate(:name, :empty?, if: true) # performs validation
867
+ #
868
+ def self?.binding: () -> Binding
869
+
870
+ # <!--
871
+ # rdoc-file=process.c
872
+ # - exit(status = true)
873
+ # - Process.exit(status = true)
874
+ # -->
875
+ # Initiates termination of the Ruby script by raising SystemExit; the exception
876
+ # may be caught. Returns exit status `status` to the underlying operating
877
+ # system.
878
+ #
879
+ # Values `true` and `false` for argument `status` indicate, respectively,
880
+ # success and failure; The meanings of integer values are system-dependent.
881
+ #
882
+ # Example:
883
+ #
884
+ # begin
885
+ # exit
886
+ # puts 'Never get here.'
887
+ # rescue SystemExit
888
+ # puts 'Rescued a SystemExit exception.'
889
+ # end
890
+ # puts 'After begin block.'
891
+ #
892
+ # Output:
893
+ #
894
+ # Rescued a SystemExit exception.
895
+ # After begin block.
896
+ #
897
+ # Just prior to final termination, Ruby executes any at-exit procedures (see
898
+ # Kernel::at_exit) and any object finalizers (see
899
+ # ObjectSpace::define_finalizer).
900
+ #
901
+ # Example:
902
+ #
903
+ # at_exit { puts 'In at_exit function.' }
904
+ # ObjectSpace.define_finalizer('string', proc { puts 'In finalizer.' })
905
+ # exit
906
+ #
907
+ # Output:
908
+ #
909
+ # In at_exit function.
910
+ # In finalizer.
911
+ #
912
+ def self?.exit: (?int | bool status) -> bot
913
+
914
+ # <!--
915
+ # rdoc-file=process.c
916
+ # - exit!(status = false)
917
+ # - Process.exit!(status = false)
918
+ # -->
919
+ # Exits the process immediately; no exit handlers are called. Returns exit
920
+ # status `status` to the underlying operating system.
921
+ #
922
+ # Process.exit!(true)
923
+ #
924
+ # Values `true` and `false` for argument `status` indicate, respectively,
925
+ # success and failure; The meanings of integer values are system-dependent.
926
+ #
927
+ def self?.exit!: (?int | bool status) -> bot
928
+
929
+ # <!-- rdoc-file=eval.c -->
930
+ # Raises an exception; see [Exceptions](rdoc-ref:exceptions.md).
931
+ #
932
+ # Argument `exception` sets the class of the new exception; it should be class
933
+ # Exception or one of its subclasses (most commonly, RuntimeError or
934
+ # StandardError), or an instance of one of those classes:
935
+ #
936
+ # begin
937
+ # raise(StandardError)
938
+ # rescue => x
939
+ # p x.class
940
+ # end
941
+ # # => StandardError
942
+ #
943
+ # Argument `message` sets the stored message in the new exception, which may be
944
+ # retrieved by method Exception#message; the message must be a
945
+ # [string-convertible
946
+ # object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or
947
+ # `nil`:
948
+ #
949
+ # begin
950
+ # raise(StandardError, 'Boom')
951
+ # rescue => x
952
+ # p x.message
953
+ # end
954
+ # # => "Boom"
955
+ #
956
+ # If argument `message` is not given, the message is the exception class name.
957
+ #
958
+ # See [Messages](rdoc-ref:exceptions.md@Messages).
959
+ #
960
+ # Argument `backtrace` might be used to modify the backtrace of the new
961
+ # exception, as reported by Exception#backtrace and
962
+ # Exception#backtrace_locations; the backtrace must be an array of
963
+ # Thread::Backtrace::Location, an array of strings, a single string, or `nil`.
964
+ #
965
+ # Using the array of Thread::Backtrace::Location instances is the most
966
+ # consistent option and should be preferred when possible. The necessary value
967
+ # might be obtained from #caller_locations, or copied from
968
+ # Exception#backtrace_locations of another error:
969
+ #
970
+ # begin
971
+ # do_some_work()
972
+ # rescue ZeroDivisionError => ex
973
+ # raise(LogicalError, "You have an error in your math", ex.backtrace_locations)
974
+ # end
975
+ #
976
+ # The ways, both Exception#backtrace and Exception#backtrace_locations of the
977
+ # raised error are set to the same backtrace.
978
+ #
979
+ # When the desired stack of locations is not available and should be constructed
980
+ # from scratch, an array of strings or a singular string can be used. In this
981
+ # case, only Exception#backtrace is set:
982
+ #
983
+ # begin
984
+ # raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1])
985
+ # rescue => ex
986
+ # p ex.backtrace
987
+ # # => ["dsl.rb:3", "framework.rb:1"]
988
+ # p ex.backtrace_locations
989
+ # # => nil
990
+ # end
991
+ #
992
+ # If argument `backtrace` is not given, the backtrace is set according to an
993
+ # array of Thread::Backtrace::Location objects, as derived from the call stack.
994
+ #
995
+ # See [Backtraces](rdoc-ref:exceptions.md@Backtraces).
996
+ #
997
+ # Keyword argument `cause` sets the stored cause in the new exception, which may
998
+ # be retrieved by method Exception#cause; the cause must be an exception object
999
+ # (Exception or one of its subclasses), or `nil`:
1000
+ #
1001
+ # begin
1002
+ # raise(StandardError, cause: RuntimeError.new)
1003
+ # rescue => x
1004
+ # p x.cause
1005
+ # end
1006
+ # # => #<RuntimeError: RuntimeError>
1007
+ #
1008
+ # If keyword argument `cause` is not given, the cause is the value of
1009
+ # <code>$!</code>.
1010
+ #
1011
+ # See [Cause](rdoc-ref:exceptions.md@Cause).
1012
+ #
1013
+ # In the alternate calling sequence, where argument `exception` *not* given,
1014
+ # raises a new exception of the class given by <code>$!</code>, or of class
1015
+ # RuntimeError if <code>$!</code> is `nil`:
1016
+ #
1017
+ # begin
1018
+ # raise
1019
+ # rescue => x
1020
+ # p x
1021
+ # end
1022
+ # # => RuntimeError
1023
+ #
1024
+ # With argument `exception` not given, argument `message` and keyword argument
1025
+ # `cause` may be given, but argument `backtrace` may not be given.
1026
+ #
1027
+ # `cause` can not be given as an only argument.
1028
+ #
1029
+ def self?.fail: () -> bot
1030
+ | (string message, ?cause: Exception?) -> bot
1031
+ | (_Exception exception, ?string | _ToS message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot
1032
+ | (_Exception exception, ?cause: Exception?, **untyped) -> bot
1033
+
1034
+ # <!--
1035
+ # rdoc-file=eval.c
1036
+ # - raise(exception, message = exception.to_s, backtrace = nil, cause: $!)
1037
+ # - raise(message = nil, cause: $!)
1038
+ # -->
1039
+ # Raises an exception; see [Exceptions](rdoc-ref:exceptions.md).
1040
+ #
1041
+ # Argument `exception` sets the class of the new exception; it should be class
1042
+ # Exception or one of its subclasses (most commonly, RuntimeError or
1043
+ # StandardError), or an instance of one of those classes:
1044
+ #
1045
+ # begin
1046
+ # raise(StandardError)
1047
+ # rescue => x
1048
+ # p x.class
1049
+ # end
1050
+ # # => StandardError
1051
+ #
1052
+ # Argument `message` sets the stored message in the new exception, which may be
1053
+ # retrieved by method Exception#message; the message must be a
1054
+ # [string-convertible
1055
+ # object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or
1056
+ # `nil`:
1057
+ #
1058
+ # begin
1059
+ # raise(StandardError, 'Boom')
1060
+ # rescue => x
1061
+ # p x.message
1062
+ # end
1063
+ # # => "Boom"
1064
+ #
1065
+ # If argument `message` is not given, the message is the exception class name.
1066
+ #
1067
+ # See [Messages](rdoc-ref:exceptions.md@Messages).
1068
+ #
1069
+ # Argument `backtrace` might be used to modify the backtrace of the new
1070
+ # exception, as reported by Exception#backtrace and
1071
+ # Exception#backtrace_locations; the backtrace must be an array of
1072
+ # Thread::Backtrace::Location, an array of strings, a single string, or `nil`.
1073
+ #
1074
+ # Using the array of Thread::Backtrace::Location instances is the most
1075
+ # consistent option and should be preferred when possible. The necessary value
1076
+ # might be obtained from #caller_locations, or copied from
1077
+ # Exception#backtrace_locations of another error:
1078
+ #
1079
+ # begin
1080
+ # do_some_work()
1081
+ # rescue ZeroDivisionError => ex
1082
+ # raise(LogicalError, "You have an error in your math", ex.backtrace_locations)
1083
+ # end
1084
+ #
1085
+ # The ways, both Exception#backtrace and Exception#backtrace_locations of the
1086
+ # raised error are set to the same backtrace.
1087
+ #
1088
+ # When the desired stack of locations is not available and should be constructed
1089
+ # from scratch, an array of strings or a singular string can be used. In this
1090
+ # case, only Exception#backtrace is set:
1091
+ #
1092
+ # begin
1093
+ # raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1])
1094
+ # rescue => ex
1095
+ # p ex.backtrace
1096
+ # # => ["dsl.rb:3", "framework.rb:1"]
1097
+ # p ex.backtrace_locations
1098
+ # # => nil
1099
+ # end
1100
+ #
1101
+ # If argument `backtrace` is not given, the backtrace is set according to an
1102
+ # array of Thread::Backtrace::Location objects, as derived from the call stack.
1103
+ #
1104
+ # See [Backtraces](rdoc-ref:exceptions.md@Backtraces).
1105
+ #
1106
+ # Keyword argument `cause` sets the stored cause in the new exception, which may
1107
+ # be retrieved by method Exception#cause; the cause must be an exception object
1108
+ # (Exception or one of its subclasses), or `nil`:
1109
+ #
1110
+ # begin
1111
+ # raise(StandardError, cause: RuntimeError.new)
1112
+ # rescue => x
1113
+ # p x.cause
1114
+ # end
1115
+ # # => #<RuntimeError: RuntimeError>
1116
+ #
1117
+ # If keyword argument `cause` is not given, the cause is the value of
1118
+ # <code>$!</code>.
1119
+ #
1120
+ # See [Cause](rdoc-ref:exceptions.md@Cause).
1121
+ #
1122
+ # In the alternate calling sequence, where argument `exception` *not* given,
1123
+ # raises a new exception of the class given by <code>$!</code>, or of class
1124
+ # RuntimeError if <code>$!</code> is `nil`:
1125
+ #
1126
+ # begin
1127
+ # raise
1128
+ # rescue => x
1129
+ # p x
1130
+ # end
1131
+ # # => RuntimeError
1132
+ #
1133
+ # With argument `exception` not given, argument `message` and keyword argument
1134
+ # `cause` may be given, but argument `backtrace` may not be given.
1135
+ #
1136
+ # `cause` can not be given as an only argument.
1137
+ #
1138
+ alias raise fail
1139
+
1140
+ alias self.raise self.fail
1141
+
1142
+ # <!-- rdoc-file=object.c -->
1143
+ # Returns the string resulting from formatting `objects` into `format_string`.
1144
+ #
1145
+ # For details on `format_string`, see [Format
1146
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
1147
+ #
1148
+ def self?.format: (String format, *untyped args) -> String
1149
+
1150
+ # <!--
1151
+ # rdoc-file=object.c
1152
+ # - sprintf(format_string *objects) -> string
1153
+ # -->
1154
+ # Returns the string resulting from formatting `objects` into `format_string`.
1155
+ #
1156
+ # For details on `format_string`, see [Format
1157
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
1158
+ #
1159
+ alias sprintf format
1160
+
1161
+ alias self.sprintf self.format
1162
+
1163
+ # <!--
1164
+ # rdoc-file=io.c
1165
+ # - gets(sep=$/ [, getline_args]) -> string or nil
1166
+ # - gets(limit [, getline_args]) -> string or nil
1167
+ # - gets(sep, limit [, getline_args]) -> string or nil
1168
+ # -->
1169
+ # Returns (and assigns to <code>$_</code>) the next line from the list of files
1170
+ # in `ARGV` (or <code>$*</code>), or from standard input if no files are present
1171
+ # on the command line. Returns `nil` at end of file. The optional argument
1172
+ # specifies the record separator. The separator is included with the contents of
1173
+ # each record. A separator of `nil` reads the entire contents, and a zero-length
1174
+ # separator reads the input one paragraph at a time, where paragraphs are
1175
+ # divided by two consecutive newlines. If the first argument is an integer, or
1176
+ # optional second argument is given, the returning string would not be longer
1177
+ # than the given value in bytes. If multiple filenames are present in `ARGV`,
1178
+ # <code>gets(nil)</code> will read the contents one file at a time.
1179
+ #
1180
+ # ARGV << "testfile"
1181
+ # print while gets
1182
+ #
1183
+ # <em>produces:</em>
1184
+ #
1185
+ # This is line one
1186
+ # This is line two
1187
+ # This is line three
1188
+ # And so on...
1189
+ #
1190
+ # The style of programming using <code>$_</code> as an implicit parameter is
1191
+ # gradually losing favor in the Ruby community.
1192
+ #
1193
+ def self?.gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
1194
+
1195
+ # <!--
1196
+ # rdoc-file=eval.c
1197
+ # - global_variables -> array
1198
+ # -->
1199
+ # Returns an array of the names of global variables. This includes special
1200
+ # regexp global variables such as <code>$~</code> and <code>$+</code>, but does
1201
+ # not include the numbered regexp global variables (<code>$1</code>,
1202
+ # <code>$2</code>, etc.).
1203
+ #
1204
+ # global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
1205
+ #
1206
+ def self?.global_variables: () -> Array[Symbol]
1207
+
1208
+ # <!--
1209
+ # rdoc-file=load.c
1210
+ # - load(filename, wrap=false) -> true
1211
+ # -->
1212
+ # Loads and executes the Ruby program in the file *filename*.
1213
+ #
1214
+ # If the filename is an absolute path (e.g. starts with '/'), the file will be
1215
+ # loaded directly using the absolute path.
1216
+ #
1217
+ # If the filename is an explicit relative path (e.g. starts with './' or '../'),
1218
+ # the file will be loaded using the relative path from the current directory.
1219
+ #
1220
+ # Otherwise, the file will be searched for in the library directories listed in
1221
+ # <code>$LOAD_PATH</code> (<code>$:</code>). If the file is found in a
1222
+ # directory, it will attempt to load the file relative to that directory. If
1223
+ # the file is not found in any of the directories in <code>$LOAD_PATH</code>,
1224
+ # the file will be loaded using the relative path from the current directory.
1225
+ #
1226
+ # If the file doesn't exist when there is an attempt to load it, a LoadError
1227
+ # will be raised.
1228
+ #
1229
+ # If the optional *wrap* parameter is `true`, the loaded script will be executed
1230
+ # under an anonymous module. If the optional *wrap* parameter is a module, the
1231
+ # loaded script will be executed under the given module. In no circumstance will
1232
+ # any local variables in the loaded file be propagated to the loading
1233
+ # environment.
1234
+ #
1235
+ def self?.load: (String filename, ?Module | bool) -> bool
1236
+
1237
+ # <!--
1238
+ # rdoc-file=kernel.rb
1239
+ # - loop { block }
1240
+ # - loop -> an_enumerator
1241
+ # -->
1242
+ # Repeatedly executes the block.
1243
+ #
1244
+ # If no block is given, an enumerator is returned instead.
1245
+ #
1246
+ # loop do
1247
+ # print "Input: "
1248
+ # line = gets
1249
+ # # break if q, Q is entered or EOF signal (Ctrl-D on Unix, Ctrl-Z on windows) is sent
1250
+ # break if !line or line =~ /^q/i
1251
+ # # ...
1252
+ # end
1253
+ #
1254
+ # A StopIteration raised in the block breaks the loop. In this case, loop
1255
+ # returns the "result" value stored in the exception.
1256
+ #
1257
+ # enum = Enumerator.new { |y|
1258
+ # y << "one"
1259
+ # y << "two"
1260
+ # :ok
1261
+ # }
1262
+ #
1263
+ # result = loop {
1264
+ # puts enum.next
1265
+ # } #=> :ok
1266
+ #
1267
+ def self?.loop: () { () -> void } -> bot
1268
+ | () -> ::Enumerator[nil, bot]
1269
+
1270
+ # <!--
1271
+ # rdoc-file=io.c
1272
+ # - open(path, mode = 'r', perm = 0666, **opts) -> io or nil
1273
+ # - open(path, mode = 'r', perm = 0666, **opts) {|io| ... } -> obj
1274
+ # -->
1275
+ # Creates an IO object connected to the given file.
1276
+ #
1277
+ # With no block given, file stream is returned:
1278
+ #
1279
+ # open('t.txt') # => #<File:t.txt>
1280
+ #
1281
+ # With a block given, calls the block with the open file stream, then closes the
1282
+ # stream:
1283
+ #
1284
+ # open('t.txt') {|f| p f } # => #<File:t.txt (closed)>
1285
+ #
1286
+ # Output:
1287
+ #
1288
+ # #<File:t.txt>
1289
+ #
1290
+ # See File.open for details.
1291
+ #
1292
+ def self?.open: (String name, ?String mode, ?Integer perm) -> IO?
1293
+ | [T] (String name, ?String mode, ?Integer perm) { (IO) -> T } -> T
1294
+
1295
+ # <!--
1296
+ # rdoc-file=io.c
1297
+ # - print(*objects) -> nil
1298
+ # -->
1299
+ # Equivalent to <code>$stdout.print(*objects)</code>, this method is the
1300
+ # straightforward way to write to <code>$stdout</code>.
1301
+ #
1302
+ # Writes the given objects to <code>$stdout</code>; returns `nil`. Appends the
1303
+ # output record separator <code>$OUTPUT_RECORD_SEPARATOR</code>
1304
+ # <code>$\</code>), if it is not `nil`.
1305
+ #
1306
+ # With argument `objects` given, for each object:
1307
+ #
1308
+ # * Converts via its method `to_s` if not a string.
1309
+ # * Writes to `stdout`.
1310
+ # * If not the last object, writes the output field separator
1311
+ # <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code> if it is not `nil`.
1312
+ #
1313
+ # With default separators:
1314
+ #
1315
+ # objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero']
1316
+ # $OUTPUT_RECORD_SEPARATOR
1317
+ # $OUTPUT_FIELD_SEPARATOR
1318
+ # print(*objects)
1319
+ #
1320
+ # Output:
1321
+ #
1322
+ # nil
1323
+ # nil
1324
+ # 00.00/10+0izerozero
1325
+ #
1326
+ # With specified separators:
1327
+ #
1328
+ # $OUTPUT_RECORD_SEPARATOR = "\n"
1329
+ # $OUTPUT_FIELD_SEPARATOR = ','
1330
+ # print(*objects)
1331
+ #
1332
+ # Output:
1333
+ #
1334
+ # 0,0.0,0/1,0+0i,zero,zero
1335
+ #
1336
+ # With no argument given, writes the content of <code>$_</code> (which is
1337
+ # usually the most recent user input):
1338
+ #
1339
+ # gets # Sets $_ to the most recent user input.
1340
+ # print # Prints $_.
1341
+ #
1342
+ def self?.print: (*_ToS args) -> nil
1343
+
1344
+ # <!--
1345
+ # rdoc-file=io.c
1346
+ # - printf(format_string, *objects) -> nil
1347
+ # - printf(io, format_string, *objects) -> nil
1348
+ # -->
1349
+ # Equivalent to:
1350
+ #
1351
+ # io.write(sprintf(format_string, *objects))
1352
+ #
1353
+ # For details on `format_string`, see [Format
1354
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
1355
+ #
1356
+ # With the single argument `format_string`, formats `objects` into the string,
1357
+ # then writes the formatted string to $stdout:
1358
+ #
1359
+ # printf('%4.4d %10s %2.2f', 24, 24, 24.0)
1360
+ #
1361
+ # Output (on $stdout):
1362
+ #
1363
+ # 0024 24 24.00#
1364
+ #
1365
+ # With arguments `io` and `format_string`, formats `objects` into the string,
1366
+ # then writes the formatted string to `io`:
1367
+ #
1368
+ # printf($stderr, '%4.4d %10s %2.2f', 24, 24, 24.0)
1369
+ #
1370
+ # Output (on $stderr):
1371
+ #
1372
+ # 0024 24 24.00# => nil
1373
+ #
1374
+ # With no arguments, does nothing.
1375
+ #
1376
+ def self?.printf: () -> nil
1377
+ | (String fmt, *untyped args) -> nil
1378
+ | (_Writer io, string fmt, *untyped args) -> nil
1379
+
1380
+ # <!--
1381
+ # rdoc-file=proc.c
1382
+ # - proc { |...| block } -> a_proc
1383
+ # -->
1384
+ # Equivalent to Proc.new.
1385
+ #
1386
+ def self?.proc: () { (?) -> untyped } -> Proc
1387
+
1388
+ # <!--
1389
+ # rdoc-file=proc.c
1390
+ # - lambda { |...| block } -> a_proc
1391
+ # -->
1392
+ # Equivalent to Proc.new, except the resulting Proc objects check the number of
1393
+ # parameters passed when called.
1394
+ #
1395
+ def self?.lambda: () { () -> untyped } -> Proc
1396
+
1397
+ # <!--
1398
+ # rdoc-file=io.c
1399
+ # - putc(int) -> int
1400
+ # -->
1401
+ # Equivalent to:
1402
+ #
1403
+ # $stdout.putc(int)
1404
+ #
1405
+ # See IO#putc for important information regarding multi-byte characters.
1406
+ #
1407
+ def self?.putc: [T < _ToInt] (T chr) -> T
1408
+ | (String chr) -> String
1409
+
1410
+ # <!--
1411
+ # rdoc-file=io.c
1412
+ # - puts(*objects) -> nil
1413
+ # -->
1414
+ # Equivalent to
1415
+ #
1416
+ # $stdout.puts(objects)
1417
+ #
1418
+ def self?.puts: (*_ToS objects) -> nil
1419
+
1420
+ # <!--
1421
+ # rdoc-file=io.c
1422
+ # - p(object) -> obj
1423
+ # - p(*objects) -> array of objects
1424
+ # - p -> nil
1425
+ # -->
1426
+ # For each object `obj`, executes:
1427
+ #
1428
+ # $stdout.write(obj.inspect, "\n")
1429
+ #
1430
+ # With one object given, returns the object; with multiple objects given,
1431
+ # returns an array containing the objects; with no object given, returns `nil`.
1432
+ #
1433
+ # Examples:
1434
+ #
1435
+ # r = Range.new(0, 4)
1436
+ # p r # => 0..4
1437
+ # p [r, r, r] # => [0..4, 0..4, 0..4]
1438
+ # p # => nil
1439
+ #
1440
+ # Output:
1441
+ #
1442
+ # 0..4
1443
+ # [0..4, 0..4, 0..4]
1444
+ #
1445
+ # Kernel#p is designed for debugging purposes. Ruby implementations may define
1446
+ # Kernel#p to be uninterruptible in whole or in part. On CRuby, Kernel#p's
1447
+ # writing of data is uninterruptible.
1448
+ #
1449
+ def self?.p: [T < _Inspect] (T arg0) -> T
1450
+ | (_Inspect arg0, _Inspect arg1, *_Inspect rest) -> Array[_Inspect]
1451
+ | () -> nil
1452
+
1453
+ # <!--
1454
+ # rdoc-file=lib/pp.rb
1455
+ # - pp(*objs)
1456
+ # -->
1457
+ # prints arguments in pretty form.
1458
+ #
1459
+ # <code>#pp</code> returns argument(s).
1460
+ #
1461
+ def self?.pp: [T] (T arg0) -> T
1462
+ | (untyped, untyped, *untyped) -> Array[untyped]
1463
+ | () -> nil
1464
+
1465
+ # <!--
1466
+ # rdoc-file=random.c
1467
+ # - rand(max=0) -> number
1468
+ # -->
1469
+ # If called without an argument, or if <code>max.to_i.abs == 0</code>, rand
1470
+ # returns a pseudo-random floating point number between 0.0 and 1.0, including
1471
+ # 0.0 and excluding 1.0.
1472
+ #
1473
+ # rand #=> 0.2725926052826416
1474
+ #
1475
+ # When <code>max.abs</code> is greater than or equal to 1, `rand` returns a
1476
+ # pseudo-random integer greater than or equal to 0 and less than
1477
+ # <code>max.to_i.abs</code>.
1478
+ #
1479
+ # rand(100) #=> 12
1480
+ #
1481
+ # When `max` is a Range, `rand` returns a random number where
1482
+ # <code>range.member?(number) == true</code>.
1483
+ #
1484
+ # Negative or floating point values for `max` are allowed, but may give
1485
+ # surprising results.
1486
+ #
1487
+ # rand(-100) # => 87
1488
+ # rand(-0.5) # => 0.8130921818028143
1489
+ # rand(1.9) # equivalent to rand(1), which is always 0
1490
+ #
1491
+ # Kernel.srand may be used to ensure that sequences of random numbers are
1492
+ # reproducible between different runs of a program.
1493
+ #
1494
+ # Related: Random.rand.
1495
+ # rand(100.0) # => 64 (Integer because max.to_i is 100)
1496
+ # Random.rand(100.0) # => 30.315320967824523
1497
+ #
1498
+ def self?.rand: (?0) -> Float
1499
+ | (int arg0) -> Integer
1500
+ | (::Range[Integer] arg0) -> Integer?
1501
+ | (::Range[Float] arg0) -> Float?
1502
+
1503
+ # <!--
1504
+ # rdoc-file=io.c
1505
+ # - readline(sep = $/, chomp: false) -> string
1506
+ # - readline(limit, chomp: false) -> string
1507
+ # - readline(sep, limit, chomp: false) -> string
1508
+ # -->
1509
+ # Equivalent to method Kernel#gets, except that it raises an exception if called
1510
+ # at end-of-stream:
1511
+ #
1512
+ # $ cat t.txt | ruby -e "p readlines; readline"
1513
+ # ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
1514
+ # in `readline': end of file reached (EOFError)
1515
+ #
1516
+ # Optional keyword argument `chomp` specifies whether line separators are to be
1517
+ # omitted.
1518
+ #
1519
+ def self?.readline: (?String arg0, ?Integer arg1, ?chomp: boolish) -> String
1520
+
1521
+ # <!--
1522
+ # rdoc-file=io.c
1523
+ # - readlines(sep = $/, chomp: false, **enc_opts) -> array
1524
+ # - readlines(limit, chomp: false, **enc_opts) -> array
1525
+ # - readlines(sep, limit, chomp: false, **enc_opts) -> array
1526
+ # -->
1527
+ # Returns an array containing the lines returned by calling Kernel#gets until
1528
+ # the end-of-stream is reached; (see [Line IO](rdoc-ref:IO@Line+IO)).
1529
+ #
1530
+ # With only string argument `sep` given, returns the remaining lines as
1531
+ # determined by line separator `sep`, or `nil` if none; see [Line
1532
+ # Separator](rdoc-ref:IO@Line+Separator):
1533
+ #
1534
+ # # Default separator.
1535
+ # $ cat t.txt | ruby -e "p readlines"
1536
+ # ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
1537
+ #
1538
+ # # Specified separator.
1539
+ # $ cat t.txt | ruby -e "p readlines 'li'"
1540
+ # ["First li", "ne\nSecond li", "ne\n\nFourth li", "ne\nFifth li", "ne\n"]
1541
+ #
1542
+ # # Get-all separator.
1543
+ # $ cat t.txt | ruby -e "p readlines nil"
1544
+ # ["First line\nSecond line\n\nFourth line\nFifth line\n"]
1545
+ #
1546
+ # # Get-paragraph separator.
1547
+ # $ cat t.txt | ruby -e "p readlines ''"
1548
+ # ["First line\nSecond line\n\n", "Fourth line\nFifth line\n"]
1549
+ #
1550
+ # With only integer argument `limit` given, limits the number of bytes in the
1551
+ # line; see [Line Limit](rdoc-ref:IO@Line+Limit):
1552
+ #
1553
+ # $cat t.txt | ruby -e "p readlines 10"
1554
+ # ["First line", "\n", "Second lin", "e\n", "\n", "Fourth lin", "e\n", "Fifth line", "\n"]
1555
+ #
1556
+ # $cat t.txt | ruby -e "p readlines 11"
1557
+ # ["First line\n", "Second line", "\n", "\n", "Fourth line", "\n", "Fifth line\n"]
1558
+ #
1559
+ # $cat t.txt | ruby -e "p readlines 12"
1560
+ # ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
1561
+ #
1562
+ # With arguments `sep` and `limit` given, combines the two behaviors (see [Line
1563
+ # Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)).
1564
+ #
1565
+ # Optional keyword argument `chomp` specifies whether line separators are to be
1566
+ # omitted:
1567
+ #
1568
+ # $ cat t.txt | ruby -e "p readlines(chomp: true)"
1569
+ # ["First line", "Second line", "", "Fourth line", "Fifth line"]
1570
+ #
1571
+ # Optional keyword arguments `enc_opts` specify encoding options; see [Encoding
1572
+ # options](rdoc-ref:encodings.rdoc@Encoding+Options).
1573
+ #
1574
+ def self?.readlines: (?string sep, ?int limit, ?chomp: boolish) -> ::Array[String]
1575
+
1576
+ # <!--
1577
+ # rdoc-file=lib/rubygems/core_ext/kernel_require.rb
1578
+ # - require(path)
1579
+ # -->
1580
+ # When RubyGems is required, Kernel#require is replaced with our own which is
1581
+ # capable of loading gems on demand.
1582
+ #
1583
+ # When you call <code>require 'x'</code>, this is what happens:
1584
+ # * If the file can be loaded from the existing Ruby loadpath, it is.
1585
+ # * Otherwise, installed gems are searched for a file that matches. If it's
1586
+ # found in gem 'y', that gem is activated (added to the loadpath).
1587
+ #
1588
+ # The normal `require` functionality of returning false if that file has already
1589
+ # been loaded is preserved.
1590
+ #
1591
+ def self?.require: (String path) -> bool
1592
+
1593
+ # <!--
1594
+ # rdoc-file=load.c
1595
+ # - require_relative(string) -> true or false
1596
+ # -->
1597
+ # Ruby tries to load the library named *string* relative to the directory
1598
+ # containing the requiring file. If the file does not exist a LoadError is
1599
+ # raised. Returns `true` if the file was loaded and `false` if the file was
1600
+ # already loaded before.
1601
+ #
1602
+ def self?.require_relative: (String feature) -> bool
1603
+
1604
+ # <!--
1605
+ # rdoc-file=io.c
1606
+ # - IO.select(read_ios, write_ios = [], error_ios = [], timeout = nil) -> array or nil
1607
+ # -->
1608
+ # Invokes system call [select(2)](https://linux.die.net/man/2/select), which
1609
+ # monitors multiple file descriptors, waiting until one or more of the file
1610
+ # descriptors becomes ready for some class of I/O operation.
1611
+ #
1612
+ # Not implemented on all platforms.
1613
+ #
1614
+ # Each of the arguments `read_ios`, `write_ios`, and `error_ios` is an array of
1615
+ # IO objects.
1616
+ #
1617
+ # Argument `timeout` is a numeric value (such as integer or float) timeout
1618
+ # interval in seconds. `timeout` can also be `nil` or
1619
+ # <code>Float::INFINITY</code>. `nil` and <code>Float::INFINITY</code> means no
1620
+ # timeout.
1621
+ #
1622
+ # The method monitors the IO objects given in all three arrays, waiting for some
1623
+ # to be ready; returns a 3-element array whose elements are:
1624
+ #
1625
+ # * An array of the objects in `read_ios` that are ready for reading.
1626
+ # * An array of the objects in `write_ios` that are ready for writing.
1627
+ # * An array of the objects in `error_ios` have pending exceptions.
1628
+ #
1629
+ # If no object becomes ready within the given `timeout`, `nil` is returned.
1630
+ #
1631
+ # IO.select peeks the buffer of IO objects for testing readability. If the IO
1632
+ # buffer is not empty, IO.select immediately notifies readability. This "peek"
1633
+ # only happens for IO objects. It does not happen for IO-like objects such as
1634
+ # OpenSSL::SSL::SSLSocket.
1635
+ #
1636
+ # The best way to use IO.select is invoking it after non-blocking methods such
1637
+ # as #read_nonblock, #write_nonblock, etc. The methods raise an exception which
1638
+ # is extended by IO::WaitReadable or IO::WaitWritable. The modules notify how
1639
+ # the caller should wait with IO.select. If IO::WaitReadable is raised, the
1640
+ # caller should wait for reading. If IO::WaitWritable is raised, the caller
1641
+ # should wait for writing.
1642
+ #
1643
+ # So, blocking read (#readpartial) can be emulated using #read_nonblock and
1644
+ # IO.select as follows:
1645
+ #
1646
+ # begin
1647
+ # result = io_like.read_nonblock(maxlen)
1648
+ # rescue IO::WaitReadable
1649
+ # IO.select([io_like])
1650
+ # retry
1651
+ # rescue IO::WaitWritable
1652
+ # IO.select(nil, [io_like])
1653
+ # retry
1654
+ # end
1655
+ #
1656
+ # Especially, the combination of non-blocking methods and IO.select is preferred
1657
+ # for IO like objects such as OpenSSL::SSL::SSLSocket. It has #to_io method to
1658
+ # return underlying IO object. IO.select calls #to_io to obtain the file
1659
+ # descriptor to wait.
1660
+ #
1661
+ # This means that readability notified by IO.select doesn't mean readability
1662
+ # from OpenSSL::SSL::SSLSocket object.
1663
+ #
1664
+ # The most likely situation is that OpenSSL::SSL::SSLSocket buffers some data.
1665
+ # IO.select doesn't see the buffer. So IO.select can block when
1666
+ # OpenSSL::SSL::SSLSocket#readpartial doesn't block.
1667
+ #
1668
+ # However, several more complicated situations exist.
1669
+ #
1670
+ # SSL is a protocol which is sequence of records. The record consists of
1671
+ # multiple bytes. So, the remote side of SSL sends a partial record, IO.select
1672
+ # notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a byte and
1673
+ # OpenSSL::SSL::SSLSocket#readpartial will block.
1674
+ #
1675
+ # Also, the remote side can request SSL renegotiation which forces the local SSL
1676
+ # engine to write some data. This means OpenSSL::SSL::SSLSocket#readpartial may
1677
+ # invoke #write system call and it can block. In such a situation,
1678
+ # OpenSSL::SSL::SSLSocket#read_nonblock raises IO::WaitWritable instead of
1679
+ # blocking. So, the caller should wait for ready for writability as above
1680
+ # example.
1681
+ #
1682
+ # The combination of non-blocking methods and IO.select is also useful for
1683
+ # streams such as tty, pipe socket socket when multiple processes read from a
1684
+ # stream.
1685
+ #
1686
+ # Finally, Linux kernel developers don't guarantee that readability of select(2)
1687
+ # means readability of following read(2) even for a single process; see
1688
+ # [select(2)](https://linux.die.net/man/2/select)
1689
+ #
1690
+ # Invoking IO.select before IO#readpartial works well as usual. However it is
1691
+ # not the best way to use IO.select.
1692
+ #
1693
+ # The writability notified by select(2) doesn't show how many bytes are
1694
+ # writable. IO#write method blocks until given whole string is written. So,
1695
+ # <code>IO#write(two or more bytes)</code> can block after writability is
1696
+ # notified by IO.select. IO#write_nonblock is required to avoid the blocking.
1697
+ #
1698
+ # Blocking write (#write) can be emulated using #write_nonblock and IO.select as
1699
+ # follows: IO::WaitReadable should also be rescued for SSL renegotiation in
1700
+ # OpenSSL::SSL::SSLSocket.
1701
+ #
1702
+ # while 0 < string.bytesize
1703
+ # begin
1704
+ # written = io_like.write_nonblock(string)
1705
+ # rescue IO::WaitReadable
1706
+ # IO.select([io_like])
1707
+ # retry
1708
+ # rescue IO::WaitWritable
1709
+ # IO.select(nil, [io_like])
1710
+ # retry
1711
+ # end
1712
+ # string = string.byteslice(written..-1)
1713
+ # end
1714
+ #
1715
+ # Example:
1716
+ #
1717
+ # rp, wp = IO.pipe
1718
+ # mesg = "ping "
1719
+ # 100.times {
1720
+ # # IO.select follows IO#read. Not the best way to use IO.select.
1721
+ # rs, ws, = IO.select([rp], [wp])
1722
+ # if r = rs[0]
1723
+ # ret = r.read(5)
1724
+ # print ret
1725
+ # case ret
1726
+ # when /ping/
1727
+ # mesg = "pong\n"
1728
+ # when /pong/
1729
+ # mesg = "ping "
1730
+ # end
1731
+ # end
1732
+ # if w = ws[0]
1733
+ # w.write(mesg)
1734
+ # end
1735
+ # }
1736
+ #
1737
+ # Output:
1738
+ #
1739
+ # ping pong
1740
+ # ping pong
1741
+ # ping pong
1742
+ # (snipped)
1743
+ # ping
1744
+ #
1745
+ def self?.select: (::Array[IO] read, ?::Array[IO] write, ?::Array[IO] error, ?Time::_Timeout timeout) -> ::Array[String]
1746
+
1747
+ # <!--
1748
+ # rdoc-file=process.c
1749
+ # - sleep(secs = nil) -> slept_secs
1750
+ # -->
1751
+ # Suspends execution of the current thread for the number of seconds specified
1752
+ # by numeric argument `secs`, or forever if `secs` is `nil`; returns the integer
1753
+ # number of seconds suspended (rounded).
1754
+ #
1755
+ # Time.new # => 2008-03-08 19:56:19 +0900
1756
+ # sleep 1.2 # => 1
1757
+ # Time.new # => 2008-03-08 19:56:20 +0900
1758
+ # sleep 1.9 # => 2
1759
+ # Time.new # => 2008-03-08 19:56:22 +0900
1760
+ #
1761
+ def self?.sleep: (?nil) -> bot
1762
+ | (Time::_Timeout duration) -> Integer
1763
+
1764
+ # <!--
1765
+ # rdoc-file=io.c
1766
+ # - syscall(integer_callno, *arguments) -> integer
1767
+ # -->
1768
+ # Invokes Posix system call [syscall(2)](https://linux.die.net/man/2/syscall),
1769
+ # which calls a specified function.
1770
+ #
1771
+ # Calls the operating system function identified by `integer_callno`; returns
1772
+ # the result of the function or raises SystemCallError if it failed. The effect
1773
+ # of the call is platform-dependent. The arguments and returned value are
1774
+ # platform-dependent.
1775
+ #
1776
+ # For each of `arguments`: if it is an integer, it is passed directly; if it is
1777
+ # a string, it is interpreted as a binary sequence of bytes. There may be as
1778
+ # many as nine such arguments.
1779
+ #
1780
+ # Arguments `integer_callno` and `argument`, as well as the returned value, are
1781
+ # platform-dependent.
1782
+ #
1783
+ # Note: Method `syscall` is essentially unsafe and unportable. The DL (Fiddle)
1784
+ # library is preferred for safer and a bit more portable programming.
1785
+ #
1786
+ # Not implemented on all platforms.
1787
+ #
1788
+ def self?.syscall: (Integer num, *untyped args) -> untyped
1789
+
1790
+ # <!--
1791
+ # rdoc-file=file.c
1792
+ # - test(char, path0, path1 = nil) -> object
1793
+ # -->
1794
+ # Performs a test on one or both of the *filesystem entities* at the given paths
1795
+ # `path0` and `path1`:
1796
+ # * Each path `path0` or `path1` points to a file, directory, device, pipe,
1797
+ # etc.
1798
+ # * Character `char` selects a specific test.
1799
+ # The tests:
1800
+ # * Each of these tests operates only on the entity at `path0`,
1801
+ # and returns `true` or `false`;
1802
+ # for a non-existent entity, returns `false` (does not raise exception):
1803
+ # Character |Test
1804
+ # ----------------|-----------------------------------------------------------------------------
1805
+ # <code>'b'</code>|Whether the entity is a block device.
1806
+ # <code>'c'</code>|Whether the entity is a character device.
1807
+ # <code>'d'</code>|Whether the entity is a directory.
1808
+ # <code>'e'</code>|Whether the entity is an existing entity.
1809
+ # <code>'f'</code>|Whether the entity is an existing regular file.
1810
+ # <code>'g'</code>|Whether the entity's setgid bit is set.
1811
+ # <code>'G'</code>|Whether the entity's group ownership is equal to the caller's.
1812
+ # <code>'k'</code>|Whether the entity's sticky bit is set.
1813
+ # <code>'l'</code>|Whether the entity is a symbolic link.
1814
+ # <code>'o'</code>|Whether the entity is owned by the caller's effective uid.
1815
+ # <code>'O'</code>|Like <code>'o'</code>, but uses the real uid (not the effective uid).
1816
+ # <code>'p'</code>|Whether the entity is a FIFO device (named pipe).
1817
+ # <code>'r'</code>|Whether the entity is readable by the caller's effective uid/gid.
1818
+ # <code>'R'</code>|Like <code>'r'</code>, but uses the real uid/gid (not the effective uid/gid).
1819
+ # <code>'S'</code>|Whether the entity is a socket.
1820
+ # <code>'u'</code>|Whether the entity's setuid bit is set.
1821
+ # <code>'w'</code>|Whether the entity is writable by the caller's effective uid/gid.
1822
+ # <code>'W'</code>|Like <code>'w'</code>, but uses the real uid/gid (not the effective uid/gid).
1823
+ # <code>'x'</code>|Whether the entity is executable by the caller's effective uid/gid.
1824
+ # <code>'X'</code>|Like <code>'x'</code>, but uses the real uid/gid (not the effective uid/git).
1825
+ # <code>'z'</code>|Whether the entity exists and is of length zero.
1826
+ # * This test operates only on the entity at `path0`,
1827
+ # and returns an integer size or +nil+:
1828
+ # Character |Test
1829
+ # ----------------|--------------------------------------------------------------------------------------------
1830
+ # <code>'s'</code>|Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise.
1831
+ # * Each of these tests operates only on the entity at `path0`,
1832
+ # and returns a Time object;
1833
+ # raises an exception if the entity does not exist:
1834
+ # Character |Test
1835
+ # ----------------|--------------------------------------
1836
+ # <code>'A'</code>|Last access time for the entity.
1837
+ # <code>'C'</code>|Last change time for the entity.
1838
+ # <code>'M'</code>|Last modification time for the entity.
1839
+ # * Each of these tests operates on the modification time (`mtime`)
1840
+ # of each of the entities at `path0` and `path1`,
1841
+ # and returns a `true` or `false`;
1842
+ # returns `false` if either entity does not exist:
1843
+ # Character |Test
1844
+ # ----------------|---------------------------------------------------------------
1845
+ # <code>'<'</code>|Whether the `mtime` at `path0` is less than that at `path1`.
1846
+ # <code>'='</code>|Whether the `mtime` at `path0` is equal to that at `path1`.
1847
+ # <code>'>'</code>|Whether the `mtime` at `path0` is greater than that at `path1`.
1848
+ # * This test operates on the content of each of the entities at `path0` and
1849
+ # `path1`,
1850
+ # and returns a `true` or `false`;
1851
+ # returns `false` if either entity does not exist:
1852
+ # Character |Test
1853
+ # ----------------|---------------------------------------------
1854
+ # <code>'-'</code>|Whether the entities exist and are identical.
1855
+ #
1856
+ def self?.test: ('b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'G' | 'k' | 'l' | 'o' | 'O' | 'p' | 'r' | 'R' | 'S' | 'u' | 'w' | 'W' | 'x' | 'X' | 'z' |
1857
+ 98 | 99 | 100 | 101 | 102 | 103 | 71 | 107 | 108 | 111 | 79 | 112 | 114 | 82 | 83 | 117 | 119 | 87 | 120 | 88 | 122, path filepath) -> bool
1858
+ | ('s' | 115, path filepath) -> Integer?
1859
+ | ('A' | 'M' | 'C' | 65 | 77 | 67, path filepath) -> Time
1860
+ | ('<' | '=' | '>' | '-' | 60 | 61 | 62 | 45, path filepath1, path filepath2) -> bool
1861
+ | (String | int cmd, path filepath1, ?path filepath2) -> (bool | Time | Integer | nil)
1862
+
1863
+ # <!--
1864
+ # rdoc-file=vm_eval.c
1865
+ # - throw(tag [, obj])
1866
+ # -->
1867
+ # Transfers control to the end of the active `catch` block waiting for *tag*.
1868
+ # Raises `UncaughtThrowError` if there is no `catch` block for the *tag*. The
1869
+ # optional second parameter supplies a return value for the `catch` block, which
1870
+ # otherwise defaults to `nil`. For examples, see Kernel::catch.
1871
+ #
1872
+ def self?.throw: (untyped tag, ?untyped obj) -> bot
1873
+
1874
+ # <!--
1875
+ # rdoc-file=warning.rb
1876
+ # - warn(*msgs, uplevel: nil, category: nil) -> nil
1877
+ # -->
1878
+ # If warnings have been disabled (for example with the <code>-W0</code> flag),
1879
+ # does nothing. Otherwise, converts each of the messages to strings, appends a
1880
+ # newline character to the string if the string does not end in a newline, and
1881
+ # calls Warning.warn with the string.
1882
+ #
1883
+ # warn("warning 1", "warning 2")
1884
+ #
1885
+ # <em>produces:</em>
1886
+ #
1887
+ # warning 1
1888
+ # warning 2
1889
+ #
1890
+ # If the `uplevel` keyword argument is given, the string will be prepended with
1891
+ # information for the given caller frame in the same format used by the
1892
+ # `rb_warn` C function.
1893
+ #
1894
+ # # In baz.rb
1895
+ # def foo
1896
+ # warn("invalid call to foo", uplevel: 1)
1897
+ # end
1898
+ #
1899
+ # def bar
1900
+ # foo
1901
+ # end
1902
+ #
1903
+ # bar
1904
+ #
1905
+ # <em>produces:</em>
1906
+ #
1907
+ # baz.rb:6: warning: invalid call to foo
1908
+ #
1909
+ # If `category` keyword argument is given, passes the category to
1910
+ # <code>Warning.warn</code>. The category given must be one of the following
1911
+ # categories:
1912
+ #
1913
+ # :deprecated
1914
+ # : Used for warning for deprecated functionality that may be removed in the
1915
+ # future.
1916
+ #
1917
+ # :experimental
1918
+ # : Used for experimental features that may change in future releases.
1919
+ #
1920
+ # :performance
1921
+ # : Used for warning about APIs or pattern that have negative performance
1922
+ # impact
1923
+ #
1924
+ def self?.warn: (*_ToS msg, ?uplevel: int?, ?category: Warning::category?) -> nil
1925
+
1926
+ # <!--
1927
+ # rdoc-file=process.c
1928
+ # - exec([env, ] command_line, options = {})
1929
+ # - exec([env, ] exe_path, *args, options = {})
1930
+ # -->
1931
+ # Replaces the current process by doing one of the following:
1932
+ #
1933
+ # * Passing string `command_line` to the shell.
1934
+ # * Invoking the executable at `exe_path`.
1935
+ #
1936
+ # This method has potential security vulnerabilities if called with untrusted
1937
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
1938
+ #
1939
+ # The new process is created using the [exec system
1940
+ # call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e
1941
+ # xecve.html); it may inherit some of its environment from the calling program
1942
+ # (possibly including open file descriptors).
1943
+ #
1944
+ # Argument `env`, if given, is a hash that affects `ENV` for the new process;
1945
+ # see [Execution Environment](rdoc-ref:Process@Execution+Environment).
1946
+ #
1947
+ # Argument `options` is a hash of options for the new process; see [Execution
1948
+ # Options](rdoc-ref:Process@Execution+Options).
1949
+ #
1950
+ # The first required argument is one of the following:
1951
+ #
1952
+ # * `command_line` if it is a string, and if it begins with a shell reserved
1953
+ # word or special built-in, or if it contains one or more meta characters.
1954
+ # * `exe_path` otherwise.
1955
+ #
1956
+ # <strong>Argument `command_line`</strong>
1957
+ #
1958
+ # String argument `command_line` is a command line to be passed to a shell; it
1959
+ # must begin with a shell reserved word, begin with a special built-in, or
1960
+ # contain meta characters:
1961
+ #
1962
+ # exec('if true; then echo "Foo"; fi') # Shell reserved word.
1963
+ # exec('exit') # Built-in.
1964
+ # exec('date > date.tmp') # Contains meta character.
1965
+ #
1966
+ # The command line may also contain arguments and options for the command:
1967
+ #
1968
+ # exec('echo "Foo"')
1969
+ #
1970
+ # Output:
1971
+ #
1972
+ # Foo
1973
+ #
1974
+ # See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the
1975
+ # shell.
1976
+ #
1977
+ # Raises an exception if the new process could not execute.
1978
+ #
1979
+ # <strong>Argument `exe_path`</strong>
1980
+ #
1981
+ # Argument `exe_path` is one of the following:
1982
+ #
1983
+ # * The string path to an executable to be called.
1984
+ # * A 2-element array containing the path to an executable and the string to
1985
+ # be used as the name of the executing process.
1986
+ #
1987
+ # Example:
1988
+ #
1989
+ # exec('/usr/bin/date')
1990
+ #
1991
+ # Output:
1992
+ #
1993
+ # Sat Aug 26 09:38:00 AM CDT 2023
1994
+ #
1995
+ # Ruby invokes the executable directly. This form does not use the shell; see
1996
+ # [Arguments args](rdoc-ref:Process@Arguments+args) for caveats.
1997
+ #
1998
+ # exec('doesnt_exist') # Raises Errno::ENOENT
1999
+ #
2000
+ # If one or more `args` is given, each is an argument or option to be passed to
2001
+ # the executable:
2002
+ #
2003
+ # exec('echo', 'C*')
2004
+ # exec('echo', 'hello', 'world')
2005
+ #
2006
+ # Output:
2007
+ #
2008
+ # C*
2009
+ # hello world
2010
+ #
2011
+ # Raises an exception if the new process could not execute.
2012
+ #
2013
+ def self?.exec: (String command, *String args, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: bool, ?chdir: String) -> bot
2014
+ | (Hash[string, string?] env, String command, *String args, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: bool, ?chdir: String) -> bot
2015
+
2016
+ type redirect_fd = Integer | :in | :out | :err | IO | String | [ String ] | [ String, string | int ] | [ String, string | int, int ] | [ :child, int ] | :close
2017
+
2018
+ # <!--
2019
+ # rdoc-file=process.c
2020
+ # - spawn([env, ] command_line, options = {}) -> pid
2021
+ # - spawn([env, ] exe_path, *args, options = {}) -> pid
2022
+ # -->
2023
+ # Creates a new child process by doing one of the following in that process:
2024
+ #
2025
+ # * Passing string `command_line` to the shell.
2026
+ # * Invoking the executable at `exe_path`.
2027
+ #
2028
+ # This method has potential security vulnerabilities if called with untrusted
2029
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
2030
+ #
2031
+ # Returns the process ID (pid) of the new process, without waiting for it to
2032
+ # complete.
2033
+ #
2034
+ # To avoid zombie processes, the parent process should call either:
2035
+ #
2036
+ # * Process.wait, to collect the termination statuses of its children.
2037
+ # * Process.detach, to register disinterest in their status.
2038
+ #
2039
+ # The new process is created using the [exec system
2040
+ # call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e
2041
+ # xecve.html); it may inherit some of its environment from the calling program
2042
+ # (possibly including open file descriptors).
2043
+ #
2044
+ # Argument `env`, if given, is a hash that affects `ENV` for the new process;
2045
+ # see [Execution Environment](rdoc-ref:Process@Execution+Environment).
2046
+ #
2047
+ # Argument `options` is a hash of options for the new process; see [Execution
2048
+ # Options](rdoc-ref:Process@Execution+Options).
2049
+ #
2050
+ # The first required argument is one of the following:
2051
+ #
2052
+ # * `command_line` if it is a string, and if it begins with a shell reserved
2053
+ # word or special built-in, or if it contains one or more meta characters.
2054
+ # * `exe_path` otherwise.
2055
+ #
2056
+ # <strong>Argument `command_line`</strong>
2057
+ #
2058
+ # String argument `command_line` is a command line to be passed to a shell; it
2059
+ # must begin with a shell reserved word, begin with a special built-in, or
2060
+ # contain meta characters:
2061
+ #
2062
+ # spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word.
2063
+ # Process.wait # => 798847
2064
+ # spawn('exit') # => 798848 # Built-in.
2065
+ # Process.wait # => 798848
2066
+ # spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character.
2067
+ # Process.wait # => 798849
2068
+ # spawn('date > /nop/date.tmp') # => 798882 # Issues error message.
2069
+ # Process.wait # => 798882
2070
+ #
2071
+ # The command line may also contain arguments and options for the command:
2072
+ #
2073
+ # spawn('echo "Foo"') # => 799031
2074
+ # Process.wait # => 799031
2075
+ #
2076
+ # Output:
2077
+ #
2078
+ # Foo
2079
+ #
2080
+ # See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the
2081
+ # shell.
2082
+ #
2083
+ # Raises an exception if the new process could not execute.
2084
+ #
2085
+ # <strong>Argument `exe_path`</strong>
2086
+ #
2087
+ # Argument `exe_path` is one of the following:
2088
+ #
2089
+ # * The string path to an executable to be called.
2090
+ # * A 2-element array containing the path to an executable to be called, and
2091
+ # the string to be used as the name of the executing process.
2092
+ #
2093
+ # spawn('/usr/bin/date') # Path to date on Unix-style system.
2094
+ # Process.wait
2095
+ #
2096
+ # Output:
2097
+ #
2098
+ # Mon Aug 28 11:43:10 AM CDT 2023
2099
+ #
2100
+ # Ruby invokes the executable directly. This form does not use the shell; see
2101
+ # [Arguments args](rdoc-ref:Process@Arguments+args) for caveats.
2102
+ #
2103
+ # If one or more `args` is given, each is an argument or option to be passed to
2104
+ # the executable:
2105
+ #
2106
+ # spawn('echo', 'C*') # => 799392
2107
+ # Process.wait # => 799392
2108
+ # spawn('echo', 'hello', 'world') # => 799393
2109
+ # Process.wait # => 799393
2110
+ #
2111
+ # Output:
2112
+ #
2113
+ # C*
2114
+ # hello world
2115
+ #
2116
+ # Raises an exception if the new process could not execute.
2117
+ #
2118
+ def self?.spawn: (String command, *String args, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: bool, ?chdir: String) -> Integer
2119
+ | (Hash[string, string?] env, String command, *String args, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: bool, ?chdir: String) -> Integer
2120
+
2121
+ # <!--
2122
+ # rdoc-file=process.c
2123
+ # - system([env, ] command_line, options = {}, exception: false) -> true, false, or nil
2124
+ # - system([env, ] exe_path, *args, options = {}, exception: false) -> true, false, or nil
2125
+ # -->
2126
+ # Creates a new child process by doing one of the following in that process:
2127
+ #
2128
+ # * Passing string `command_line` to the shell.
2129
+ # * Invoking the executable at `exe_path`.
2130
+ #
2131
+ # This method has potential security vulnerabilities if called with untrusted
2132
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
2133
+ #
2134
+ # Returns:
2135
+ #
2136
+ # * `true` if the command exits with status zero.
2137
+ # * `false` if the exit status is a non-zero integer.
2138
+ # * `nil` if the command could not execute.
2139
+ #
2140
+ # Raises an exception (instead of returning `false` or `nil`) if keyword
2141
+ # argument `exception` is set to `true`.
2142
+ #
2143
+ # Assigns the command's error status to <code>$?</code>.
2144
+ #
2145
+ # The new process is created using the [system system
2146
+ # call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/s
2147
+ # ystem.html); it may inherit some of its environment from the calling program
2148
+ # (possibly including open file descriptors).
2149
+ #
2150
+ # Argument `env`, if given, is a hash that affects `ENV` for the new process;
2151
+ # see [Execution Environment](rdoc-ref:Process@Execution+Environment).
2152
+ #
2153
+ # Argument `options` is a hash of options for the new process; see [Execution
2154
+ # Options](rdoc-ref:Process@Execution+Options).
2155
+ #
2156
+ # The first required argument is one of the following:
2157
+ #
2158
+ # * `command_line` if it is a string, and if it begins with a shell reserved
2159
+ # word or special built-in, or if it contains one or more meta characters.
2160
+ # * `exe_path` otherwise.
2161
+ #
2162
+ # <strong>Argument `command_line`</strong>
2163
+ #
2164
+ # String argument `command_line` is a command line to be passed to a shell; it
2165
+ # must begin with a shell reserved word, begin with a special built-in, or
2166
+ # contain meta characters:
2167
+ #
2168
+ # system('if true; then echo "Foo"; fi') # => true # Shell reserved word.
2169
+ # system('exit') # => true # Built-in.
2170
+ # system('date > /tmp/date.tmp') # => true # Contains meta character.
2171
+ # system('date > /nop/date.tmp') # => false
2172
+ # system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
2173
+ #
2174
+ # Assigns the command's error status to <code>$?</code>:
2175
+ #
2176
+ # system('exit') # => true # Built-in.
2177
+ # $? # => #<Process::Status: pid 640610 exit 0>
2178
+ # system('date > /nop/date.tmp') # => false
2179
+ # $? # => #<Process::Status: pid 640742 exit 2>
2180
+ #
2181
+ # The command line may also contain arguments and options for the command:
2182
+ #
2183
+ # system('echo "Foo"') # => true
2184
+ #
2185
+ # Output:
2186
+ #
2187
+ # Foo
2188
+ #
2189
+ # See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the
2190
+ # shell.
2191
+ #
2192
+ # Raises an exception if the new process could not execute.
2193
+ #
2194
+ # <strong>Argument `exe_path`</strong>
2195
+ #
2196
+ # Argument `exe_path` is one of the following:
2197
+ #
2198
+ # * The string path to an executable to be called.
2199
+ # * A 2-element array containing the path to an executable and the string to
2200
+ # be used as the name of the executing process.
2201
+ #
2202
+ # Example:
2203
+ #
2204
+ # system('/usr/bin/date') # => true # Path to date on Unix-style system.
2205
+ # system('foo') # => nil # Command failed.
2206
+ #
2207
+ # Output:
2208
+ #
2209
+ # Mon Aug 28 11:43:10 AM CDT 2023
2210
+ #
2211
+ # Assigns the command's error status to <code>$?</code>:
2212
+ #
2213
+ # system('/usr/bin/date') # => true
2214
+ # $? # => #<Process::Status: pid 645605 exit 0>
2215
+ # system('foo') # => nil
2216
+ # $? # => #<Process::Status: pid 645608 exit 127>
2217
+ #
2218
+ # Ruby invokes the executable directly. This form does not use the shell; see
2219
+ # [Arguments args](rdoc-ref:Process@Arguments+args) for caveats.
2220
+ #
2221
+ # system('doesnt_exist') # => nil
2222
+ #
2223
+ # If one or more `args` is given, each is an argument or option to be passed to
2224
+ # the executable:
2225
+ #
2226
+ # system('echo', 'C*') # => true
2227
+ # system('echo', 'hello', 'world') # => true
2228
+ #
2229
+ # Output:
2230
+ #
2231
+ # C*
2232
+ # hello world
2233
+ #
2234
+ # Raises an exception if the new process could not execute.
2235
+ #
2236
+ def self?.system: (String command, *String args, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: bool, ?chdir: String, ?exception: bool) -> (NilClass | FalseClass | TrueClass)
2237
+ | (Hash[string, string?] env, String command, *String args, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: bool, ?chdir: String, ?exception: bool) -> (NilClass | FalseClass | TrueClass)
2238
+
2239
+ # An interface used with `trace_var` (and `untrace_var`) for custom command types.
2240
+ interface _Tracer
2241
+ # Called whenever the global variable that's being traced changes; the argument is the new value.
2242
+ def call: (untyped argument) -> void
2243
+ end
2244
+
2245
+ # <!--
2246
+ # rdoc-file=eval.c
2247
+ # - trace_var(symbol, cmd ) -> nil
2248
+ # - trace_var(symbol) {|val| block } -> nil
2249
+ # -->
2250
+ # Controls tracing of assignments to global variables. The parameter `symbol`
2251
+ # identifies the variable (as either a string name or a symbol identifier).
2252
+ # *cmd* (which may be a string or a `Proc` object) or block is executed whenever
2253
+ # the variable is assigned. The block or `Proc` object receives the variable's
2254
+ # new value as a parameter. Also see #untrace_var.
2255
+ #
2256
+ # trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
2257
+ # $_ = "hello"
2258
+ # $_ = ' there'
2259
+ #
2260
+ # <em>produces:</em>
2261
+ #
2262
+ # $_ is now 'hello'
2263
+ # $_ is now ' there'
2264
+ #
2265
+ def self?.trace_var: (interned name, String | _Tracer cmd) -> nil
2266
+ | (interned name) { (untyped value) -> void } -> nil
2267
+ | (interned name, nil) -> Array[String | _Tracer]?
2268
+
2269
+ # <!--
2270
+ # rdoc-file=eval.c
2271
+ # - untrace_var(symbol [, cmd] ) -> array or nil
2272
+ # -->
2273
+ # Removes tracing for the specified command on the given global variable and
2274
+ # returns `nil`. If no command is specified, removes all tracing for that
2275
+ # variable and returns an array containing the commands actually removed.
2276
+ #
2277
+ def self?.untrace_var: (interned name, ?nil) -> Array[String | _Tracer]
2278
+ | (interned name, String cmd) -> [String]?
2279
+ | [T < _Tracer] (interned name, T cmd) -> [T]?
2280
+ | (interned name, untyped cmd) -> nil
2281
+
2282
+ # <!--
2283
+ # rdoc-file=object.c
2284
+ # - obj !~ other -> true or false
2285
+ # -->
2286
+ # Returns true if two objects do not match (using the *=~* method), otherwise
2287
+ # false.
2288
+ #
2289
+ def !~: (untyped other) -> bool
2290
+
2291
+ # <!--
2292
+ # rdoc-file=object.c
2293
+ # - obj <=> other -> 0 or nil
2294
+ # -->
2295
+ # Returns 0 if `obj` and `other` are the same object or `obj == other`,
2296
+ # otherwise nil.
2297
+ #
2298
+ # The #<=> is used by various methods to compare objects, for example
2299
+ # Enumerable#sort, Enumerable#max etc.
2300
+ #
2301
+ # Your implementation of #<=> should return one of the following values: -1, 0,
2302
+ # 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
2303
+ # 1 means self is bigger than other. Nil means the two values could not be
2304
+ # compared.
2305
+ #
2306
+ # When you define #<=>, you can include Comparable to gain the methods #<=, #<,
2307
+ # #==, #>=, #> and #between?.
2308
+ #
2309
+ def <=>: (untyped other) -> 0?
2310
+
2311
+ # <!--
2312
+ # rdoc-file=object.c
2313
+ # - obj === other -> true or false
2314
+ # -->
2315
+ # Case Equality -- For class Object, effectively the same as calling `#==`, but
2316
+ # typically overridden by descendants to provide meaningful semantics in `case`
2317
+ # statements.
2318
+ #
2319
+ alias === ==
2320
+
2321
+ # <!--
2322
+ # rdoc-file=kernel.rb
2323
+ # - obj.clone(freeze: nil) -> an_object
2324
+ # -->
2325
+ # Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
2326
+ # but not the objects they reference. #clone copies the frozen value state of
2327
+ # *obj*, unless the <code>:freeze</code> keyword argument is given with a false
2328
+ # or true value. See also the discussion under Object#dup.
2329
+ #
2330
+ # class Klass
2331
+ # attr_accessor :str
2332
+ # end
2333
+ # s1 = Klass.new #=> #<Klass:0x401b3a38>
2334
+ # s1.str = "Hello" #=> "Hello"
2335
+ # s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello">
2336
+ # s2.str[1,4] = "i" #=> "i"
2337
+ # s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
2338
+ # s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
2339
+ #
2340
+ # This method may have class-specific behavior. If so, that behavior will be
2341
+ # documented under the #`initialize_copy` method of the class.
2342
+ #
2343
+ def clone: (?freeze: bool?) -> self
2344
+
2345
+ # <!--
2346
+ # rdoc-file=proc.c
2347
+ # - define_singleton_method(symbol, method) -> symbol
2348
+ # - define_singleton_method(symbol) { block } -> symbol
2349
+ # -->
2350
+ # Defines a public singleton method in the receiver. The *method* parameter can
2351
+ # be a `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified,
2352
+ # it is used as the method body. If a block or a method has parameters, they're
2353
+ # used as method parameters.
2354
+ #
2355
+ # class A
2356
+ # class << self
2357
+ # def class_name
2358
+ # to_s
2359
+ # end
2360
+ # end
2361
+ # end
2362
+ # A.define_singleton_method(:who_am_i) do
2363
+ # "I am: #{class_name}"
2364
+ # end
2365
+ # A.who_am_i # ==> "I am: A"
2366
+ #
2367
+ # guy = "Bob"
2368
+ # guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
2369
+ # guy.hello #=> "Bob: Hello there!"
2370
+ #
2371
+ # chris = "Chris"
2372
+ # chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" }
2373
+ # chris.greet("Hi") #=> "Hi, I'm Chris!"
2374
+ #
2375
+ def define_singleton_method: (interned name, Method | UnboundMethod | Proc method) -> Symbol
2376
+ | (interned name) { (?) [self: self] -> untyped } -> Symbol
2377
+
2378
+ # <!--
2379
+ # rdoc-file=io.c
2380
+ # - display(port = $>) -> nil
2381
+ # -->
2382
+ # Writes `self` on the given port:
2383
+ #
2384
+ # 1.display
2385
+ # "cat".display
2386
+ # [ 4, 5, 6 ].display
2387
+ # puts
2388
+ #
2389
+ # Output:
2390
+ #
2391
+ # 1cat[4, 5, 6]
2392
+ #
2393
+ def display: (?_Writer port) -> nil
2394
+
2395
+ # <!--
2396
+ # rdoc-file=object.c
2397
+ # - obj.dup -> an_object
2398
+ # -->
2399
+ # Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
2400
+ # but not the objects they reference.
2401
+ #
2402
+ # This method may have class-specific behavior. If so, that behavior will be
2403
+ # documented under the #`initialize_copy` method of the class.
2404
+ #
2405
+ # ### on dup vs clone
2406
+ #
2407
+ # In general, #clone and #dup may have different semantics in descendant
2408
+ # classes. While #clone is used to duplicate an object, including its internal
2409
+ # state, #dup typically uses the class of the descendant object to create the
2410
+ # new instance.
2411
+ #
2412
+ # When using #dup, any modules that the object has been extended with will not
2413
+ # be copied.
2414
+ #
2415
+ # class Klass
2416
+ # attr_accessor :str
2417
+ # end
2418
+ #
2419
+ # module Foo
2420
+ # def foo; 'foo'; end
2421
+ # end
2422
+ #
2423
+ # s1 = Klass.new #=> #<Klass:0x401b3a38>
2424
+ # s1.extend(Foo) #=> #<Klass:0x401b3a38>
2425
+ # s1.foo #=> "foo"
2426
+ #
2427
+ # s2 = s1.clone #=> #<Klass:0x401be280>
2428
+ # s2.foo #=> "foo"
2429
+ #
2430
+ # s3 = s1.dup #=> #<Klass:0x401c1084>
2431
+ # s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401c1084>
2432
+ #
2433
+ def dup: () -> self
2434
+
2435
+ # <!-- rdoc-file=enumerator.c -->
2436
+ # Creates a new Enumerator which will enumerate by calling `method` on `obj`,
2437
+ # passing `args` if any. What was *yielded* by method becomes values of
2438
+ # enumerator.
2439
+ #
2440
+ # If a block is given, it will be used to calculate the size of the enumerator
2441
+ # without the need to iterate it (see Enumerator#size).
2442
+ #
2443
+ # ### Examples
2444
+ #
2445
+ # str = "xyz"
2446
+ #
2447
+ # enum = str.enum_for(:each_byte)
2448
+ # enum.each { |b| puts b }
2449
+ # # => 120
2450
+ # # => 121
2451
+ # # => 122
2452
+ #
2453
+ # # protect an array from being modified by some_method
2454
+ # a = [1, 2, 3]
2455
+ # some_method(a.to_enum)
2456
+ #
2457
+ # # String#split in block form is more memory-effective:
2458
+ # very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') }
2459
+ # # This could be rewritten more idiomatically with to_enum:
2460
+ # very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first
2461
+ #
2462
+ # It is typical to call to_enum when defining methods for a generic Enumerable,
2463
+ # in case no block is passed.
2464
+ #
2465
+ # Here is such an example, with parameter passing and a sizing block:
2466
+ #
2467
+ # module Enumerable
2468
+ # # a generic method to repeat the values of any enumerable
2469
+ # def repeat(n)
2470
+ # raise ArgumentError, "#{n} is negative!" if n < 0
2471
+ # unless block_given?
2472
+ # return to_enum(__method__, n) do # __method__ is :repeat here
2473
+ # sz = size # Call size and multiply by n...
2474
+ # sz * n if sz # but return nil if size itself is nil
2475
+ # end
2476
+ # end
2477
+ # each do |*val|
2478
+ # n.times { yield *val }
2479
+ # end
2480
+ # end
2481
+ # end
2482
+ #
2483
+ # %i[hello world].repeat(2) { |w| puts w }
2484
+ # # => Prints 'hello', 'hello', 'world', 'world'
2485
+ # enum = (1..14).repeat(3)
2486
+ # # => returns an Enumerator when called without a block
2487
+ # enum.first(4) # => [1, 1, 1, 2]
2488
+ # enum.size # => 42
2489
+ #
2490
+ def enum_for: (?interned method, *untyped, **untyped) ?{ (*untyped, **untyped) -> Integer } -> Enumerator[untyped, untyped]
2491
+
2492
+ alias to_enum enum_for
2493
+
2494
+ # <!--
2495
+ # rdoc-file=object.c
2496
+ # - obj == other -> true or false
2497
+ # - obj.equal?(other) -> true or false
2498
+ # - obj.eql?(other) -> true or false
2499
+ # -->
2500
+ # Equality --- At the Object level, #== returns `true` only if `obj` and `other`
2501
+ # are the same object. Typically, this method is overridden in descendant
2502
+ # classes to provide class-specific meaning.
2503
+ #
2504
+ # Unlike #==, the #equal? method should never be overridden by subclasses as it
2505
+ # is used to determine object identity (that is, `a.equal?(b)` if and only if
2506
+ # `a` is the same object as `b`):
2507
+ #
2508
+ # obj = "a"
2509
+ # other = obj.dup
2510
+ #
2511
+ # obj == other #=> true
2512
+ # obj.equal? other #=> false
2513
+ # obj.equal? obj #=> true
2514
+ #
2515
+ # The #eql? method returns `true` if `obj` and `other` refer to the same hash
2516
+ # key. This is used by Hash to test members for equality. For any pair of
2517
+ # objects where #eql? returns `true`, the #hash value of both objects must be
2518
+ # equal. So any subclass that overrides #eql? should also override #hash
2519
+ # appropriately.
2520
+ #
2521
+ # For objects of class Object, #eql? is synonymous with #==. Subclasses
2522
+ # normally continue this tradition by aliasing #eql? to their overridden #==
2523
+ # method, but there are exceptions. Numeric types, for example, perform type
2524
+ # conversion across #==, but not across #eql?, so:
2525
+ #
2526
+ # 1 == 1.0 #=> true
2527
+ # 1.eql? 1.0 #=> false
2528
+ #
2529
+ def eql?: (untyped other) -> bool
2530
+
2531
+ # <!--
2532
+ # rdoc-file=eval.c
2533
+ # - obj.extend(module, ...) -> obj
2534
+ # -->
2535
+ # Adds to *obj* the instance methods from each module given as a parameter.
2536
+ #
2537
+ # module Mod
2538
+ # def hello
2539
+ # "Hello from Mod.\n"
2540
+ # end
2541
+ # end
2542
+ #
2543
+ # class Klass
2544
+ # def hello
2545
+ # "Hello from Klass.\n"
2546
+ # end
2547
+ # end
2548
+ #
2549
+ # k = Klass.new
2550
+ # k.hello #=> "Hello from Klass.\n"
2551
+ # k.extend(Mod) #=> #<Klass:0x401b3bc8>
2552
+ # k.hello #=> "Hello from Mod.\n"
2553
+ #
2554
+ def extend: (Module module, *Module other_modules) -> self
2555
+
2556
+ # <!--
2557
+ # rdoc-file=object.c
2558
+ # - obj.freeze -> obj
2559
+ # -->
2560
+ # Prevents further modifications to *obj*. A FrozenError will be raised if
2561
+ # modification is attempted. There is no way to unfreeze a frozen object. See
2562
+ # also Object#frozen?.
2563
+ #
2564
+ # This method returns self.
2565
+ #
2566
+ # a = [ "a", "b", "c" ]
2567
+ # a.freeze
2568
+ # a << "z"
2569
+ #
2570
+ # *produces:*
2571
+ #
2572
+ # prog.rb:3:in `<<': can't modify frozen Array (FrozenError)
2573
+ # from prog.rb:3
2574
+ #
2575
+ # Objects of the following classes are always frozen: Integer, Float, Symbol.
2576
+ #
2577
+ def freeze: () -> self
2578
+
2579
+ # <!--
2580
+ # rdoc-file=kernel.rb
2581
+ # - obj.frozen? -> true or false
2582
+ # -->
2583
+ # Returns the freeze status of *obj*.
2584
+ #
2585
+ # a = [ "a", "b", "c" ]
2586
+ # a.freeze #=> ["a", "b", "c"]
2587
+ # a.frozen? #=> true
2588
+ #
2589
+ def frozen?: () -> bool
2590
+
2591
+ # <!--
2592
+ # rdoc-file=object.c
2593
+ # - obj.hash -> integer
2594
+ # -->
2595
+ # Generates an Integer hash value for this object. This function must have the
2596
+ # property that `a.eql?(b)` implies `a.hash == b.hash`.
2597
+ #
2598
+ # The hash value is used along with #eql? by the Hash class to determine if two
2599
+ # objects reference the same hash key. Any hash value that exceeds the capacity
2600
+ # of an Integer will be truncated before being used.
2601
+ #
2602
+ # The hash value for an object may not be identical across invocations or
2603
+ # implementations of Ruby. If you need a stable identifier across Ruby
2604
+ # invocations and implementations you will need to generate one with a custom
2605
+ # method.
2606
+ #
2607
+ # Certain core classes such as Integer use built-in hash calculations and do not
2608
+ # call the #hash method when used as a hash key.
2609
+ #
2610
+ # When implementing your own #hash based on multiple values, the best practice
2611
+ # is to combine the class and any values using the hash code of an array:
2612
+ #
2613
+ # For example:
2614
+ #
2615
+ # def hash
2616
+ # [self.class, a, b, c].hash
2617
+ # end
2618
+ #
2619
+ # The reason for this is that the Array#hash method already has logic for safely
2620
+ # and efficiently combining multiple hash values.
2621
+ #
2622
+ def hash: () -> Integer
2623
+
2624
+ # <!--
2625
+ # rdoc-file=object.c
2626
+ # - obj.inspect -> string
2627
+ # -->
2628
+ # Returns a string containing a human-readable representation of *obj*. The
2629
+ # default #inspect shows the object's class name, an encoding of its memory
2630
+ # address, and a list of the instance variables and their values (by calling
2631
+ # #inspect on each of them). User defined classes should override this method
2632
+ # to provide a better representation of *obj*. When overriding this method, it
2633
+ # should return a string whose encoding is compatible with the default external
2634
+ # encoding.
2635
+ #
2636
+ # [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
2637
+ # Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
2638
+ #
2639
+ # class Foo
2640
+ # end
2641
+ # Foo.new.inspect #=> "#<Foo:0x0300c868>"
2642
+ #
2643
+ # class Bar
2644
+ # def initialize
2645
+ # @bar = 1
2646
+ # end
2647
+ # end
2648
+ # Bar.new.inspect #=> "#<Bar:0x0300c868 @bar=1>"
2649
+ #
2650
+ def inspect: () -> String
2651
+
2652
+ # <!--
2653
+ # rdoc-file=object.c
2654
+ # - obj.instance_of?(class) -> true or false
2655
+ # -->
2656
+ # Returns `true` if *obj* is an instance of the given class. See also
2657
+ # Object#kind_of?.
2658
+ #
2659
+ # class A; end
2660
+ # class B < A; end
2661
+ # class C < B; end
2662
+ #
2663
+ # b = B.new
2664
+ # b.instance_of? A #=> false
2665
+ # b.instance_of? B #=> true
2666
+ # b.instance_of? C #=> false
2667
+ #
2668
+ def instance_of?: (Module | Class module_or_class) -> bool
2669
+
2670
+ # <!--
2671
+ # rdoc-file=object.c
2672
+ # - obj.instance_variable_defined?(symbol) -> true or false
2673
+ # - obj.instance_variable_defined?(string) -> true or false
2674
+ # -->
2675
+ # Returns `true` if the given instance variable is defined in *obj*. String
2676
+ # arguments are converted to symbols.
2677
+ #
2678
+ # class Fred
2679
+ # def initialize(p1, p2)
2680
+ # @a, @b = p1, p2
2681
+ # end
2682
+ # end
2683
+ # fred = Fred.new('cat', 99)
2684
+ # fred.instance_variable_defined?(:@a) #=> true
2685
+ # fred.instance_variable_defined?("@b") #=> true
2686
+ # fred.instance_variable_defined?("@c") #=> false
2687
+ #
2688
+ def instance_variable_defined?: (interned variable) -> bool
2689
+
2690
+ # <!--
2691
+ # rdoc-file=object.c
2692
+ # - obj.instance_variable_get(symbol) -> obj
2693
+ # - obj.instance_variable_get(string) -> obj
2694
+ # -->
2695
+ # Returns the value of the given instance variable, or nil if the instance
2696
+ # variable is not set. The `@` part of the variable name should be included for
2697
+ # regular instance variables. Throws a NameError exception if the supplied
2698
+ # symbol is not valid as an instance variable name. String arguments are
2699
+ # converted to symbols.
2700
+ #
2701
+ # class Fred
2702
+ # def initialize(p1, p2)
2703
+ # @a, @b = p1, p2
2704
+ # end
2705
+ # end
2706
+ # fred = Fred.new('cat', 99)
2707
+ # fred.instance_variable_get(:@a) #=> "cat"
2708
+ # fred.instance_variable_get("@b") #=> 99
2709
+ #
2710
+ def instance_variable_get: (interned variable) -> untyped
2711
+
2712
+ # <!--
2713
+ # rdoc-file=object.c
2714
+ # - obj.instance_variable_set(symbol, obj) -> obj
2715
+ # - obj.instance_variable_set(string, obj) -> obj
2716
+ # -->
2717
+ # Sets the instance variable named by *symbol* to the given object. This may
2718
+ # circumvent the encapsulation intended by the author of the class, so it should
2719
+ # be used with care. The variable does not have to exist prior to this call. If
2720
+ # the instance variable name is passed as a string, that string is converted to
2721
+ # a symbol.
2722
+ #
2723
+ # class Fred
2724
+ # def initialize(p1, p2)
2725
+ # @a, @b = p1, p2
2726
+ # end
2727
+ # end
2728
+ # fred = Fred.new('cat', 99)
2729
+ # fred.instance_variable_set(:@a, 'dog') #=> "dog"
2730
+ # fred.instance_variable_set(:@c, 'cat') #=> "cat"
2731
+ # fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
2732
+ #
2733
+ def instance_variable_set: [T] (interned variable, T value) -> T
2734
+
2735
+ # <!--
2736
+ # rdoc-file=object.c
2737
+ # - obj.instance_variables -> array
2738
+ # -->
2739
+ # Returns an array of instance variable names for the receiver. Note that simply
2740
+ # defining an accessor does not create the corresponding instance variable.
2741
+ #
2742
+ # class Fred
2743
+ # attr_accessor :a1
2744
+ # def initialize
2745
+ # @iv = 3
2746
+ # end
2747
+ # end
2748
+ # Fred.new.instance_variables #=> [:@iv]
2749
+ #
2750
+ def instance_variables: () -> Array[Symbol]
2751
+
2752
+ # <!-- rdoc-file=object.c -->
2753
+ # Returns `true` if *class* is the class of *obj*, or if *class* is one of the
2754
+ # superclasses of *obj* or modules included in *obj*.
2755
+ #
2756
+ # module M; end
2757
+ # class A
2758
+ # include M
2759
+ # end
2760
+ # class B < A; end
2761
+ # class C < B; end
2762
+ #
2763
+ # b = B.new
2764
+ # b.is_a? A #=> true
2765
+ # b.is_a? B #=> true
2766
+ # b.is_a? C #=> false
2767
+ # b.is_a? M #=> true
2768
+ #
2769
+ # b.kind_of? A #=> true
2770
+ # b.kind_of? B #=> true
2771
+ # b.kind_of? C #=> false
2772
+ # b.kind_of? M #=> true
2773
+ #
2774
+ def is_a?: (Module | Class module_or_class) -> bool
2775
+
2776
+ alias kind_of? is_a?
2777
+
2778
+ # <!--
2779
+ # rdoc-file=object.c
2780
+ # - obj.itself -> obj
2781
+ # -->
2782
+ # Returns the receiver.
2783
+ #
2784
+ # string = "my string"
2785
+ # string.itself.object_id == string.object_id #=> true
2786
+ #
2787
+ def itself: () -> self
2788
+
2789
+ # <!--
2790
+ # rdoc-file=proc.c
2791
+ # - obj.method(sym) -> method
2792
+ # -->
2793
+ # Looks up the named method as a receiver in *obj*, returning a Method object
2794
+ # (or raising NameError). The Method object acts as a closure in *obj*'s object
2795
+ # instance, so instance variables and the value of `self` remain available.
2796
+ #
2797
+ # class Demo
2798
+ # def initialize(n)
2799
+ # @iv = n
2800
+ # end
2801
+ # def hello()
2802
+ # "Hello, @iv = #{@iv}"
2803
+ # end
2804
+ # end
2805
+ #
2806
+ # k = Demo.new(99)
2807
+ # m = k.method(:hello)
2808
+ # m.call #=> "Hello, @iv = 99"
2809
+ #
2810
+ # l = Demo.new('Fred')
2811
+ # m = l.method("hello")
2812
+ # m.call #=> "Hello, @iv = Fred"
2813
+ #
2814
+ # Note that Method implements `to_proc` method, which means it can be used with
2815
+ # iterators.
2816
+ #
2817
+ # [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
2818
+ #
2819
+ # out = File.open('test.txt', 'w')
2820
+ # [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
2821
+ #
2822
+ # require 'date'
2823
+ # %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
2824
+ # #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
2825
+ #
2826
+ def method: (interned name) -> Method
2827
+
2828
+ # <!--
2829
+ # rdoc-file=object.c
2830
+ # - obj.methods(regular=true) -> array
2831
+ # -->
2832
+ # Returns a list of the names of public and protected methods of *obj*. This
2833
+ # will include all the methods accessible in *obj*'s ancestors. If the optional
2834
+ # parameter is `false`, it returns an array of *obj*'s public and protected
2835
+ # singleton methods, the array will not include methods in modules included in
2836
+ # *obj*.
2837
+ #
2838
+ # class Klass
2839
+ # def klass_method()
2840
+ # end
2841
+ # end
2842
+ # k = Klass.new
2843
+ # k.methods[0..9] #=> [:klass_method, :nil?, :===,
2844
+ # # :==~, :!, :eql?
2845
+ # # :hash, :<=>, :class, :singleton_class]
2846
+ # k.methods.length #=> 56
2847
+ #
2848
+ # k.methods(false) #=> []
2849
+ # def k.singleton_method; end
2850
+ # k.methods(false) #=> [:singleton_method]
2851
+ #
2852
+ # module M123; def m123; end end
2853
+ # k.extend M123
2854
+ # k.methods(false) #=> [:singleton_method]
2855
+ #
2856
+ def methods: (?boolish regular) -> Array[Symbol]
2857
+
2858
+ # <!--
2859
+ # rdoc-file=object.c
2860
+ # - obj.nil? -> true or false
2861
+ # -->
2862
+ # Only the object *nil* responds `true` to `nil?`.
2863
+ #
2864
+ # Object.new.nil? #=> false
2865
+ # nil.nil? #=> true
2866
+ #
2867
+ def nil?: () -> false
2868
+
2869
+ # <!--
2870
+ # rdoc-file=gc.c
2871
+ # - obj.__id__ -> integer
2872
+ # - obj.object_id -> integer
2873
+ # -->
2874
+ # Returns an integer identifier for `obj`.
2875
+ #
2876
+ # The same number will be returned on all calls to `object_id` for a given
2877
+ # object, and no two active objects will share an id.
2878
+ #
2879
+ # Note: that some objects of builtin classes are reused for optimization. This
2880
+ # is the case for immediate values and frozen string literals.
2881
+ #
2882
+ # BasicObject implements +__id__+, Kernel implements `object_id`.
2883
+ #
2884
+ # Immediate values are not passed by reference but are passed by value: `nil`,
2885
+ # `true`, `false`, Fixnums, Symbols, and some Floats.
2886
+ #
2887
+ # Object.new.object_id == Object.new.object_id # => false
2888
+ # (21 * 2).object_id == (21 * 2).object_id # => true
2889
+ # "hello".object_id == "hello".object_id # => false
2890
+ # "hi".freeze.object_id == "hi".freeze.object_id # => true
2891
+ #
2892
+ alias object_id __id__
2893
+
2894
+ # <!--
2895
+ # rdoc-file=object.c
2896
+ # - obj.private_methods(all=true) -> array
2897
+ # -->
2898
+ # Returns the list of private methods accessible to *obj*. If the *all*
2899
+ # parameter is set to `false`, only those methods in the receiver will be
2900
+ # listed.
2901
+ #
2902
+ def private_methods: (?boolish all) -> Array[Symbol]
2903
+
2904
+ # <!--
2905
+ # rdoc-file=object.c
2906
+ # - obj.protected_methods(all=true) -> array
2907
+ # -->
2908
+ # Returns the list of protected methods accessible to *obj*. If the *all*
2909
+ # parameter is set to `false`, only those methods in the receiver will be
2910
+ # listed.
2911
+ #
2912
+ def protected_methods: (?boolish all) -> Array[Symbol]
2913
+
2914
+ # <!--
2915
+ # rdoc-file=proc.c
2916
+ # - obj.public_method(sym) -> method
2917
+ # -->
2918
+ # Similar to *method*, searches public method only.
2919
+ #
2920
+ def public_method: (interned name) -> Method
2921
+
2922
+ # <!--
2923
+ # rdoc-file=object.c
2924
+ # - obj.public_methods(all=true) -> array
2925
+ # -->
2926
+ # Returns the list of public methods accessible to *obj*. If the *all* parameter
2927
+ # is set to `false`, only those methods in the receiver will be listed.
2928
+ #
2929
+ def public_methods: (?boolish all) -> Array[Symbol]
2930
+
2931
+ # <!--
2932
+ # rdoc-file=vm_eval.c
2933
+ # - obj.public_send(symbol [, args...]) -> obj
2934
+ # - obj.public_send(string [, args...]) -> obj
2935
+ # -->
2936
+ # Invokes the method identified by *symbol*, passing it any arguments specified.
2937
+ # Unlike send, public_send calls public methods only. When the method is
2938
+ # identified by a string, the string is converted to a symbol.
2939
+ #
2940
+ # 1.public_send(:puts, "hello") # causes NoMethodError
2941
+ #
2942
+ def public_send: (interned name, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
2943
+
2944
+ # <!--
2945
+ # rdoc-file=object.c
2946
+ # - obj.remove_instance_variable(symbol) -> obj
2947
+ # - obj.remove_instance_variable(string) -> obj
2948
+ # -->
2949
+ # Removes the named instance variable from *obj*, returning that variable's
2950
+ # value. String arguments are converted to symbols.
2951
+ #
2952
+ # class Dummy
2953
+ # attr_reader :var
2954
+ # def initialize
2955
+ # @var = 99
2956
+ # end
2957
+ # def remove
2958
+ # remove_instance_variable(:@var)
2959
+ # end
2960
+ # end
2961
+ # d = Dummy.new
2962
+ # d.var #=> 99
2963
+ # d.remove #=> 99
2964
+ # d.var #=> nil
2965
+ #
2966
+ def remove_instance_variable: (interned variable) -> untyped
2967
+
2968
+ # <!--
2969
+ # rdoc-file=vm_method.c
2970
+ # - obj.respond_to?(symbol, include_all=false) -> true or false
2971
+ # - obj.respond_to?(string, include_all=false) -> true or false
2972
+ # -->
2973
+ # Returns `true` if *obj* responds to the given method. Private and protected
2974
+ # methods are included in the search only if the optional second parameter
2975
+ # evaluates to `true`.
2976
+ #
2977
+ # If the method is not implemented, as Process.fork on Windows, File.lchmod on
2978
+ # GNU/Linux, etc., false is returned.
2979
+ #
2980
+ # If the method is not defined, `respond_to_missing?` method is called and the
2981
+ # result is returned.
2982
+ #
2983
+ # When the method name parameter is given as a string, the string is converted
2984
+ # to a symbol.
2985
+ #
2986
+ def respond_to?: (interned name, ?boolish include_all) -> bool
2987
+
2988
+ # <!--
2989
+ # rdoc-file=vm_method.c
2990
+ # - obj.respond_to_missing?(symbol, include_all) -> true or false
2991
+ # - obj.respond_to_missing?(string, include_all) -> true or false
2992
+ # -->
2993
+ # DO NOT USE THIS DIRECTLY.
2994
+ #
2995
+ # Hook method to return whether the *obj* can respond to *id* method or not.
2996
+ #
2997
+ # When the method name parameter is given as a string, the string is converted
2998
+ # to a symbol.
2999
+ #
3000
+ # See #respond_to?, and the example of BasicObject.
3001
+ #
3002
+ private def respond_to_missing?: (Symbol | String name, bool include_all) -> bool
3003
+
3004
+ # <!--
3005
+ # rdoc-file=vm_eval.c
3006
+ # - foo.send(symbol [, args...]) -> obj
3007
+ # - foo.__send__(symbol [, args...]) -> obj
3008
+ # - foo.send(string [, args...]) -> obj
3009
+ # - foo.__send__(string [, args...]) -> obj
3010
+ # -->
3011
+ # Invokes the method identified by *symbol*, passing it any arguments specified.
3012
+ # When the method is identified by a string, the string is converted to a
3013
+ # symbol.
3014
+ #
3015
+ # BasicObject implements +__send__+, Kernel implements `send`. `__send__` is
3016
+ # safer than `send` when *obj* has the same method name like `Socket`. See also
3017
+ # `public_send`.
3018
+ #
3019
+ # class Klass
3020
+ # def hello(*args)
3021
+ # "Hello " + args.join(' ')
3022
+ # end
3023
+ # end
3024
+ # k = Klass.new
3025
+ # k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
3026
+ #
3027
+ alias send __send__
3028
+
3029
+ # <!--
3030
+ # rdoc-file=object.c
3031
+ # - obj.singleton_class -> class
3032
+ # -->
3033
+ # Returns the singleton class of *obj*. This method creates a new singleton
3034
+ # class if *obj* does not have one.
3035
+ #
3036
+ # If *obj* is `nil`, `true`, or `false`, it returns NilClass, TrueClass, or
3037
+ # FalseClass, respectively. If *obj* is an Integer, a Float or a Symbol, it
3038
+ # raises a TypeError.
3039
+ #
3040
+ # Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
3041
+ # String.singleton_class #=> #<Class:String>
3042
+ # nil.singleton_class #=> NilClass
3043
+ #
3044
+ def singleton_class: () -> Class
3045
+
3046
+ # <!--
3047
+ # rdoc-file=proc.c
3048
+ # - obj.singleton_method(sym) -> method
3049
+ # -->
3050
+ # Similar to *method*, searches singleton method only.
3051
+ #
3052
+ # class Demo
3053
+ # def initialize(n)
3054
+ # @iv = n
3055
+ # end
3056
+ # def hello()
3057
+ # "Hello, @iv = #{@iv}"
3058
+ # end
3059
+ # end
3060
+ #
3061
+ # k = Demo.new(99)
3062
+ # def k.hi
3063
+ # "Hi, @iv = #{@iv}"
3064
+ # end
3065
+ # m = k.singleton_method(:hi)
3066
+ # m.call #=> "Hi, @iv = 99"
3067
+ # m = k.singleton_method(:hello) #=> NameError
3068
+ #
3069
+ def singleton_method: (interned name) -> Method
3070
+
3071
+ # <!--
3072
+ # rdoc-file=object.c
3073
+ # - obj.singleton_methods(all=true) -> array
3074
+ # -->
3075
+ # Returns an array of the names of singleton methods for *obj*. If the optional
3076
+ # *all* parameter is true, the list will include methods in modules included in
3077
+ # *obj*. Only public and protected singleton methods are returned.
3078
+ #
3079
+ # module Other
3080
+ # def three() end
3081
+ # end
3082
+ #
3083
+ # class Single
3084
+ # def Single.four() end
3085
+ # end
3086
+ #
3087
+ # a = Single.new
3088
+ #
3089
+ # def a.one()
3090
+ # end
3091
+ #
3092
+ # class << a
3093
+ # include Other
3094
+ # def two()
3095
+ # end
3096
+ # end
3097
+ #
3098
+ # Single.singleton_methods #=> [:four]
3099
+ # a.singleton_methods(false) #=> [:two, :one]
3100
+ # a.singleton_methods #=> [:two, :one, :three]
3101
+ #
3102
+ def singleton_methods: (?boolish all) -> Array[Symbol]
3103
+
3104
+ # <!--
3105
+ # rdoc-file=kernel.rb
3106
+ # - obj.tap {|x| block } -> obj
3107
+ # -->
3108
+ # Yields self to the block and then returns self. The primary purpose of this
3109
+ # method is to "tap into" a method chain, in order to perform operations on
3110
+ # intermediate results within the chain.
3111
+ #
3112
+ # (1..10) .tap {|x| puts "original: #{x}" }
3113
+ # .to_a .tap {|x| puts "array: #{x}" }
3114
+ # .select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
3115
+ # .map {|x| x*x } .tap {|x| puts "squares: #{x}" }
3116
+ #
3117
+ def tap: () { (self) -> void } -> self
3118
+
3119
+ # <!--
3120
+ # rdoc-file=object.c
3121
+ # - obj.to_s -> string
3122
+ # -->
3123
+ # Returns a string representing *obj*. The default #to_s prints the object's
3124
+ # class and an encoding of the object id. As a special case, the top-level
3125
+ # object that is the initial execution context of Ruby programs returns
3126
+ # ``main''.
3127
+ #
3128
+ def to_s: () -> String
3129
+
3130
+ # <!--
3131
+ # rdoc-file=kernel.rb
3132
+ # - yield_self()
3133
+ # -->
3134
+ #
3135
+ def yield_self: () -> Enumerator[self, untyped]
3136
+ | [T] () { (self) -> T } -> T
3137
+
3138
+ # <!--
3139
+ # rdoc-file=kernel.rb
3140
+ # - obj.then {|x| block } -> an_object
3141
+ # -->
3142
+ # Yields self to the block and returns the result of the block.
3143
+ #
3144
+ # 3.next.then {|x| x**x }.to_s #=> "256"
3145
+ #
3146
+ # A good use of `then` is value piping in method chains:
3147
+ #
3148
+ # require 'open-uri'
3149
+ # require 'json'
3150
+ #
3151
+ # construct_url(arguments)
3152
+ # .then {|url| URI(url).read }
3153
+ # .then {|response| JSON.parse(response) }
3154
+ #
3155
+ # When called without a block, the method returns an `Enumerator`, which can be
3156
+ # used, for example, for conditional circuit-breaking:
3157
+ #
3158
+ # # Meets condition, no-op
3159
+ # 1.then.detect(&:odd?) # => 1
3160
+ # # Does not meet condition, drop value
3161
+ # 2.then.detect(&:odd?) # => nil
3162
+ #
3163
+ alias then yield_self
3164
+
3165
+ private
3166
+
3167
+ def initialize_copy: (self object) -> self
3168
+
3169
+ def initialize_clone: (self object, ?freeze: bool?) -> self
3170
+
3171
+ def initialize_dup: (self object) -> self
3172
+ end