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/range.rbs ADDED
@@ -0,0 +1,1209 @@
1
+ # <!-- rdoc-file=range.c -->
2
+ # A Range object represents a collection of values that are between given begin
3
+ # and end values.
4
+ #
5
+ # You can create an Range object explicitly with:
6
+ #
7
+ # * A [range literal](rdoc-ref:syntax/literals.rdoc@Range+Literals):
8
+ #
9
+ # # Ranges that use '..' to include the given end value.
10
+ # (1..4).to_a # => [1, 2, 3, 4]
11
+ # ('a'..'d').to_a # => ["a", "b", "c", "d"]
12
+ # # Ranges that use '...' to exclude the given end value.
13
+ # (1...4).to_a # => [1, 2, 3]
14
+ # ('a'...'d').to_a # => ["a", "b", "c"]
15
+ #
16
+ # * Method Range.new:
17
+ #
18
+ # # Ranges that by default include the given end value. Range.new(1, 4).to_a
19
+ # # => [1, 2, 3, 4] Range.new('a', 'd').to_a # => ["a", "b", "c", "d"] #
20
+ # Ranges that use third argument `exclude_end` to exclude the given end
21
+ # value. Range.new(1, 4, true).to_a # => [1, 2, 3] Range.new('a', 'd',
22
+ # true).to_a # => ["a", "b", "c"]
23
+ #
24
+ # ## Beginless Ranges
25
+ #
26
+ # A *beginless* *range* has a definite end value, but a `nil` begin value. Such
27
+ # a range includes all values up to the end value.
28
+ #
29
+ # r = (..4) # => nil..4
30
+ # r.begin # => nil
31
+ # r.include?(-50) # => true
32
+ # r.include?(4) # => true
33
+ #
34
+ # r = (...4) # => nil...4
35
+ # r.include?(4) # => false
36
+ #
37
+ # Range.new(nil, 4) # => nil..4
38
+ # Range.new(nil, 4, true) # => nil...4
39
+ #
40
+ # A beginless range may be used to slice an array:
41
+ #
42
+ # a = [1, 2, 3, 4]
43
+ # # Include the third array element in the slice
44
+ # r = (..2) # => nil..2
45
+ # a[r] # => [1, 2, 3]
46
+ # # Exclude the third array element from the slice
47
+ # r = (...2) # => nil...2
48
+ # a[r] # => [1, 2]
49
+ #
50
+ # Method `each` for a beginless range raises an exception.
51
+ #
52
+ # ## Endless Ranges
53
+ #
54
+ # An *endless* *range* has a definite begin value, but a `nil` end value. Such a
55
+ # range includes all values from the begin value.
56
+ #
57
+ # r = (1..) # => 1..
58
+ # r.end # => nil
59
+ # r.include?(50) # => true
60
+ #
61
+ # Range.new(1, nil) # => 1..
62
+ #
63
+ # The literal for an endless range may be written with either two dots or three.
64
+ # The range has the same elements, either way. But note that the two are not
65
+ # equal:
66
+ #
67
+ # r0 = (1..) # => 1..
68
+ # r1 = (1...) # => 1...
69
+ # r0.begin == r1.begin # => true
70
+ # r0.end == r1.end # => true
71
+ # r0 == r1 # => false
72
+ #
73
+ # An endless range may be used to slice an array:
74
+ #
75
+ # a = [1, 2, 3, 4]
76
+ # r = (2..) # => 2..
77
+ # a[r] # => [3, 4]
78
+ #
79
+ # Method `each` for an endless range calls the given block indefinitely:
80
+ #
81
+ # a = []
82
+ # r = (1..)
83
+ # r.each do |i|
84
+ # a.push(i) if i.even?
85
+ # break if i > 10
86
+ # end
87
+ # a # => [2, 4, 6, 8, 10]
88
+ #
89
+ # A range can be both beginless and endless. For literal beginless, endless
90
+ # ranges, at least the beginning or end of the range must be given as an
91
+ # explicit nil value. It is recommended to use an explicit nil beginning and
92
+ # end, since that is what Ruby uses for Range#inspect:
93
+ #
94
+ # (nil..) # => (nil..nil)
95
+ # (..nil) # => (nil..nil)
96
+ # (nil..nil) # => (nil..nil)
97
+ #
98
+ # ## Ranges and Other Classes
99
+ #
100
+ # An object may be put into a range if its class implements instance method
101
+ # <code>#<=></code>. Ruby core classes that do so include Array, Complex,
102
+ # File::Stat, Float, Integer, Kernel, Module, Numeric, Rational, String, Symbol,
103
+ # and Time.
104
+ #
105
+ # Example:
106
+ #
107
+ # t0 = Time.now # => 2021-09-19 09:22:48.4854986 -0500
108
+ # t1 = Time.now # => 2021-09-19 09:22:56.0365079 -0500
109
+ # t2 = Time.now # => 2021-09-19 09:23:08.5263283 -0500
110
+ # (t0..t2).include?(t1) # => true
111
+ # (t0..t1).include?(t2) # => false
112
+ #
113
+ # A range can be iterated over only if its elements implement instance method
114
+ # `succ`. Ruby core classes that do so include Integer, String, and Symbol (but
115
+ # not the other classes mentioned above).
116
+ #
117
+ # Iterator methods include:
118
+ #
119
+ # * In Range itself: #each, #step, and #%
120
+ # * Included from module Enumerable: #each_entry, #each_with_index,
121
+ # #each_with_object, #each_slice, #each_cons, and #reverse_each.
122
+ #
123
+ # Example:
124
+ #
125
+ # a = []
126
+ # (1..4).each {|i| a.push(i) }
127
+ # a # => [1, 2, 3, 4]
128
+ #
129
+ # ## Ranges and User-Defined Classes
130
+ #
131
+ # A user-defined class that is to be used in a range must implement instance
132
+ # method <code>#<=></code>; see Integer#<=>. To make iteration available, it
133
+ # must also implement instance method `succ`; see Integer#succ.
134
+ #
135
+ # The class below implements both <code>#<=></code> and `succ`, and so can be
136
+ # used both to construct ranges and to iterate over them. Note that the
137
+ # Comparable module is included so the <code>==</code> method is defined in
138
+ # terms of <code>#<=></code>.
139
+ #
140
+ # # Represent a string of 'X' characters.
141
+ # class Xs
142
+ # include Comparable
143
+ # attr_accessor :length
144
+ # def initialize(n)
145
+ # @length = n
146
+ # end
147
+ # def succ
148
+ # Xs.new(@length + 1)
149
+ # end
150
+ # def <=>(other)
151
+ # @length <=> other.length
152
+ # end
153
+ # def to_s
154
+ # sprintf "%2d #{inspect}", @length
155
+ # end
156
+ # def inspect
157
+ # 'X' * @length
158
+ # end
159
+ # end
160
+ #
161
+ # r = Xs.new(3)..Xs.new(6) #=> XXX..XXXXXX
162
+ # r.to_a #=> [XXX, XXXX, XXXXX, XXXXXX]
163
+ # r.include?(Xs.new(5)) #=> true
164
+ # r.include?(Xs.new(7)) #=> false
165
+ #
166
+ # ## What's Here
167
+ #
168
+ # First, what's elsewhere. Class Range:
169
+ #
170
+ # * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
171
+ # * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
172
+ # provides dozens of additional methods.
173
+ #
174
+ # Here, class Range provides methods that are useful for:
175
+ #
176
+ # * [Creating a Range](rdoc-ref:Range@Methods+for+Creating+a+Range)
177
+ # * [Querying](rdoc-ref:Range@Methods+for+Querying)
178
+ # * [Comparing](rdoc-ref:Range@Methods+for+Comparing)
179
+ # * [Iterating](rdoc-ref:Range@Methods+for+Iterating)
180
+ # * [Converting](rdoc-ref:Range@Methods+for+Converting)
181
+ # * [Methods for Working with
182
+ # JSON](rdoc-ref:Range@Methods+for+Working+with+JSON)
183
+ #
184
+ # ### Methods for Creating a Range
185
+ #
186
+ # * ::new: Returns a new range.
187
+ #
188
+ # ### Methods for Querying
189
+ #
190
+ # * #begin: Returns the begin value given for `self`.
191
+ # * #bsearch: Returns an element from `self` selected by a binary search.
192
+ # * #count: Returns a count of elements in `self`.
193
+ # * #end: Returns the end value given for `self`.
194
+ # * #exclude_end?: Returns whether the end object is excluded.
195
+ # * #first: Returns the first elements of `self`.
196
+ # * #hash: Returns the integer hash code.
197
+ # * #last: Returns the last elements of `self`.
198
+ # * #max: Returns the maximum values in `self`.
199
+ # * #min: Returns the minimum values in `self`.
200
+ # * #minmax: Returns the minimum and maximum values in `self`.
201
+ # * #size: Returns the count of elements in `self`.
202
+ #
203
+ # ### Methods for Comparing
204
+ #
205
+ # * #==: Returns whether a given object is equal to `self` (uses #==).
206
+ # * #===: Returns whether the given object is between the begin and end
207
+ # values.
208
+ # * #cover?: Returns whether a given object is within `self`.
209
+ # * #eql?: Returns whether a given object is equal to `self` (uses #eql?).
210
+ # * #include? (aliased as #member?): Returns whether a given object is an
211
+ # element of `self`.
212
+ #
213
+ # ### Methods for Iterating
214
+ #
215
+ # * #%: Requires argument `n`; calls the block with each `n`-th element of
216
+ # `self`.
217
+ # * #each: Calls the block with each element of `self`.
218
+ # * #step: Takes optional argument `n` (defaults to 1); calls the block with
219
+ # each `n`-th element of `self`.
220
+ #
221
+ # ### Methods for Converting
222
+ #
223
+ # * #inspect: Returns a string representation of `self` (uses #inspect).
224
+ # * #to_a (aliased as #entries): Returns elements of `self` in an array.
225
+ # * #to_s: Returns a string representation of `self` (uses #to_s).
226
+ #
227
+ # ### Methods for Working with JSON
228
+ #
229
+ # * ::json_create: Returns a new Range object constructed from the given
230
+ # object.
231
+ # * #as_json: Returns a 2-element hash representing `self`.
232
+ # * #to_json: Returns a JSON string representing `self`.
233
+ #
234
+ # To make these methods available:
235
+ #
236
+ # require 'json/add/range'
237
+ #
238
+ class Range[out E] < Object
239
+ include Enumerable[E]
240
+
241
+ # <!--
242
+ # rdoc-file=range.c
243
+ # - %(n) {|element| ... } -> self
244
+ # - %(n) -> enumerator or arithmetic_sequence
245
+ # -->
246
+ # Same as #step (but doesn't provide default value for `n`). The method is
247
+ # convenient for experssive producing of Enumerator::ArithmeticSequence.
248
+ #
249
+ # array = [0, 1, 2, 3, 4, 5, 6]
250
+ #
251
+ # # slice each second element:
252
+ # seq = (0..) % 2 #=> ((0..).%(2))
253
+ # array[seq] #=> [0, 2, 4, 6]
254
+ # # or just
255
+ # array[(0..) % 2] #=> [0, 2, 4, 6]
256
+ #
257
+ # Note that due to operator precedence in Ruby, parentheses are mandatory around
258
+ # range in this case:
259
+ #
260
+ # (0..7) % 2 #=> ((0..7).%(2)) -- as expected
261
+ # 0..7 % 2 #=> 0..1 -- parsed as 0..(7 % 2)
262
+ #
263
+ def %: (Numeric | int n) -> Enumerator[E, self]
264
+ | (Numeric | int n) { (E element) -> void } -> self
265
+
266
+ # <!--
267
+ # rdoc-file=range.c
268
+ # - self == other -> true or false
269
+ # -->
270
+ # Returns `true` if and only if:
271
+ #
272
+ # * `other` is a range.
273
+ # * <code>other.begin == self.begin</code>.
274
+ # * <code>other.end == self.end</code>.
275
+ # * <code>other.exclude_end? == self.exclude_end?</code>.
276
+ #
277
+ # Otherwise returns `false`.
278
+ #
279
+ # r = (1..5)
280
+ # r == (1..5) # => true
281
+ # r = Range.new(1, 5)
282
+ # r == 'foo' # => false
283
+ # r == (2..5) # => false
284
+ # r == (1..4) # => false
285
+ # r == (1...5) # => false
286
+ # r == Range.new(1, 5, true) # => false
287
+ #
288
+ # Note that even with the same argument, the return values of #== and #eql? can
289
+ # differ:
290
+ #
291
+ # (1..2) == (1..2.0) # => true
292
+ # (1..2).eql? (1..2.0) # => false
293
+ #
294
+ # Related: Range#eql?.
295
+ #
296
+ def ==: (untyped obj) -> bool
297
+
298
+ # <!--
299
+ # rdoc-file=range.c
300
+ # - self === object -> true or false
301
+ # -->
302
+ # Returns `true` if `object` is between <code>self.begin</code> and
303
+ # <code>self.end</code>. `false` otherwise:
304
+ #
305
+ # (1..4) === 2 # => true
306
+ # (1..4) === 5 # => false
307
+ # (1..4) === 'a' # => false
308
+ # (1..4) === 4 # => true
309
+ # (1...4) === 4 # => false
310
+ # ('a'..'d') === 'c' # => true
311
+ # ('a'..'d') === 'e' # => false
312
+ #
313
+ # A case statement uses method <code>===</code>, and so:
314
+ #
315
+ # case 79
316
+ # when (1..50)
317
+ # "low"
318
+ # when (51..75)
319
+ # "medium"
320
+ # when (76..100)
321
+ # "high"
322
+ # end # => "high"
323
+ #
324
+ # case "2.6.5"
325
+ # when ..."2.4"
326
+ # "EOL"
327
+ # when "2.4"..."2.5"
328
+ # "maintenance"
329
+ # when "2.5"..."3.0"
330
+ # "stable"
331
+ # when "3.1"..
332
+ # "upcoming"
333
+ # end # => "stable"
334
+ #
335
+ def ===: (untyped obj) -> bool
336
+
337
+ # <!--
338
+ # rdoc-file=range.c
339
+ # - self.begin -> object
340
+ # -->
341
+ # Returns the object that defines the beginning of `self`.
342
+ #
343
+ # (1..4).begin # => 1
344
+ # (..2).begin # => nil
345
+ #
346
+ # Related: Range#first, Range#end.
347
+ #
348
+ def begin: () -> E
349
+
350
+ # <!--
351
+ # rdoc-file=range.c
352
+ # - bsearch {|obj| block } -> value
353
+ # -->
354
+ # Returns an element from `self` selected by a binary search.
355
+ #
356
+ # See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
357
+ #
358
+ def bsearch: () -> ::Enumerator[E, E?]
359
+ | () { (E) -> (true | false) } -> E?
360
+ | () { (E) -> ::Integer } -> E?
361
+
362
+ # <!--
363
+ # rdoc-file=range.c
364
+ # - cover?(object) -> true or false
365
+ # - cover?(range) -> true or false
366
+ # -->
367
+ # Returns `true` if the given argument is within `self`, `false` otherwise.
368
+ #
369
+ # With non-range argument `object`, evaluates with <code><=</code> and
370
+ # <code><</code>.
371
+ #
372
+ # For range `self` with included end value (<code>#exclude_end? ==
373
+ # false</code>), evaluates thus:
374
+ #
375
+ # self.begin <= object <= self.end
376
+ #
377
+ # Examples:
378
+ #
379
+ # r = (1..4)
380
+ # r.cover?(1) # => true
381
+ # r.cover?(4) # => true
382
+ # r.cover?(0) # => false
383
+ # r.cover?(5) # => false
384
+ # r.cover?('foo') # => false
385
+ #
386
+ # r = ('a'..'d')
387
+ # r.cover?('a') # => true
388
+ # r.cover?('d') # => true
389
+ # r.cover?(' ') # => false
390
+ # r.cover?('e') # => false
391
+ # r.cover?(0) # => false
392
+ #
393
+ # For range `r` with excluded end value (<code>#exclude_end? == true</code>),
394
+ # evaluates thus:
395
+ #
396
+ # r.begin <= object < r.end
397
+ #
398
+ # Examples:
399
+ #
400
+ # r = (1...4)
401
+ # r.cover?(1) # => true
402
+ # r.cover?(3) # => true
403
+ # r.cover?(0) # => false
404
+ # r.cover?(4) # => false
405
+ # r.cover?('foo') # => false
406
+ #
407
+ # r = ('a'...'d')
408
+ # r.cover?('a') # => true
409
+ # r.cover?('c') # => true
410
+ # r.cover?(' ') # => false
411
+ # r.cover?('d') # => false
412
+ # r.cover?(0) # => false
413
+ #
414
+ # With range argument `range`, compares the first and last elements of `self`
415
+ # and `range`:
416
+ #
417
+ # r = (1..4)
418
+ # r.cover?(1..4) # => true
419
+ # r.cover?(0..4) # => false
420
+ # r.cover?(1..5) # => false
421
+ # r.cover?('a'..'d') # => false
422
+ #
423
+ # r = (1...4)
424
+ # r.cover?(1..3) # => true
425
+ # r.cover?(1..4) # => false
426
+ #
427
+ # If begin and end are numeric, #cover? behaves like #include?
428
+ #
429
+ # (1..3).cover?(1.5) # => true
430
+ # (1..3).include?(1.5) # => true
431
+ #
432
+ # But when not numeric, the two methods may differ:
433
+ #
434
+ # ('a'..'d').cover?('cc') # => true
435
+ # ('a'..'d').include?('cc') # => false
436
+ #
437
+ # Returns `false` if either:
438
+ #
439
+ # * The begin value of `self` is larger than its end value.
440
+ # * An internal call to <code>#<=></code> returns `nil`; that is, the operands
441
+ # are not comparable.
442
+ #
443
+ # Beginless ranges cover all values of the same type before the end, excluding
444
+ # the end for exclusive ranges. Beginless ranges cover ranges that end before
445
+ # the end of the beginless range, or at the end of the beginless range for
446
+ # inclusive ranges.
447
+ #
448
+ # (..2).cover?(1) # => true
449
+ # (..2).cover?(2) # => true
450
+ # (..2).cover?(3) # => false
451
+ # (...2).cover?(2) # => false
452
+ # (..2).cover?("2") # => false
453
+ # (..2).cover?(..2) # => true
454
+ # (..2).cover?(...2) # => true
455
+ # (..2).cover?(.."2") # => false
456
+ # (...2).cover?(..2) # => false
457
+ #
458
+ # Endless ranges cover all values of the same type after the beginning. Endless
459
+ # exclusive ranges do not cover endless inclusive ranges.
460
+ #
461
+ # (2..).cover?(1) # => false
462
+ # (2..).cover?(3) # => true
463
+ # (2...).cover?(3) # => true
464
+ # (2..).cover?(2) # => true
465
+ # (2..).cover?("2") # => false
466
+ # (2..).cover?(2..) # => true
467
+ # (2..).cover?(2...) # => true
468
+ # (2..).cover?("2"..) # => false
469
+ # (2...).cover?(2..) # => false
470
+ # (2...).cover?(3...) # => true
471
+ # (2...).cover?(3..) # => false
472
+ # (3..).cover?(2..) # => false
473
+ #
474
+ # Ranges that are both beginless and endless cover all values and ranges, and
475
+ # return true for all arguments, with the exception that beginless and endless
476
+ # exclusive ranges do not cover endless inclusive ranges.
477
+ #
478
+ # (nil...).cover?(Object.new) # => true
479
+ # (nil...).cover?(nil...) # => true
480
+ # (nil..).cover?(nil...) # => true
481
+ # (nil...).cover?(nil..) # => false
482
+ # (nil...).cover?(1..) # => false
483
+ #
484
+ # Related: Range#include?.
485
+ #
486
+ def cover?: (untyped obj) -> bool
487
+
488
+ # <!--
489
+ # rdoc-file=range.c
490
+ # - each {|element| ... } -> self
491
+ # - each -> an_enumerator
492
+ # -->
493
+ # With a block given, passes each element of `self` to the block:
494
+ #
495
+ # a = []
496
+ # (1..4).each {|element| a.push(element) } # => 1..4
497
+ # a # => [1, 2, 3, 4]
498
+ #
499
+ # Raises an exception unless <code>self.first.respond_to?(:succ)</code>.
500
+ #
501
+ # With no block given, returns an enumerator.
502
+ #
503
+ def each: () { (E arg0) -> untyped } -> self
504
+ | () -> ::Enumerator[E, self]
505
+
506
+ # <!--
507
+ # rdoc-file=range.c
508
+ # - self.end -> object
509
+ # -->
510
+ # Returns the object that defines the end of `self`.
511
+ #
512
+ # (1..4).end # => 4
513
+ # (1...4).end # => 4
514
+ # (1..).end # => nil
515
+ #
516
+ # Related: Range#begin, Range#last.
517
+ #
518
+ def end: () -> E
519
+
520
+ # <!--
521
+ # rdoc-file=range.c
522
+ # - exclude_end? -> true or false
523
+ # -->
524
+ # Returns `true` if `self` excludes its end value; `false` otherwise:
525
+ #
526
+ # Range.new(2, 5).exclude_end? # => false
527
+ # Range.new(2, 5, true).exclude_end? # => true
528
+ # (2..5).exclude_end? # => false
529
+ # (2...5).exclude_end? # => true
530
+ #
531
+ def exclude_end?: () -> bool
532
+
533
+ # <!--
534
+ # rdoc-file=range.c
535
+ # - first -> object
536
+ # - first(n) -> array
537
+ # -->
538
+ # With no argument, returns the first element of `self`, if it exists:
539
+ #
540
+ # (1..4).first # => 1
541
+ # ('a'..'d').first # => "a"
542
+ #
543
+ # With non-negative integer argument `n` given, returns the first `n` elements
544
+ # in an array:
545
+ #
546
+ # (1..10).first(3) # => [1, 2, 3]
547
+ # (1..10).first(0) # => []
548
+ # (1..4).first(50) # => [1, 2, 3, 4]
549
+ #
550
+ # Raises an exception if there is no first element:
551
+ #
552
+ # (..4).first # Raises RangeError
553
+ #
554
+ def first: () -> E
555
+ | (Integer n) -> ::Array[E]
556
+
557
+ # <!--
558
+ # rdoc-file=range.c
559
+ # - hash -> integer
560
+ # -->
561
+ # Returns the integer hash value for `self`. Two range objects `r0` and `r1`
562
+ # have the same hash value if and only if <code>r0.eql?(r1)</code>.
563
+ #
564
+ # Related: Range#eql?, Object#hash.
565
+ #
566
+ def hash: () -> Integer
567
+
568
+ # <!-- rdoc-file=range.c -->
569
+ # Returns `true` if `object` is an element of `self`, `false` otherwise:
570
+ #
571
+ # (1..4).include?(2) # => true
572
+ # (1..4).include?(5) # => false
573
+ # (1..4).include?(4) # => true
574
+ # (1...4).include?(4) # => false
575
+ # ('a'..'d').include?('b') # => true
576
+ # ('a'..'d').include?('e') # => false
577
+ # ('a'..'d').include?('B') # => false
578
+ # ('a'..'d').include?('d') # => true
579
+ # ('a'...'d').include?('d') # => false
580
+ #
581
+ # If begin and end are numeric, #include? behaves like #cover?
582
+ #
583
+ # (1..3).include?(1.5) # => true
584
+ # (1..3).cover?(1.5) # => true
585
+ #
586
+ # But when not numeric, the two methods may differ:
587
+ #
588
+ # ('a'..'d').include?('cc') # => false
589
+ # ('a'..'d').cover?('cc') # => true
590
+ #
591
+ # Related: Range#cover?.
592
+ #
593
+ def include?: (untyped obj) -> bool
594
+
595
+ # <!--
596
+ # rdoc-file=range.c
597
+ # - Range.new(begin, end, exclude_end = false) -> new_range
598
+ # -->
599
+ # Returns a new range based on the given objects `begin` and `end`. Optional
600
+ # argument `exclude_end` determines whether object `end` is included as the last
601
+ # object in the range:
602
+ #
603
+ # Range.new(2, 5).to_a # => [2, 3, 4, 5]
604
+ # Range.new(2, 5, true).to_a # => [2, 3, 4]
605
+ # Range.new('a', 'd').to_a # => ["a", "b", "c", "d"]
606
+ # Range.new('a', 'd', true).to_a # => ["a", "b", "c"]
607
+ #
608
+ def initialize: (E from, E to, ?boolish exclude_end) -> void
609
+
610
+ # <!--
611
+ # rdoc-file=range.c
612
+ # - inspect -> string
613
+ # -->
614
+ # Returns a string representation of `self`, including
615
+ # <code>begin.inspect</code> and <code>end.inspect</code>:
616
+ #
617
+ # (1..4).inspect # => "1..4"
618
+ # (1...4).inspect # => "1...4"
619
+ # (1..).inspect # => "1.."
620
+ # (..4).inspect # => "..4"
621
+ #
622
+ # Note that returns from #to_s and #inspect may differ:
623
+ #
624
+ # ('a'..'d').to_s # => "a..d"
625
+ # ('a'..'d').inspect # => "\"a\"..\"d\""
626
+ #
627
+ # Related: Range#to_s.
628
+ #
629
+ def inspect: () -> String
630
+
631
+ # <!--
632
+ # rdoc-file=range.c
633
+ # - last -> object
634
+ # - last(n) -> array
635
+ # -->
636
+ # With no argument, returns the last element of `self`, if it exists:
637
+ #
638
+ # (1..4).last # => 4
639
+ # ('a'..'d').last # => "d"
640
+ #
641
+ # Note that `last` with no argument returns the end element of `self` even if
642
+ # #exclude_end? is `true`:
643
+ #
644
+ # (1...4).last # => 4
645
+ # ('a'...'d').last # => "d"
646
+ #
647
+ # With non-negative integer argument `n` given, returns the last `n` elements in
648
+ # an array:
649
+ #
650
+ # (1..10).last(3) # => [8, 9, 10]
651
+ # (1..10).last(0) # => []
652
+ # (1..4).last(50) # => [1, 2, 3, 4]
653
+ #
654
+ # Note that `last` with argument does not return the end element of `self` if
655
+ # #exclude_end? it `true`:
656
+ #
657
+ # (1...4).last(3) # => [1, 2, 3]
658
+ # ('a'...'d').last(3) # => ["a", "b", "c"]
659
+ #
660
+ # Raises an exception if there is no last element:
661
+ #
662
+ # (1..).last # Raises RangeError
663
+ #
664
+ def last: () -> E
665
+ | (Integer n) -> ::Array[E]
666
+
667
+ # <!--
668
+ # rdoc-file=range.c
669
+ # - max -> object
670
+ # - max(n) -> array
671
+ # - max {|a, b| ... } -> object
672
+ # - max(n) {|a, b| ... } -> array
673
+ # -->
674
+ # Returns the maximum value in `self`, using method <code>#<=></code> or a given
675
+ # block for comparison.
676
+ #
677
+ # With no argument and no block given, returns the maximum-valued element of
678
+ # `self`.
679
+ #
680
+ # (1..4).max # => 4
681
+ # ('a'..'d').max # => "d"
682
+ # (-4..-1).max # => -1
683
+ #
684
+ # With non-negative integer argument `n` given, and no block given, returns the
685
+ # `n` maximum-valued elements of `self` in an array:
686
+ #
687
+ # (1..4).max(2) # => [4, 3]
688
+ # ('a'..'d').max(2) # => ["d", "c"]
689
+ # (-4..-1).max(2) # => [-1, -2]
690
+ # (1..4).max(50) # => [4, 3, 2, 1]
691
+ #
692
+ # If a block is given, it is called:
693
+ #
694
+ # * First, with the first two element of `self`.
695
+ # * Then, sequentially, with the so-far maximum value and the next element of
696
+ # `self`.
697
+ #
698
+ # To illustrate:
699
+ #
700
+ # (1..4).max {|a, b| p [a, b]; a <=> b } # => 4
701
+ #
702
+ # Output:
703
+ #
704
+ # [2, 1]
705
+ # [3, 2]
706
+ # [4, 3]
707
+ #
708
+ # With no argument and a block given, returns the return value of the last call
709
+ # to the block:
710
+ #
711
+ # (1..4).max {|a, b| -(a <=> b) } # => 1
712
+ #
713
+ # With non-negative integer argument `n` given, and a block given, returns the
714
+ # return values of the last `n` calls to the block in an array:
715
+ #
716
+ # (1..4).max(2) {|a, b| -(a <=> b) } # => [1, 2]
717
+ # (1..4).max(50) {|a, b| -(a <=> b) } # => [1, 2, 3, 4]
718
+ #
719
+ # Returns an empty array if `n` is zero:
720
+ #
721
+ # (1..4).max(0) # => []
722
+ # (1..4).max(0) {|a, b| -(a <=> b) } # => []
723
+ #
724
+ # Returns `nil` or an empty array if:
725
+ #
726
+ # * The begin value of the range is larger than the end value:
727
+ #
728
+ # (4..1).max # => nil
729
+ # (4..1).max(2) # => []
730
+ # (4..1).max {|a, b| -(a <=> b) } # => nil
731
+ # (4..1).max(2) {|a, b| -(a <=> b) } # => []
732
+ #
733
+ # * The begin value of an exclusive range is equal to the end value:
734
+ #
735
+ # (1...1).max # => nil
736
+ # (1...1).max(2) # => []
737
+ # (1...1).max {|a, b| -(a <=> b) } # => nil
738
+ # (1...1).max(2) {|a, b| -(a <=> b) } # => []
739
+ #
740
+ # Raises an exception if either:
741
+ #
742
+ # * `self` is a endless range: <code>(1..)</code>.
743
+ # * A block is given and `self` is a beginless range.
744
+ #
745
+ # Related: Range#min, Range#minmax.
746
+ #
747
+ def max: ...
748
+
749
+ # <!--
750
+ # rdoc-file=range.c
751
+ # - min -> object
752
+ # - min(n) -> array
753
+ # - min {|a, b| ... } -> object
754
+ # - min(n) {|a, b| ... } -> array
755
+ # -->
756
+ # Returns the minimum value in `self`, using method <code>#<=></code> or a given
757
+ # block for comparison.
758
+ #
759
+ # With no argument and no block given, returns the minimum-valued element of
760
+ # `self`.
761
+ #
762
+ # (1..4).min # => 1
763
+ # ('a'..'d').min # => "a"
764
+ # (-4..-1).min # => -4
765
+ #
766
+ # With non-negative integer argument `n` given, and no block given, returns the
767
+ # `n` minimum-valued elements of `self` in an array:
768
+ #
769
+ # (1..4).min(2) # => [1, 2]
770
+ # ('a'..'d').min(2) # => ["a", "b"]
771
+ # (-4..-1).min(2) # => [-4, -3]
772
+ # (1..4).min(50) # => [1, 2, 3, 4]
773
+ #
774
+ # If a block is given, it is called:
775
+ #
776
+ # * First, with the first two element of `self`.
777
+ # * Then, sequentially, with the so-far minimum value and the next element of
778
+ # `self`.
779
+ #
780
+ # To illustrate:
781
+ #
782
+ # (1..4).min {|a, b| p [a, b]; a <=> b } # => 1
783
+ #
784
+ # Output:
785
+ #
786
+ # [2, 1]
787
+ # [3, 1]
788
+ # [4, 1]
789
+ #
790
+ # With no argument and a block given, returns the return value of the last call
791
+ # to the block:
792
+ #
793
+ # (1..4).min {|a, b| -(a <=> b) } # => 4
794
+ #
795
+ # With non-negative integer argument `n` given, and a block given, returns the
796
+ # return values of the last `n` calls to the block in an array:
797
+ #
798
+ # (1..4).min(2) {|a, b| -(a <=> b) } # => [4, 3]
799
+ # (1..4).min(50) {|a, b| -(a <=> b) } # => [4, 3, 2, 1]
800
+ #
801
+ # Returns an empty array if `n` is zero:
802
+ #
803
+ # (1..4).min(0) # => []
804
+ # (1..4).min(0) {|a, b| -(a <=> b) } # => []
805
+ #
806
+ # Returns `nil` or an empty array if:
807
+ #
808
+ # * The begin value of the range is larger than the end value:
809
+ #
810
+ # (4..1).min # => nil
811
+ # (4..1).min(2) # => []
812
+ # (4..1).min {|a, b| -(a <=> b) } # => nil
813
+ # (4..1).min(2) {|a, b| -(a <=> b) } # => []
814
+ #
815
+ # * The begin value of an exclusive range is equal to the end value:
816
+ #
817
+ # (1...1).min # => nil
818
+ # (1...1).min(2) # => []
819
+ # (1...1).min {|a, b| -(a <=> b) } # => nil
820
+ # (1...1).min(2) {|a, b| -(a <=> b) } # => []
821
+ #
822
+ # Raises an exception if either:
823
+ #
824
+ # * `self` is a beginless range: <code>(..4)</code>.
825
+ # * A block is given and `self` is an endless range.
826
+ #
827
+ # Related: Range#max, Range#minmax.
828
+ #
829
+ def min: ...
830
+
831
+ # <!--
832
+ # rdoc-file=range.c
833
+ # - minmax -> [object, object]
834
+ # - minmax {|a, b| ... } -> [object, object]
835
+ # -->
836
+ # Returns a 2-element array containing the minimum and maximum value in `self`,
837
+ # either according to comparison method <code>#<=></code> or a given block.
838
+ #
839
+ # With no block given, returns the minimum and maximum values, using
840
+ # <code>#<=></code> for comparison:
841
+ #
842
+ # (1..4).minmax # => [1, 4]
843
+ # (1...4).minmax # => [1, 3]
844
+ # ('a'..'d').minmax # => ["a", "d"]
845
+ # (-4..-1).minmax # => [-4, -1]
846
+ #
847
+ # With a block given, the block must return an integer:
848
+ #
849
+ # * Negative if `a` is smaller than `b`.
850
+ # * Zero if `a` and `b` are equal.
851
+ # * Positive if `a` is larger than `b`.
852
+ #
853
+ # The block is called <code>self.size</code> times to compare elements; returns
854
+ # a 2-element Array containing the minimum and maximum values from `self`, per
855
+ # the block:
856
+ #
857
+ # (1..4).minmax {|a, b| -(a <=> b) } # => [4, 1]
858
+ #
859
+ # Returns <code>[nil, nil]</code> if:
860
+ #
861
+ # * The begin value of the range is larger than the end value:
862
+ #
863
+ # (4..1).minmax # => [nil, nil]
864
+ # (4..1).minmax {|a, b| -(a <=> b) } # => [nil, nil]
865
+ #
866
+ # * The begin value of an exclusive range is equal to the end value:
867
+ #
868
+ # (1...1).minmax # => [nil, nil]
869
+ # (1...1).minmax {|a, b| -(a <=> b) } # => [nil, nil]
870
+ #
871
+ # Raises an exception if `self` is a beginless or an endless range.
872
+ #
873
+ # Related: Range#min, Range#max.
874
+ #
875
+ def minmax: ...
876
+
877
+ # <!--
878
+ # rdoc-file=range.c
879
+ # - overlap?(range) -> true or false
880
+ # -->
881
+ # Returns `true` if `range` overlaps with `self`, `false` otherwise:
882
+ #
883
+ # (0..2).overlap?(1..3) #=> true
884
+ # (0..2).overlap?(3..4) #=> false
885
+ # (0..).overlap?(..0) #=> true
886
+ #
887
+ # With non-range argument, raises TypeError.
888
+ #
889
+ # (1..3).overlap?(1) # TypeError
890
+ #
891
+ # Returns `false` if an internal call to <code>#<=></code> returns `nil`; that
892
+ # is, the operands are not comparable.
893
+ #
894
+ # (1..3).overlap?('a'..'d') # => false
895
+ #
896
+ # Returns `false` if `self` or `range` is empty. "Empty range" means that its
897
+ # begin value is larger than, or equal for an exclusive range, its end value.
898
+ #
899
+ # (4..1).overlap?(2..3) # => false
900
+ # (4..1).overlap?(..3) # => false
901
+ # (4..1).overlap?(2..) # => false
902
+ # (2...2).overlap?(1..2) # => false
903
+ #
904
+ # (1..4).overlap?(3..2) # => false
905
+ # (..4).overlap?(3..2) # => false
906
+ # (1..).overlap?(3..2) # => false
907
+ # (1..2).overlap?(2...2) # => false
908
+ #
909
+ # Returns `false` if the begin value one of `self` and `range` is larger than,
910
+ # or equal if the other is an exclusive range, the end value of the other:
911
+ #
912
+ # (4..5).overlap?(2..3) # => false
913
+ # (4..5).overlap?(2...4) # => false
914
+ #
915
+ # (1..2).overlap?(3..4) # => false
916
+ # (1...3).overlap?(3..4) # => false
917
+ #
918
+ # Returns `false` if the end value one of `self` and `range` is larger than, or
919
+ # equal for an exclusive range, the end value of the other:
920
+ #
921
+ # (4..5).overlap?(2..3) # => false
922
+ # (4..5).overlap?(2...4) # => false
923
+ #
924
+ # (1..2).overlap?(3..4) # => false
925
+ # (1...3).overlap?(3..4) # => false
926
+ #
927
+ # Note that the method wouldn't make any assumptions about the beginless range
928
+ # being actually empty, even if its upper bound is the minimum possible value of
929
+ # its type, so all this would return `true`:
930
+ #
931
+ # (...-Float::INFINITY).overlap?(...-Float::INFINITY) # => true
932
+ # (..."").overlap?(..."") # => true
933
+ # (...[]).overlap?(...[]) # => true
934
+ #
935
+ # Even if those ranges are effectively empty (no number can be smaller than
936
+ # <code>-Float::INFINITY</code>), they are still considered overlapping with
937
+ # themselves.
938
+ #
939
+ # Related: Range#cover?.
940
+ #
941
+ def overlap?: (Range[untyped]) -> bool
942
+
943
+ # <!--
944
+ # rdoc-file=range.c
945
+ # - reverse_each {|element| ... } -> self
946
+ # - reverse_each -> an_enumerator
947
+ # -->
948
+ # With a block given, passes each element of `self` to the block in reverse
949
+ # order:
950
+ #
951
+ # a = []
952
+ # (1..4).reverse_each {|element| a.push(element) } # => 1..4
953
+ # a # => [4, 3, 2, 1]
954
+ #
955
+ # a = []
956
+ # (1...4).reverse_each {|element| a.push(element) } # => 1...4
957
+ # a # => [3, 2, 1]
958
+ #
959
+ # With no block given, returns an enumerator.
960
+ #
961
+ def reverse_each: () { (E) -> void } -> self
962
+ | () -> ::Enumerator[E, self]
963
+
964
+ # <!--
965
+ # rdoc-file=range.c
966
+ # - size -> non_negative_integer or Infinity or nil
967
+ # -->
968
+ # Returns the count of elements in `self` if both begin and end values are
969
+ # numeric; otherwise, returns `nil`:
970
+ #
971
+ # (1..4).size # => 4
972
+ # (1...4).size # => 3
973
+ # (1..).size # => Infinity
974
+ # ('a'..'z').size # => nil
975
+ #
976
+ # If `self` is not iterable, raises an exception:
977
+ #
978
+ # (0.5..2.5).size # TypeError
979
+ # (..1).size # TypeError
980
+ #
981
+ # Related: Range#count.
982
+ #
983
+ def size: () -> (Integer | Float | nil)
984
+
985
+ # <!--
986
+ # rdoc-file=range.c
987
+ # - count -> integer
988
+ # - count(object) -> integer
989
+ # - count {|element| ... } -> integer
990
+ # -->
991
+ # Returns the count of elements, based on an argument or block criterion, if
992
+ # given.
993
+ #
994
+ # With no argument and no block given, returns the number of elements:
995
+ #
996
+ # (1..4).count # => 4
997
+ # (1...4).count # => 3
998
+ # ('a'..'d').count # => 4
999
+ # ('a'...'d').count # => 3
1000
+ # (1..).count # => Infinity
1001
+ # (..4).count # => Infinity
1002
+ #
1003
+ # With argument `object`, returns the number of `object` found in `self`, which
1004
+ # will usually be zero or one:
1005
+ #
1006
+ # (1..4).count(2) # => 1
1007
+ # (1..4).count(5) # => 0
1008
+ # (1..4).count('a') # => 0
1009
+ #
1010
+ # With a block given, calls the block with each element; returns the number of
1011
+ # elements for which the block returns a truthy value:
1012
+ #
1013
+ # (1..4).count {|element| element < 3 } # => 2
1014
+ #
1015
+ # Related: Range#size.
1016
+ #
1017
+ def count: () -> (Integer | Float)
1018
+ | (untyped) -> Integer
1019
+ | () { (E) -> boolish } -> Integer
1020
+
1021
+ # <!--
1022
+ # rdoc-file=range.c
1023
+ # - step(s = 1) {|element| ... } -> self
1024
+ # - step(s = 1) -> enumerator/arithmetic_sequence
1025
+ # -->
1026
+ # Iterates over the elements of range in steps of `s`. The iteration is
1027
+ # performed by <code>+</code> operator:
1028
+ #
1029
+ # (0..6).step(2) { puts _1 } #=> 1..5
1030
+ # # Prints: 0, 2, 4, 6
1031
+ #
1032
+ # # Iterate between two dates in step of 1 day (24 hours)
1033
+ # (Time.utc(2022, 2, 24)..Time.utc(2022, 3, 1)).step(24*60*60) { puts _1 }
1034
+ # # Prints:
1035
+ # # 2022-02-24 00:00:00 UTC
1036
+ # # 2022-02-25 00:00:00 UTC
1037
+ # # 2022-02-26 00:00:00 UTC
1038
+ # # 2022-02-27 00:00:00 UTC
1039
+ # # 2022-02-28 00:00:00 UTC
1040
+ # # 2022-03-01 00:00:00 UTC
1041
+ #
1042
+ # If <code> + step</code> decreases the value, iteration is still performed when
1043
+ # step `begin` is higher than the `end`:
1044
+ #
1045
+ # (0..6).step(-2) { puts _1 }
1046
+ # # Prints nothing
1047
+ #
1048
+ # (6..0).step(-2) { puts _1 }
1049
+ # # Prints: 6, 4, 2, 0
1050
+ #
1051
+ # (Time.utc(2022, 3, 1)..Time.utc(2022, 2, 24)).step(-24*60*60) { puts _1 }
1052
+ # # Prints:
1053
+ # # 2022-03-01 00:00:00 UTC
1054
+ # # 2022-02-28 00:00:00 UTC
1055
+ # # 2022-02-27 00:00:00 UTC
1056
+ # # 2022-02-26 00:00:00 UTC
1057
+ # # 2022-02-25 00:00:00 UTC
1058
+ # # 2022-02-24 00:00:00 UTC
1059
+ #
1060
+ # When the block is not provided, and range boundaries and step are Numeric, the
1061
+ # method returns Enumerator::ArithmeticSequence.
1062
+ #
1063
+ # (1..5).step(2) # => ((1..5).step(2))
1064
+ # (1.0..).step(1.5) #=> ((1.0..).step(1.5))
1065
+ # (..3r).step(1/3r) #=> ((..3/1).step((1/3)))
1066
+ #
1067
+ # Enumerator::ArithmeticSequence can be further used as a value object for
1068
+ # iteration or slicing of collections (see Array#[]). There is a convenience
1069
+ # method #% with behavior similar to `step` to produce arithmetic sequences more
1070
+ # expressively:
1071
+ #
1072
+ # # Same as (1..5).step(2)
1073
+ # (1..5) % 2 # => ((1..5).%(2))
1074
+ #
1075
+ # In a generic case, when the block is not provided, Enumerator is returned:
1076
+ #
1077
+ # ('a'..).step('b') #=> #<Enumerator: "a"..:step("b")>
1078
+ # ('a'..).step('b').take(3) #=> ["a", "ab", "abb"]
1079
+ #
1080
+ # If `s` is not provided, it is considered `1` for ranges with numeric `begin`:
1081
+ #
1082
+ # (1..5).step { p _1 }
1083
+ # # Prints: 1, 2, 3, 4, 5
1084
+ #
1085
+ # For non-Numeric ranges, step absence is an error:
1086
+ #
1087
+ # (Time.utc(2022, 3, 1)..Time.utc(2022, 2, 24)).step { p _1 }
1088
+ # # raises: step is required for non-numeric ranges (ArgumentError)
1089
+ #
1090
+ # For backward compatibility reasons, String ranges support the iteration both
1091
+ # with string step and with integer step. In the latter case, the iteration is
1092
+ # performed by calculating the next values with String#succ:
1093
+ #
1094
+ # ('a'..'e').step(2) { p _1 }
1095
+ # # Prints: a, c, e
1096
+ # ('a'..'e').step { p _1 }
1097
+ # # Default step 1; prints: a, b, c, d, e
1098
+ #
1099
+ def step: (?Numeric | int) -> Enumerator[E, self]
1100
+ | (?Numeric | int) { (E element) -> void } -> self
1101
+ | (untyped) -> Enumerator[E, self]
1102
+ | (untyped) { (E element) -> void } -> self
1103
+
1104
+ # <!--
1105
+ # rdoc-file=range.c
1106
+ # - to_s -> string
1107
+ # -->
1108
+ # Returns a string representation of `self`, including <code>begin.to_s</code>
1109
+ # and <code>end.to_s</code>:
1110
+ #
1111
+ # (1..4).to_s # => "1..4"
1112
+ # (1...4).to_s # => "1...4"
1113
+ # (1..).to_s # => "1.."
1114
+ # (..4).to_s # => "..4"
1115
+ #
1116
+ # Note that returns from #to_s and #inspect may differ:
1117
+ #
1118
+ # ('a'..'d').to_s # => "a..d"
1119
+ # ('a'..'d').inspect # => "\"a\"..\"d\""
1120
+ #
1121
+ # Related: Range#inspect.
1122
+ #
1123
+ def to_s: () -> String
1124
+
1125
+ # <!--
1126
+ # rdoc-file=range.c
1127
+ # - eql?(other) -> true or false
1128
+ # -->
1129
+ # Returns `true` if and only if:
1130
+ #
1131
+ # * `other` is a range.
1132
+ # * <code>other.begin.eql?(self.begin)</code>.
1133
+ # * <code>other.end.eql?(self.end)</code>.
1134
+ # * <code>other.exclude_end? == self.exclude_end?</code>.
1135
+ #
1136
+ # Otherwise returns `false`.
1137
+ #
1138
+ # r = (1..5)
1139
+ # r.eql?(1..5) # => true
1140
+ # r = Range.new(1, 5)
1141
+ # r.eql?('foo') # => false
1142
+ # r.eql?(2..5) # => false
1143
+ # r.eql?(1..4) # => false
1144
+ # r.eql?(1...5) # => false
1145
+ # r.eql?(Range.new(1, 5, true)) # => false
1146
+ #
1147
+ # Note that even with the same argument, the return values of #== and #eql? can
1148
+ # differ:
1149
+ #
1150
+ # (1..2) == (1..2.0) # => true
1151
+ # (1..2).eql? (1..2.0) # => false
1152
+ #
1153
+ # Related: Range#==.
1154
+ #
1155
+ def eql?: (untyped obj) -> bool
1156
+
1157
+ # <!--
1158
+ # rdoc-file=range.c
1159
+ # - include?(object) -> true or false
1160
+ # -->
1161
+ # Returns `true` if `object` is an element of `self`, `false` otherwise:
1162
+ #
1163
+ # (1..4).include?(2) # => true
1164
+ # (1..4).include?(5) # => false
1165
+ # (1..4).include?(4) # => true
1166
+ # (1...4).include?(4) # => false
1167
+ # ('a'..'d').include?('b') # => true
1168
+ # ('a'..'d').include?('e') # => false
1169
+ # ('a'..'d').include?('B') # => false
1170
+ # ('a'..'d').include?('d') # => true
1171
+ # ('a'...'d').include?('d') # => false
1172
+ #
1173
+ # If begin and end are numeric, #include? behaves like #cover?
1174
+ #
1175
+ # (1..3).include?(1.5) # => true
1176
+ # (1..3).cover?(1.5) # => true
1177
+ #
1178
+ # But when not numeric, the two methods may differ:
1179
+ #
1180
+ # ('a'..'d').include?('cc') # => false
1181
+ # ('a'..'d').cover?('cc') # => true
1182
+ #
1183
+ # Related: Range#cover?.
1184
+ #
1185
+ def member?: (untyped obj) -> bool
1186
+
1187
+ # <!--
1188
+ # rdoc-file=range.c
1189
+ # - to_a -> array
1190
+ # -->
1191
+ # Returns an array containing the elements in `self`, if a finite collection;
1192
+ # raises an exception otherwise.
1193
+ #
1194
+ # (1..4).to_a # => [1, 2, 3, 4]
1195
+ # (1...4).to_a # => [1, 2, 3]
1196
+ # ('a'..'d').to_a # => ["a", "b", "c", "d"]
1197
+ #
1198
+ def to_a: ...
1199
+
1200
+ # <!-- rdoc-file=range.c -->
1201
+ # Returns an array containing the elements in `self`, if a finite collection;
1202
+ # raises an exception otherwise.
1203
+ #
1204
+ # (1..4).to_a # => [1, 2, 3, 4]
1205
+ # (1...4).to_a # => [1, 2, 3]
1206
+ # ('a'..'d').to_a # => ["a", "b", "c", "d"]
1207
+ #
1208
+ alias entries to_a
1209
+ end