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/integer.rbs ADDED
@@ -0,0 +1,1374 @@
1
+ # <!-- rdoc-file=numeric.c -->
2
+ # An Integer object represents an integer value.
3
+ #
4
+ # You can create an Integer object explicitly with:
5
+ #
6
+ # * An [integer literal](rdoc-ref:syntax/literals.rdoc@Integer+Literals).
7
+ #
8
+ # You can convert certain objects to Integers with:
9
+ #
10
+ # * Method #Integer.
11
+ #
12
+ # An attempt to add a singleton method to an instance of this class causes an
13
+ # exception to be raised.
14
+ #
15
+ # ## What's Here
16
+ #
17
+ # First, what's elsewhere. Class Integer:
18
+ #
19
+ # * Inherits from [class Numeric](rdoc-ref:Numeric@What-27s+Here) and [class
20
+ # Object](rdoc-ref:Object@What-27s+Here).
21
+ # * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
22
+ #
23
+ # Here, class Integer provides methods for:
24
+ #
25
+ # * [Querying](rdoc-ref:Integer@Querying)
26
+ # * [Comparing](rdoc-ref:Integer@Comparing)
27
+ # * [Converting](rdoc-ref:Integer@Converting)
28
+ # * [Other](rdoc-ref:Integer@Other)
29
+ #
30
+ # ### Querying
31
+ #
32
+ # * #allbits?: Returns whether all bits in `self` are set.
33
+ # * #anybits?: Returns whether any bits in `self` are set.
34
+ # * #nobits?: Returns whether no bits in `self` are set.
35
+ #
36
+ # ### Comparing
37
+ #
38
+ # * #<: Returns whether `self` is less than the given value.
39
+ # * #<=: Returns whether `self` is less than or equal to the given value.
40
+ # * #<=>: Returns a number indicating whether `self` is less than, equal to,
41
+ # or greater than the given value.
42
+ # * #== (aliased as #===): Returns whether `self` is equal to the given
43
+ # value.
44
+ #
45
+ # * #>: Returns whether `self` is greater than the given value.
46
+ # * #>=: Returns whether `self` is greater than or equal to the given value.
47
+ #
48
+ # ### Converting
49
+ #
50
+ # * ::sqrt: Returns the integer square root of the given value.
51
+ # * ::try_convert: Returns the given value converted to an Integer.
52
+ # * #% (aliased as #modulo): Returns `self` modulo the given value.
53
+ # * #&: Returns the bitwise AND of `self` and the given value.
54
+ # * #*: Returns the product of `self` and the given value.
55
+ # * #**: Returns the value of `self` raised to the power of the given value.
56
+ # * #+: Returns the sum of `self` and the given value.
57
+ # * #-: Returns the difference of `self` and the given value.
58
+ # * #/: Returns the quotient of `self` and the given value.
59
+ # * #<<: Returns the value of `self` after a leftward bit-shift.
60
+ # * #>>: Returns the value of `self` after a rightward bit-shift.
61
+ # * #[]: Returns a slice of bits from `self`.
62
+ # * #^: Returns the bitwise EXCLUSIVE OR of `self` and the given value.
63
+ # * #|: Returns the bitwise OR of `self` and the given value.
64
+ # * #ceil: Returns the smallest number greater than or equal to `self`.
65
+ # * #chr: Returns a 1-character string containing the character represented by
66
+ # the value of `self`.
67
+ # * #digits: Returns an array of integers representing the base-radix digits
68
+ # of `self`.
69
+ # * #div: Returns the integer result of dividing `self` by the given value.
70
+ # * #divmod: Returns a 2-element array containing the quotient and remainder
71
+ # results of dividing `self` by the given value.
72
+ # * #fdiv: Returns the Float result of dividing `self` by the given value.
73
+ # * #floor: Returns the greatest number smaller than or equal to `self`.
74
+ # * #pow: Returns the modular exponentiation of `self`.
75
+ # * #pred: Returns the integer predecessor of `self`.
76
+ # * #remainder: Returns the remainder after dividing `self` by the given
77
+ # value.
78
+ # * #round: Returns `self` rounded to the nearest value with the given
79
+ # precision.
80
+ # * #succ (aliased as #next): Returns the integer successor of `self`.
81
+ # * #to_f: Returns `self` converted to a Float.
82
+ # * #to_s (aliased as #inspect): Returns a string containing the place-value
83
+ # representation of `self` in the given radix.
84
+ # * #truncate: Returns `self` truncated to the given precision.
85
+ #
86
+ # ### Other
87
+ #
88
+ # * #downto: Calls the given block with each integer value from `self` down to
89
+ # the given value.
90
+ # * #times: Calls the given block `self` times with each integer in
91
+ # <code>(0..self-1)</code>.
92
+ # * #upto: Calls the given block with each integer value from `self` up to the
93
+ # given value.
94
+ #
95
+ class Integer < Numeric
96
+ # TODO: `undef self.new`
97
+
98
+ # <!--
99
+ # rdoc-file=numeric.c
100
+ # - Integer.sqrt(numeric) -> integer
101
+ # -->
102
+ # Returns the integer square root of the non-negative integer `n`, which is the
103
+ # largest non-negative integer less than or equal to the square root of
104
+ # `numeric`.
105
+ #
106
+ # Integer.sqrt(0) # => 0
107
+ # Integer.sqrt(1) # => 1
108
+ # Integer.sqrt(24) # => 4
109
+ # Integer.sqrt(25) # => 5
110
+ # Integer.sqrt(10**400) # => 10**200
111
+ #
112
+ # If `numeric` is not an Integer, it is converted to an Integer:
113
+ #
114
+ # Integer.sqrt(Complex(4, 0)) # => 2
115
+ # Integer.sqrt(Rational(4, 1)) # => 2
116
+ # Integer.sqrt(4.0) # => 2
117
+ # Integer.sqrt(3.14159) # => 1
118
+ #
119
+ # This method is equivalent to <code>Math.sqrt(numeric).floor</code>, except
120
+ # that the result of the latter code may differ from the true value due to the
121
+ # limited precision of floating point arithmetic.
122
+ #
123
+ # Integer.sqrt(10**46) # => 100000000000000000000000
124
+ # Math.sqrt(10**46).floor # => 99999999999999991611392
125
+ #
126
+ # Raises an exception if `numeric` is negative.
127
+ #
128
+ def self.sqrt: (int n) -> Integer
129
+
130
+ # <!--
131
+ # rdoc-file=numeric.c
132
+ # - Integer.try_convert(object) -> object, integer, or nil
133
+ # -->
134
+ # If `object` is an Integer object, returns `object`.
135
+ # Integer.try_convert(1) # => 1
136
+ #
137
+ # Otherwise if `object` responds to <code>:to_int</code>, calls
138
+ # <code>object.to_int</code> and returns the result.
139
+ # Integer.try_convert(1.25) # => 1
140
+ #
141
+ # Returns `nil` if `object` does not respond to <code>:to_int</code>
142
+ # Integer.try_convert([]) # => nil
143
+ #
144
+ # Raises an exception unless <code>object.to_int</code> returns an Integer
145
+ # object.
146
+ #
147
+ def self.try_convert: (int) -> Integer
148
+ | (untyped) -> Integer?
149
+
150
+ # <!--
151
+ # rdoc-file=numeric.c
152
+ # - self % other -> real_numeric
153
+ # -->
154
+ # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
155
+ #
156
+ # For integer `n` and real number `r`, these expressions are equivalent:
157
+ #
158
+ # n % r
159
+ # n-r*(n/r).floor
160
+ # n.divmod(r)[1]
161
+ #
162
+ # See Numeric#divmod.
163
+ #
164
+ # Examples:
165
+ #
166
+ # 10 % 2 # => 0
167
+ # 10 % 3 # => 1
168
+ # 10 % 4 # => 2
169
+ #
170
+ # 10 % -2 # => 0
171
+ # 10 % -3 # => -2
172
+ # 10 % -4 # => -2
173
+ #
174
+ # 10 % 3.0 # => 1.0
175
+ # 10 % Rational(3, 1) # => (1/1)
176
+ #
177
+ def %: (Float) -> Float
178
+ | (Rational) -> Rational
179
+ | (Integer) -> Integer
180
+ | (Numeric) -> Numeric
181
+
182
+ # <!--
183
+ # rdoc-file=numeric.c
184
+ # - self & other -> integer
185
+ # -->
186
+ # Bitwise AND; each bit in the result is 1 if both corresponding bits in `self`
187
+ # and `other` are 1, 0 otherwise:
188
+ #
189
+ # "%04b" % (0b0101 & 0b0110) # => "0100"
190
+ #
191
+ # Raises an exception if `other` is not an Integer.
192
+ #
193
+ # Related: Integer#| (bitwise OR), Integer#^ (bitwise EXCLUSIVE OR).
194
+ #
195
+ def &: (Integer) -> Integer
196
+
197
+ # <!--
198
+ # rdoc-file=numeric.c
199
+ # - self * other -> numeric
200
+ # -->
201
+ # Returns the numeric product of `self` and `other`:
202
+ #
203
+ # 4 * 2 # => 8
204
+ # -4 * 2 # => -8
205
+ # 4 * -2 # => -8
206
+ # 4 * 2.0 # => 8.0
207
+ # 4 * Rational(1, 3) # => (4/3)
208
+ # 4 * Complex(2, 0) # => (8+0i)
209
+ #
210
+ def *: (Float) -> Float
211
+ | (Rational) -> Rational
212
+ | (Complex) -> Complex
213
+ | (Integer) -> Integer
214
+
215
+ # <!--
216
+ # rdoc-file=numeric.c
217
+ # - self ** exponent -> numeric
218
+ # -->
219
+ # Returns `self` raised to the power `exponent`:
220
+ #
221
+ # # Result for non-negative Integer exponent is Integer.
222
+ # 2 ** 0 # => 1
223
+ # 2 ** 1 # => 2
224
+ # 2 ** 2 # => 4
225
+ # 2 ** 3 # => 8
226
+ # -2 ** 3 # => -8
227
+ # # Result for negative Integer exponent is Rational, not Float.
228
+ # 2 ** -3 # => (1/8)
229
+ # -2 ** -3 # => (-1/8)
230
+ #
231
+ # # Result for Float exponent is Float.
232
+ # 2 ** 0.0 # => 1.0
233
+ # 2 ** 1.0 # => 2.0
234
+ # 2 ** 2.0 # => 4.0
235
+ # 2 ** 3.0 # => 8.0
236
+ # -2 ** 3.0 # => -8.0
237
+ # 2 ** -3.0 # => 0.125
238
+ # -2 ** -3.0 # => -0.125
239
+ #
240
+ # # Result for non-negative Complex exponent is Complex with Integer parts.
241
+ # 2 ** Complex(0, 0) # => (1+0i)
242
+ # 2 ** Complex(1, 0) # => (2+0i)
243
+ # 2 ** Complex(2, 0) # => (4+0i)
244
+ # 2 ** Complex(3, 0) # => (8+0i)
245
+ # -2 ** Complex(3, 0) # => (-8+0i)
246
+ # # Result for negative Complex exponent is Complex with Rational parts.
247
+ # 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
248
+ # -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
249
+ #
250
+ # # Result for Rational exponent is Rational.
251
+ # 2 ** Rational(0, 1) # => (1/1)
252
+ # 2 ** Rational(1, 1) # => (2/1)
253
+ # 2 ** Rational(2, 1) # => (4/1)
254
+ # 2 ** Rational(3, 1) # => (8/1)
255
+ # -2 ** Rational(3, 1) # => (-8/1)
256
+ # 2 ** Rational(-3, 1) # => (1/8)
257
+ # -2 ** Rational(-3, 1) # => (-1/8)
258
+ #
259
+ def **: (Integer) -> Numeric
260
+ | (Float) -> Numeric
261
+ | (Rational) -> Numeric
262
+ | (Complex) -> Complex
263
+
264
+ # <!--
265
+ # rdoc-file=numeric.c
266
+ # - self + other -> numeric
267
+ # -->
268
+ # Returns the sum of `self` and `other`:
269
+ #
270
+ # 1 + 1 # => 2
271
+ # 1 + -1 # => 0
272
+ # 1 + 0 # => 1
273
+ # 1 + -2 # => -1
274
+ # 1 + Complex(1, 0) # => (2+0i)
275
+ # 1 + Rational(1, 1) # => (2/1)
276
+ #
277
+ # For a computation involving Floats, the result may be inexact (see Float#+):
278
+ #
279
+ # 1 + 3.14 # => 4.140000000000001
280
+ #
281
+ def +: (Integer) -> Integer
282
+ | (Float) -> Float
283
+ | (Rational) -> Rational
284
+ | (Complex) -> Complex
285
+
286
+ # <!--
287
+ # rdoc-file=numeric.c
288
+ # - self - other -> numeric
289
+ # -->
290
+ # Returns the difference of `self` and `other`:
291
+ #
292
+ # 4 - 2 # => 2
293
+ # -4 - 2 # => -6
294
+ # -4 - -2 # => -2
295
+ # 4 - 2.0 # => 2.0
296
+ # 4 - Rational(2, 1) # => (2/1)
297
+ # 4 - Complex(2, 0) # => (2+0i)
298
+ #
299
+ def -: (Integer) -> Integer
300
+ | (Float) -> Float
301
+ | (Rational) -> Rational
302
+ | (Complex) -> Complex
303
+
304
+ # <!--
305
+ # rdoc-file=numeric.rb
306
+ # - -self -> integer
307
+ # -->
308
+ # Returns `self`, negated:
309
+ #
310
+ # -1 # => -1
311
+ # -(-1) # => 1
312
+ # -0 # => 0
313
+ #
314
+ def -@: () -> Integer
315
+
316
+ # <!--
317
+ # rdoc-file=numeric.c
318
+ # - self / other -> numeric
319
+ # -->
320
+ # Returns the quotient of `self` and `other`.
321
+ #
322
+ # For integer `other`, truncates the result to an integer:
323
+ #
324
+ # 4 / 3 # => 1
325
+ # 4 / -3 # => -2
326
+ # -4 / 3 # => -2
327
+ # -4 / -3 # => 1
328
+ #
329
+ # For non-integer `other`, returns a non-integer result:
330
+ #
331
+ # 4 / 3.0 # => 1.3333333333333333
332
+ # 4 / Rational(3, 1) # => (4/3)
333
+ # 4 / Complex(3, 0) # => ((4/3)+0i)
334
+ #
335
+ def /: (Integer) -> Integer
336
+ | (Float) -> Float
337
+ | (Rational) -> Rational
338
+ | (Complex) -> Complex
339
+
340
+ # <!--
341
+ # rdoc-file=numeric.c
342
+ # - self < other -> true or false
343
+ # -->
344
+ # Returns whether the value of `self` is less than the value of `other`; `other`
345
+ # must be numeric, but may not be Complex:
346
+ #
347
+ # 1 < 0 # => false
348
+ # 1 < 1 # => false
349
+ # 1 < 2 # => true
350
+ # 1 < 0.5 # => false
351
+ # 1 < Rational(1, 2) # => false
352
+ #
353
+ def <: (Numeric) -> bool
354
+
355
+ # <!--
356
+ # rdoc-file=numeric.c
357
+ # - self << count -> integer
358
+ # -->
359
+ # Returns `self` with bits shifted `count` positions to the left, or to the
360
+ # right if `count` is negative:
361
+ #
362
+ # n = 0b11110000
363
+ # "%08b" % (n << 1) # => "111100000"
364
+ # "%08b" % (n << 3) # => "11110000000"
365
+ # "%08b" % (n << -1) # => "01111000"
366
+ # "%08b" % (n << -3) # => "00011110"
367
+ #
368
+ # Related: Integer#>>.
369
+ #
370
+ def <<: (int) -> Integer
371
+
372
+ # <!--
373
+ # rdoc-file=numeric.c
374
+ # - self <= other -> true or false
375
+ # -->
376
+ # Returns whether the value of `self` is less than or equal to the value of
377
+ # `other`; `other` must be numeric, but may not be Complex:
378
+ #
379
+ # 1 <= 0 # => false
380
+ # 1 <= 1 # => true
381
+ # 1 <= 2 # => true
382
+ # 1 <= 0.5 # => false
383
+ # 1 <= Rational(1, 2) # => false
384
+ #
385
+ # Raises an exception if the comparison cannot be made.
386
+ #
387
+ def <=: (Numeric) -> bool
388
+
389
+ # <!--
390
+ # rdoc-file=numeric.c
391
+ # - self <=> other -> -1, 0, 1, or nil
392
+ # -->
393
+ # Compares `self` and `other`.
394
+ #
395
+ # Returns:
396
+ #
397
+ # * <code>-1</code>, if `self` is less than `other`.
398
+ # * `0`, if `self` is equal to `other`.
399
+ # * `1`, if `self` is greater then `other`.
400
+ # * `nil`, if `self` and `other` are incomparable.
401
+ #
402
+ # Examples:
403
+ #
404
+ # 1 <=> 2 # => -1
405
+ # 1 <=> 1 # => 0
406
+ # 1 <=> 1.0 # => 0
407
+ # 1 <=> Rational(1, 1) # => 0
408
+ # 1 <=> Complex(1, 0) # => 0
409
+ # 1 <=> 0 # => 1
410
+ # 1 <=> 'foo' # => nil
411
+ #
412
+ # Class Integer includes module Comparable, each of whose methods uses
413
+ # Integer#<=> for comparison.
414
+ #
415
+ def <=>: (Integer | Rational) -> Integer
416
+ | (untyped) -> Integer?
417
+
418
+ # <!-- rdoc-file=numeric.c -->
419
+ # Returns `true` if `self` is numerically equal to `other`; `false` otherwise.
420
+ #
421
+ # 1 == 2 #=> false
422
+ # 1 == 1.0 #=> true
423
+ #
424
+ # Related: Integer#eql? (requires `other` to be an Integer).
425
+ #
426
+ def ==: (untyped other) -> bool
427
+
428
+ # <!--
429
+ # rdoc-file=numeric.c
430
+ # - self == other -> true or false
431
+ # -->
432
+ # Returns `true` if `self` is numerically equal to `other`; `false` otherwise.
433
+ #
434
+ # 1 == 2 #=> false
435
+ # 1 == 1.0 #=> true
436
+ #
437
+ # Related: Integer#eql? (requires `other` to be an Integer).
438
+ #
439
+ alias === ==
440
+
441
+ # <!--
442
+ # rdoc-file=numeric.c
443
+ # - self > other -> true or false
444
+ # -->
445
+ # Returns `true` if the value of `self` is greater than that of `other`:
446
+ #
447
+ # 1 > 0 # => true
448
+ # 1 > 1 # => false
449
+ # 1 > 2 # => false
450
+ # 1 > 0.5 # => true
451
+ # 1 > Rational(1, 2) # => true
452
+ #
453
+ # Raises an exception if the comparison cannot be made.
454
+ #
455
+ def >: (Numeric) -> bool
456
+
457
+ # <!--
458
+ # rdoc-file=numeric.c
459
+ # - self >= real -> true or false
460
+ # -->
461
+ # Returns `true` if the value of `self` is greater than or equal to that of
462
+ # `other`:
463
+ #
464
+ # 1 >= 0 # => true
465
+ # 1 >= 1 # => true
466
+ # 1 >= 2 # => false
467
+ # 1 >= 0.5 # => true
468
+ # 1 >= Rational(1, 2) # => true
469
+ #
470
+ # Raises an exception if the comparison cannot be made.
471
+ #
472
+ def >=: (Numeric) -> bool
473
+
474
+ # <!--
475
+ # rdoc-file=numeric.c
476
+ # - self >> count -> integer
477
+ # -->
478
+ # Returns `self` with bits shifted `count` positions to the right, or to the
479
+ # left if `count` is negative:
480
+ #
481
+ # n = 0b11110000
482
+ # "%08b" % (n >> 1) # => "01111000"
483
+ # "%08b" % (n >> 3) # => "00011110"
484
+ # "%08b" % (n >> -1) # => "111100000"
485
+ # "%08b" % (n >> -3) # => "11110000000"
486
+ #
487
+ # Related: Integer#<<.
488
+ #
489
+ def >>: (int) -> Integer
490
+
491
+ # <!--
492
+ # rdoc-file=numeric.c
493
+ # - self[offset] -> 0 or 1
494
+ # - self[offset, size] -> integer
495
+ # - self[range] -> integer
496
+ # -->
497
+ # Returns a slice of bits from `self`.
498
+ #
499
+ # With argument `offset`, returns the bit at the given offset, where offset 0
500
+ # refers to the least significant bit:
501
+ #
502
+ # n = 0b10 # => 2
503
+ # n[0] # => 0
504
+ # n[1] # => 1
505
+ # n[2] # => 0
506
+ # n[3] # => 0
507
+ #
508
+ # In principle, <code>n[i]</code> is equivalent to <code>(n >> i) & 1</code>.
509
+ # Thus, negative index always returns zero:
510
+ #
511
+ # 255[-1] # => 0
512
+ #
513
+ # With arguments `offset` and `size`, returns `size` bits from `self`, beginning
514
+ # at `offset` and including bits of greater significance:
515
+ #
516
+ # n = 0b111000 # => 56
517
+ # "%010b" % n[0, 10] # => "0000111000"
518
+ # "%010b" % n[4, 10] # => "0000000011"
519
+ #
520
+ # With argument `range`, returns <code>range.size</code> bits from `self`,
521
+ # beginning at <code>range.begin</code> and including bits of greater
522
+ # significance:
523
+ #
524
+ # n = 0b111000 # => 56
525
+ # "%010b" % n[0..9] # => "0000111000"
526
+ # "%010b" % n[4..9] # => "0000000011"
527
+ #
528
+ # Raises an exception if the slice cannot be constructed.
529
+ #
530
+ def []: (int) -> Integer
531
+ | (int i, int len) -> Integer
532
+ | (Range[int]) -> Integer
533
+
534
+ # <!--
535
+ # rdoc-file=numeric.c
536
+ # - self ^ other -> integer
537
+ # -->
538
+ # Bitwise EXCLUSIVE OR; each bit in the result is 1 if the corresponding bits in
539
+ # `self` and `other` are different, 0 otherwise:
540
+ #
541
+ # "%04b" % (0b0101 ^ 0b0110) # => "0011"
542
+ #
543
+ # Raises an exception if `other` is not an Integer.
544
+ #
545
+ # Related: Integer#& (bitwise AND), Integer#| (bitwise OR).
546
+ #
547
+ def ^: (Integer) -> Integer
548
+
549
+ # <!--
550
+ # rdoc-file=numeric.rb
551
+ # - abs -> integer
552
+ # -->
553
+ # Returns the absolute value of `self`.
554
+ #
555
+ # (-12345).abs # => 12345
556
+ # -12345.abs # => 12345
557
+ # 12345.abs # => 12345
558
+ #
559
+ def abs: () -> Integer
560
+
561
+ # <!--
562
+ # rdoc-file=numeric.c
563
+ # - allbits?(mask) -> true or false
564
+ # -->
565
+ # Returns `true` if all bits that are set (=1) in `mask` are also set in `self`;
566
+ # returns `false` otherwise.
567
+ #
568
+ # Example values:
569
+ #
570
+ # 0b1010101 self
571
+ # 0b1010100 mask
572
+ # 0b1010100 self & mask
573
+ # true self.allbits?(mask)
574
+ #
575
+ # 0b1010100 self
576
+ # 0b1010101 mask
577
+ # 0b1010100 self & mask
578
+ # false self.allbits?(mask)
579
+ #
580
+ # Related: Integer#anybits?, Integer#nobits?.
581
+ #
582
+ def allbits?: (int mask) -> bool
583
+
584
+ # <!--
585
+ # rdoc-file=numeric.c
586
+ # - anybits?(mask) -> true or false
587
+ # -->
588
+ # Returns `true` if any bit that is set (=1) in `mask` is also set in `self`;
589
+ # returns `false` otherwise.
590
+ #
591
+ # Example values:
592
+ #
593
+ # 0b10000010 self
594
+ # 0b11111111 mask
595
+ # 0b10000010 self & mask
596
+ # true self.anybits?(mask)
597
+ #
598
+ # 0b00000000 self
599
+ # 0b11111111 mask
600
+ # 0b00000000 self & mask
601
+ # false self.anybits?(mask)
602
+ #
603
+ # Related: Integer#allbits?, Integer#nobits?.
604
+ #
605
+ def anybits?: (int mask) -> bool
606
+
607
+ alias arg angle
608
+
609
+ # <!--
610
+ # rdoc-file=numeric.rb
611
+ # - bit_length -> integer
612
+ # -->
613
+ # Returns the number of bits of the value of `self`, which is the bit position
614
+ # of the highest-order bit that is different from the sign bit (where the least
615
+ # significant bit has bit position 1). If there is no such bit (zero or minus
616
+ # one), returns zero.
617
+ #
618
+ # This method returns <code>ceil(log2(self < 0 ? -self : self + 1))</code>>.
619
+ #
620
+ # (-2**1000-1).bit_length # => 1001
621
+ # (-2**1000).bit_length # => 1000
622
+ # (-2**1000+1).bit_length # => 1000
623
+ # (-2**12-1).bit_length # => 13
624
+ # (-2**12).bit_length # => 12
625
+ # (-2**12+1).bit_length # => 12
626
+ # -0x101.bit_length # => 9
627
+ # -0x100.bit_length # => 8
628
+ # -0xff.bit_length # => 8
629
+ # -2.bit_length # => 1
630
+ # -1.bit_length # => 0
631
+ # 0.bit_length # => 0
632
+ # 1.bit_length # => 1
633
+ # 0xff.bit_length # => 8
634
+ # 0x100.bit_length # => 9
635
+ # (2**12-1).bit_length # => 12
636
+ # (2**12).bit_length # => 13
637
+ # (2**12+1).bit_length # => 13
638
+ # (2**1000-1).bit_length # => 1000
639
+ # (2**1000).bit_length # => 1001
640
+ # (2**1000+1).bit_length # => 1001
641
+ #
642
+ # For Integer *n*, this method can be used to detect overflow in Array#pack:
643
+ #
644
+ # if n.bit_length < 32
645
+ # [n].pack('l') # No overflow.
646
+ # else
647
+ # raise 'Overflow'
648
+ # end
649
+ #
650
+ def bit_length: () -> Integer
651
+
652
+ # <!--
653
+ # rdoc-file=numeric.c
654
+ # - ceil(ndigits = 0) -> integer
655
+ # -->
656
+ # Returns an integer that is a "ceiling" value for `self`,
657
+ # as specified by the given `ndigits`,
658
+ # which must be an
659
+ # [integer-convertible
660
+ # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
661
+ # * When `self` is zero, returns zero (regardless of the value of `ndigits`):
662
+ # 0.ceil(2) # => 0
663
+ # 0.ceil(-2) # => 0
664
+ #
665
+ # * When `self` is non-zero and `ndigits` is non-negative, returns `self`:
666
+ # 555.ceil # => 555
667
+ # 555.ceil(50) # => 555
668
+ #
669
+ # * When `self` is non-zero and `ndigits` is negative,
670
+ # returns a value based on a computed granularity:
671
+ # * The granularity is <code>10 ** ndigits.abs</code>.
672
+ # * The returned value is the smallest multiple of the granularity
673
+ # that is greater than or equal to `self`.
674
+ # Examples with positive `self`:
675
+ # ndigits|Granularity|1234.ceil(ndigits)
676
+ # -------|-----------|------------------
677
+ # -1| 10| 1240
678
+ # -2| 100| 1300
679
+ # -3| 1000| 2000
680
+ # -4| 10000| 10000
681
+ # -5| 100000| 100000
682
+ # Examples with negative `self`:
683
+ # ndigits|Granularity|-1234.ceil(ndigits)
684
+ # -------|-----------|-------------------
685
+ # -1| 10| -1230
686
+ # -2| 100| -1200
687
+ # -3| 1000| -1000
688
+ # -4| 10000| 0
689
+ # -5| 100000| 0
690
+ # Related: Integer#floor.
691
+ #
692
+ def ceil: (?int digits) -> Integer
693
+
694
+ # <!--
695
+ # rdoc-file=numeric.rb
696
+ # - ceildiv(numeric) -> integer
697
+ # -->
698
+ # Returns the result of division `self` by `numeric`. rounded up to the nearest
699
+ # integer.
700
+ #
701
+ # 3.ceildiv(3) # => 1
702
+ # 4.ceildiv(3) # => 2
703
+ #
704
+ # 4.ceildiv(-3) # => -1
705
+ # -4.ceildiv(3) # => -1
706
+ # -4.ceildiv(-3) # => 2
707
+ #
708
+ # 3.ceildiv(1.2) # => 3
709
+ #
710
+ def ceildiv: (Numeric other) -> Integer
711
+
712
+ # <!--
713
+ # rdoc-file=numeric.c
714
+ # - chr -> string
715
+ # - chr(encoding) -> string
716
+ # -->
717
+ # Returns a 1-character string containing the character represented by the value
718
+ # of `self`, according to the given `encoding`.
719
+ #
720
+ # 65.chr # => "A"
721
+ # 0.chr # => "\x00"
722
+ # 255.chr # => "\xFF"
723
+ # string = 255.chr(Encoding::UTF_8)
724
+ # string.encoding # => Encoding::UTF_8
725
+ #
726
+ # Raises an exception if `self` is negative.
727
+ #
728
+ # Related: Integer#ord.
729
+ #
730
+ def chr: (?encoding encoding) -> String
731
+
732
+ # <!--
733
+ # rdoc-file=bignum.c
734
+ # - int.coerce(numeric) -> array
735
+ # -->
736
+ # Returns an array with both a `numeric` and a `int` represented as Integer
737
+ # objects or Float objects.
738
+ #
739
+ # This is achieved by converting `numeric` to an Integer or a Float.
740
+ #
741
+ # A TypeError is raised if the `numeric` is not an Integer or a Float type.
742
+ #
743
+ # (0x3FFFFFFFFFFFFFFF+1).coerce(42) #=> [42, 4611686018427387904]
744
+ #
745
+ def coerce: (Numeric) -> [ Numeric, Numeric ]
746
+
747
+ # <!--
748
+ # rdoc-file=numeric.rb
749
+ # - denominator -> 1
750
+ # -->
751
+ # Returns `1`.
752
+ #
753
+ def denominator: () -> 1
754
+
755
+ # <!--
756
+ # rdoc-file=numeric.c
757
+ # - digits(base = 10) -> array_of_integers
758
+ # -->
759
+ # Returns an array of integers representing the `base`-radix digits of `self`;
760
+ # the first element of the array represents the least significant digit:
761
+ #
762
+ # 12345.digits # => [5, 4, 3, 2, 1]
763
+ # 12345.digits(7) # => [4, 6, 6, 0, 5]
764
+ # 12345.digits(100) # => [45, 23, 1]
765
+ #
766
+ # Raises an exception if `self` is negative or `base` is less than 2.
767
+ #
768
+ def digits: (?int base) -> Array[Integer]
769
+
770
+ # <!--
771
+ # rdoc-file=numeric.c
772
+ # - div(numeric) -> integer
773
+ # -->
774
+ # Performs integer division; returns the integer result of dividing `self` by
775
+ # `numeric`:
776
+ #
777
+ # 4.div(3) # => 1
778
+ # 4.div(-3) # => -2
779
+ # -4.div(3) # => -2
780
+ # -4.div(-3) # => 1
781
+ # 4.div(3.0) # => 1
782
+ # 4.div(Rational(3, 1)) # => 1
783
+ #
784
+ # Raises an exception if `numeric` does not have method `div`.
785
+ #
786
+ def div: (Numeric) -> Integer
787
+
788
+ # <!--
789
+ # rdoc-file=numeric.c
790
+ # - divmod(other) -> array
791
+ # -->
792
+ # Returns a 2-element array <code>[q, r]</code>, where
793
+ #
794
+ # q = (self/other).floor # Quotient
795
+ # r = self % other # Remainder
796
+ #
797
+ # Examples:
798
+ #
799
+ # 11.divmod(4) # => [2, 3]
800
+ # 11.divmod(-4) # => [-3, -1]
801
+ # -11.divmod(4) # => [-3, 1]
802
+ # -11.divmod(-4) # => [2, -3]
803
+ #
804
+ # 12.divmod(4) # => [3, 0]
805
+ # 12.divmod(-4) # => [-3, 0]
806
+ # -12.divmod(4) # => [-3, 0]
807
+ # -12.divmod(-4) # => [3, 0]
808
+ #
809
+ # 13.divmod(4.0) # => [3, 1.0]
810
+ # 13.divmod(Rational(4, 1)) # => [3, (1/1)]
811
+ #
812
+ def divmod: (Integer) -> [ Integer, Integer ]
813
+ | (Float) -> [ Integer, Float ]
814
+ | (Rational) -> [ Integer, Rational ]
815
+ | (Numeric) -> [ Numeric, Numeric ]
816
+
817
+ # <!--
818
+ # rdoc-file=numeric.c
819
+ # - downto(limit) {|i| ... } -> self
820
+ # - downto(limit) -> enumerator
821
+ # -->
822
+ # Calls the given block with each integer value from `self` down to `limit`;
823
+ # returns `self`:
824
+ #
825
+ # a = []
826
+ # 10.downto(5) {|i| a << i } # => 10
827
+ # a # => [10, 9, 8, 7, 6, 5]
828
+ # a = []
829
+ # 0.downto(-5) {|i| a << i } # => 0
830
+ # a # => [0, -1, -2, -3, -4, -5]
831
+ # 4.downto(5) {|i| fail 'Cannot happen' } # => 4
832
+ #
833
+ # With no block given, returns an Enumerator.
834
+ #
835
+ def downto: (Numeric limit) { (Integer) -> void } -> Integer
836
+ | (Numeric limit) -> ::Enumerator[Integer, self]
837
+
838
+ # <!--
839
+ # rdoc-file=numeric.rb
840
+ # - even? -> true or false
841
+ # -->
842
+ # Returns `true` if `self` is an even number, `false` otherwise.
843
+ #
844
+ def even?: () -> bool
845
+
846
+ # <!--
847
+ # rdoc-file=numeric.c
848
+ # - fdiv(numeric) -> float
849
+ # -->
850
+ # Returns the Float result of dividing `self` by `numeric`:
851
+ #
852
+ # 4.fdiv(2) # => 2.0
853
+ # 4.fdiv(-2) # => -2.0
854
+ # -4.fdiv(2) # => -2.0
855
+ # 4.fdiv(2.0) # => 2.0
856
+ # 4.fdiv(Rational(3, 4)) # => 5.333333333333333
857
+ #
858
+ # Raises an exception if `numeric` cannot be converted to a Float.
859
+ #
860
+ def fdiv: (Numeric) -> Float
861
+
862
+ # <!--
863
+ # rdoc-file=numeric.c
864
+ # - floor(ndigits = 0) -> integer
865
+ # -->
866
+ # Returns an integer that is a "floor" value for `self`,
867
+ # as specified by the given `ndigits`,
868
+ # which must be an
869
+ # [integer-convertible
870
+ # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
871
+ # * When `self` is zero, returns zero (regardless of the value of `ndigits`):
872
+ # 0.floor(2) # => 0
873
+ # 0.floor(-2) # => 0
874
+ #
875
+ # * When `self` is non-zero and `ndigits` is non-negative, returns `self`:
876
+ # 555.floor # => 555
877
+ # 555.floor(50) # => 555
878
+ #
879
+ # * When `self` is non-zero and `ndigits` is negative,
880
+ # returns a value based on a computed granularity:
881
+ # * The granularity is <code>10 ** ndigits.abs</code>.
882
+ # * The returned value is the largest multiple of the granularity
883
+ # that is less than or equal to `self`.
884
+ # Examples with positive `self`:
885
+ # ndigits|Granularity|1234.floor(ndigits)
886
+ # -------|-----------|-------------------
887
+ # -1| 10| 1230
888
+ # -2| 100| 1200
889
+ # -3| 1000| 1000
890
+ # -4| 10000| 0
891
+ # -5| 100000| 0
892
+ # Examples with negative `self`:
893
+ # ndigits|Granularity|-1234.floor(ndigits)
894
+ # -------|-----------|--------------------
895
+ # -1| 10| -1240
896
+ # -2| 100| -1300
897
+ # -3| 1000| -2000
898
+ # -4| 10000| -10000
899
+ # -5| 100000| -100000
900
+ # Related: Integer#ceil.
901
+ #
902
+ def floor: (?int digits) -> Integer
903
+
904
+ # <!--
905
+ # rdoc-file=rational.c
906
+ # - int.gcd(other_int) -> integer
907
+ # -->
908
+ # Returns the greatest common divisor of the two integers. The result is always
909
+ # positive. 0.gcd(x) and x.gcd(0) return x.abs.
910
+ #
911
+ # 36.gcd(60) #=> 12
912
+ # 2.gcd(2) #=> 2
913
+ # 3.gcd(-7) #=> 1
914
+ # ((1<<31)-1).gcd((1<<61)-1) #=> 1
915
+ #
916
+ def gcd: (Integer other_int) -> Integer
917
+
918
+ # <!--
919
+ # rdoc-file=rational.c
920
+ # - int.gcdlcm(other_int) -> array
921
+ # -->
922
+ # Returns an array with the greatest common divisor and the least common
923
+ # multiple of the two integers, [gcd, lcm].
924
+ #
925
+ # 36.gcdlcm(60) #=> [12, 180]
926
+ # 2.gcdlcm(2) #=> [2, 2]
927
+ # 3.gcdlcm(-7) #=> [1, 21]
928
+ # ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297]
929
+ #
930
+ def gcdlcm: (Integer other_int) -> [ Integer, Integer ]
931
+
932
+ # <!-- rdoc-file=numeric.c -->
933
+ # Returns a string containing the place-value representation of `self` in radix
934
+ # `base` (in 2..36).
935
+ #
936
+ # 12345.to_s # => "12345"
937
+ # 12345.to_s(2) # => "11000000111001"
938
+ # 12345.to_s(8) # => "30071"
939
+ # 12345.to_s(10) # => "12345"
940
+ # 12345.to_s(16) # => "3039"
941
+ # 12345.to_s(36) # => "9ix"
942
+ # 78546939656932.to_s(36) # => "rubyrules"
943
+ #
944
+ # Raises an exception if `base` is out of range.
945
+ #
946
+ alias inspect to_s
947
+
948
+ # <!--
949
+ # rdoc-file=numeric.rb
950
+ # - integer? -> true
951
+ # -->
952
+ # Since `self` is already an Integer, always returns `true`.
953
+ #
954
+ def integer?: () -> true
955
+
956
+ # <!--
957
+ # rdoc-file=rational.c
958
+ # - int.lcm(other_int) -> integer
959
+ # -->
960
+ # Returns the least common multiple of the two integers. The result is always
961
+ # positive. 0.lcm(x) and x.lcm(0) return zero.
962
+ #
963
+ # 36.lcm(60) #=> 180
964
+ # 2.lcm(2) #=> 2
965
+ # 3.lcm(-7) #=> 21
966
+ # ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297
967
+ #
968
+ def lcm: (Integer other_int) -> Integer
969
+
970
+ # <!--
971
+ # rdoc-file=numeric.rb
972
+ # - magnitude()
973
+ # -->
974
+ #
975
+ alias magnitude abs
976
+
977
+ # <!-- rdoc-file=numeric.c -->
978
+ # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
979
+ #
980
+ # For integer `n` and real number `r`, these expressions are equivalent:
981
+ #
982
+ # n % r
983
+ # n-r*(n/r).floor
984
+ # n.divmod(r)[1]
985
+ #
986
+ # See Numeric#divmod.
987
+ #
988
+ # Examples:
989
+ #
990
+ # 10 % 2 # => 0
991
+ # 10 % 3 # => 1
992
+ # 10 % 4 # => 2
993
+ #
994
+ # 10 % -2 # => 0
995
+ # 10 % -3 # => -2
996
+ # 10 % -4 # => -2
997
+ #
998
+ # 10 % 3.0 # => 1.0
999
+ # 10 % Rational(3, 1) # => (1/1)
1000
+ #
1001
+ alias modulo %
1002
+
1003
+ def negative?: () -> bool
1004
+
1005
+ # <!-- rdoc-file=numeric.c -->
1006
+ # Returns the successor integer of `self` (equivalent to <code>self + 1</code>):
1007
+ #
1008
+ # 1.succ #=> 2
1009
+ # -1.succ #=> 0
1010
+ #
1011
+ # Related: Integer#pred (predecessor value).
1012
+ #
1013
+ alias next succ
1014
+
1015
+ # <!--
1016
+ # rdoc-file=numeric.c
1017
+ # - nobits?(mask) -> true or false
1018
+ # -->
1019
+ # Returns `true` if no bit that is set (=1) in `mask` is also set in `self`;
1020
+ # returns `false` otherwise.
1021
+ #
1022
+ # Example values:
1023
+ #
1024
+ # 0b11110000 self
1025
+ # 0b00001111 mask
1026
+ # 0b00000000 self & mask
1027
+ # true self.nobits?(mask)
1028
+ #
1029
+ # 0b00000001 self
1030
+ # 0b11111111 mask
1031
+ # 0b00000001 self & mask
1032
+ # false self.nobits?(mask)
1033
+ #
1034
+ # Related: Integer#allbits?, Integer#anybits?.
1035
+ #
1036
+ def nobits?: (int mask) -> bool
1037
+
1038
+ # <!--
1039
+ # rdoc-file=numeric.rb
1040
+ # - numerator -> self
1041
+ # -->
1042
+ # Returns `self`.
1043
+ #
1044
+ def numerator: () -> self
1045
+
1046
+ # <!--
1047
+ # rdoc-file=numeric.rb
1048
+ # - odd? -> true or false
1049
+ # -->
1050
+ # Returns `true` if `self` is an odd number, `false` otherwise.
1051
+ #
1052
+ def odd?: () -> bool
1053
+
1054
+ # <!--
1055
+ # rdoc-file=numeric.rb
1056
+ # - ord -> self
1057
+ # -->
1058
+ # Returns `self`; intended for compatibility to character literals in Ruby 1.9.
1059
+ #
1060
+ def ord: () -> self
1061
+
1062
+ def polar: () -> [ Integer, Integer | Float ]
1063
+
1064
+ def positive?: () -> bool
1065
+
1066
+ # <!--
1067
+ # rdoc-file=numeric.c
1068
+ # - integer.pow(numeric) -> numeric
1069
+ # - integer.pow(integer, integer) -> integer
1070
+ # -->
1071
+ # Returns (modular) exponentiation as:
1072
+ #
1073
+ # a.pow(b) #=> same as a**b
1074
+ # a.pow(b, m) #=> same as (a**b) % m, but avoids huge temporary values
1075
+ #
1076
+ def pow: (Integer other) -> (Integer | Rational)
1077
+ | (Integer other, Integer modulo) -> Integer
1078
+ | (Float) -> (Float | Complex)
1079
+ | (Rational) -> (Float | Rational | Complex)
1080
+ | (Complex) -> Complex
1081
+
1082
+ # <!--
1083
+ # rdoc-file=numeric.c
1084
+ # - pred -> next_integer
1085
+ # -->
1086
+ # Returns the predecessor of `self` (equivalent to <code>self - 1</code>):
1087
+ #
1088
+ # 1.pred #=> 0
1089
+ # -1.pred #=> -2
1090
+ #
1091
+ # Related: Integer#succ (successor value).
1092
+ #
1093
+ def pred: () -> Integer
1094
+
1095
+ def quo: (Integer) -> Rational
1096
+ | (Float) -> Float
1097
+ | (Rational) -> Rational
1098
+ | (Complex) -> Complex
1099
+ | (Numeric) -> Numeric
1100
+
1101
+ # <!--
1102
+ # rdoc-file=rational.c
1103
+ # - int.rationalize([eps]) -> rational
1104
+ # -->
1105
+ # Returns the value as a rational. The optional argument `eps` is always
1106
+ # ignored.
1107
+ #
1108
+ def rationalize: (?Numeric eps) -> Rational
1109
+
1110
+ def rect: () -> [ Integer, Numeric ]
1111
+
1112
+ # <!--
1113
+ # rdoc-file=numeric.c
1114
+ # - remainder(other) -> real_number
1115
+ # -->
1116
+ # Returns the remainder after dividing `self` by `other`.
1117
+ #
1118
+ # Examples:
1119
+ #
1120
+ # 11.remainder(4) # => 3
1121
+ # 11.remainder(-4) # => 3
1122
+ # -11.remainder(4) # => -3
1123
+ # -11.remainder(-4) # => -3
1124
+ #
1125
+ # 12.remainder(4) # => 0
1126
+ # 12.remainder(-4) # => 0
1127
+ # -12.remainder(4) # => 0
1128
+ # -12.remainder(-4) # => 0
1129
+ #
1130
+ # 13.remainder(4.0) # => 1.0
1131
+ # 13.remainder(Rational(4, 1)) # => (1/1)
1132
+ #
1133
+ def remainder: (Integer) -> Integer
1134
+ | (Float) -> Float
1135
+ | (Rational) -> Rational
1136
+ | (Numeric) -> Numeric
1137
+
1138
+ # <!--
1139
+ # rdoc-file=numeric.c
1140
+ # - round(ndigits= 0, half: :up) -> integer
1141
+ # -->
1142
+ # Returns `self` rounded to the nearest value with a precision of `ndigits`
1143
+ # decimal digits.
1144
+ #
1145
+ # When `ndigits` is negative, the returned value has at least
1146
+ # <code>ndigits.abs</code> trailing zeros:
1147
+ #
1148
+ # 555.round(-1) # => 560
1149
+ # 555.round(-2) # => 600
1150
+ # 555.round(-3) # => 1000
1151
+ # -555.round(-2) # => -600
1152
+ # 555.round(-4) # => 0
1153
+ #
1154
+ # Returns `self` when `ndigits` is zero or positive.
1155
+ #
1156
+ # 555.round # => 555
1157
+ # 555.round(1) # => 555
1158
+ # 555.round(50) # => 555
1159
+ #
1160
+ # If keyword argument `half` is given, and `self` is equidistant from the two
1161
+ # candidate values, the rounding is according to the given `half` value:
1162
+ #
1163
+ # * <code>:up</code> or `nil`: round away from zero:
1164
+ #
1165
+ # 25.round(-1, half: :up) # => 30
1166
+ # (-25).round(-1, half: :up) # => -30
1167
+ #
1168
+ # * <code>:down</code>: round toward zero:
1169
+ #
1170
+ # 25.round(-1, half: :down) # => 20
1171
+ # (-25).round(-1, half: :down) # => -20
1172
+ #
1173
+ # * <code>:even</code>: round toward the candidate whose last nonzero digit is
1174
+ # even:
1175
+ #
1176
+ # 25.round(-1, half: :even) # => 20
1177
+ # 15.round(-1, half: :even) # => 20
1178
+ # (-25).round(-1, half: :even) # => -20
1179
+ #
1180
+ # Raises and exception if the value for `half` is invalid.
1181
+ #
1182
+ # Related: Integer#truncate.
1183
+ #
1184
+ def round: (?int digits, ?half: Numeric::round_mode) -> Integer
1185
+
1186
+ # <!--
1187
+ # rdoc-file=numeric.rb
1188
+ # - size -> integer
1189
+ # -->
1190
+ # Returns the number of bytes in the machine representation of `self`; the value
1191
+ # is system-dependent:
1192
+ #
1193
+ # 1.size # => 8
1194
+ # -1.size # => 8
1195
+ # 2147483647.size # => 8
1196
+ # (256**10 - 1).size # => 10
1197
+ # (256**20 - 1).size # => 20
1198
+ # (256**40 - 1).size # => 40
1199
+ #
1200
+ def size: () -> Integer
1201
+
1202
+ # <!--
1203
+ # rdoc-file=numeric.c
1204
+ # - succ -> next_integer
1205
+ # -->
1206
+ # Returns the successor integer of `self` (equivalent to <code>self + 1</code>):
1207
+ #
1208
+ # 1.succ #=> 2
1209
+ # -1.succ #=> 0
1210
+ #
1211
+ # Related: Integer#pred (predecessor value).
1212
+ #
1213
+ def succ: () -> Integer
1214
+
1215
+ # <!--
1216
+ # rdoc-file=numeric.rb
1217
+ # - times {|i| ... } -> self
1218
+ # - times -> enumerator
1219
+ # -->
1220
+ # Calls the given block `self` times with each integer in
1221
+ # <code>(0..self-1)</code>:
1222
+ #
1223
+ # a = []
1224
+ # 5.times {|i| a.push(i) } # => 5
1225
+ # a # => [0, 1, 2, 3, 4]
1226
+ #
1227
+ # With no block given, returns an Enumerator.
1228
+ #
1229
+ def times: () { (Integer i) -> void } -> self
1230
+ | () -> Enumerator[Integer, self]
1231
+
1232
+ # <!--
1233
+ # rdoc-file=numeric.c
1234
+ # - to_f -> float
1235
+ # -->
1236
+ # Converts `self` to a Float:
1237
+ #
1238
+ # 1.to_f # => 1.0
1239
+ # -1.to_f # => -1.0
1240
+ #
1241
+ # If the value of `self` does not fit in a Float, the result is infinity:
1242
+ #
1243
+ # (10**400).to_f # => Infinity
1244
+ # (-10**400).to_f # => -Infinity
1245
+ #
1246
+ def to_f: () -> Float
1247
+
1248
+ # <!--
1249
+ # rdoc-file=numeric.rb
1250
+ # - to_i -> self
1251
+ # -->
1252
+ # Returns `self` (which is already an Integer).
1253
+ #
1254
+ def to_i: () -> self
1255
+
1256
+ # <!--
1257
+ # rdoc-file=numeric.rb
1258
+ # - to_int -> self
1259
+ # -->
1260
+ # Returns `self` (which is already an Integer).
1261
+ #
1262
+ alias to_int to_i
1263
+
1264
+ # <!--
1265
+ # rdoc-file=rational.c
1266
+ # - int.to_r -> rational
1267
+ # -->
1268
+ # Returns the value as a rational.
1269
+ #
1270
+ # 1.to_r #=> (1/1)
1271
+ # (1<<64).to_r #=> (18446744073709551616/1)
1272
+ #
1273
+ def to_r: () -> Rational
1274
+
1275
+ # <!--
1276
+ # rdoc-file=numeric.c
1277
+ # - to_s(base = 10) -> string
1278
+ # -->
1279
+ # Returns a string containing the place-value representation of `self` in radix
1280
+ # `base` (in 2..36).
1281
+ #
1282
+ # 12345.to_s # => "12345"
1283
+ # 12345.to_s(2) # => "11000000111001"
1284
+ # 12345.to_s(8) # => "30071"
1285
+ # 12345.to_s(10) # => "12345"
1286
+ # 12345.to_s(16) # => "3039"
1287
+ # 12345.to_s(36) # => "9ix"
1288
+ # 78546939656932.to_s(36) # => "rubyrules"
1289
+ #
1290
+ # Raises an exception if `base` is out of range.
1291
+ #
1292
+ def to_s: (?int base) -> String
1293
+
1294
+ # <!--
1295
+ # rdoc-file=numeric.c
1296
+ # - truncate(ndigits = 0) -> integer
1297
+ # -->
1298
+ # Returns `self` truncated (toward zero) to a precision of `ndigits` decimal
1299
+ # digits.
1300
+ #
1301
+ # When `ndigits` is negative, the returned value has at least
1302
+ # <code>ndigits.abs</code> trailing zeros:
1303
+ #
1304
+ # 555.truncate(-1) # => 550
1305
+ # 555.truncate(-2) # => 500
1306
+ # -555.truncate(-2) # => -500
1307
+ #
1308
+ # Returns `self` when `ndigits` is zero or positive.
1309
+ #
1310
+ # 555.truncate # => 555
1311
+ # 555.truncate(50) # => 555
1312
+ #
1313
+ # Related: Integer#round.
1314
+ #
1315
+ def truncate: (?int ndigits) -> Integer
1316
+
1317
+ # <!--
1318
+ # rdoc-file=numeric.c
1319
+ # - upto(limit) {|i| ... } -> self
1320
+ # - upto(limit) -> enumerator
1321
+ # -->
1322
+ # Calls the given block with each integer value from `self` up to `limit`;
1323
+ # returns `self`:
1324
+ #
1325
+ # a = []
1326
+ # 5.upto(10) {|i| a << i } # => 5
1327
+ # a # => [5, 6, 7, 8, 9, 10]
1328
+ # a = []
1329
+ # -5.upto(0) {|i| a << i } # => -5
1330
+ # a # => [-5, -4, -3, -2, -1, 0]
1331
+ # 5.upto(4) {|i| fail 'Cannot happen' } # => 5
1332
+ #
1333
+ # With no block given, returns an Enumerator.
1334
+ #
1335
+ def upto: (Numeric limit) { (Integer) -> void } -> Integer
1336
+ | (Numeric limit) -> ::Enumerator[Integer, self]
1337
+
1338
+ # <!--
1339
+ # rdoc-file=numeric.rb
1340
+ # - zero? -> true or false
1341
+ # -->
1342
+ # Returns `true` if `self` has a zero value, `false` otherwise.
1343
+ #
1344
+ def zero?: () -> bool
1345
+
1346
+ # <!--
1347
+ # rdoc-file=numeric.c
1348
+ # - self | other -> integer
1349
+ # -->
1350
+ # Bitwise OR; each bit in the result is 1 if either corresponding bit in `self`
1351
+ # or `other` is 1, 0 otherwise:
1352
+ #
1353
+ # "%04b" % (0b0101 | 0b0110) # => "0111"
1354
+ #
1355
+ # Raises an exception if `other` is not an Integer.
1356
+ #
1357
+ # Related: Integer#& (bitwise AND), Integer#^ (bitwise EXCLUSIVE OR).
1358
+ #
1359
+ def |: (Integer) -> Integer
1360
+
1361
+ # <!--
1362
+ # rdoc-file=numeric.rb
1363
+ # - ~int -> integer
1364
+ # -->
1365
+ # One's complement: returns the value of `self` with each bit inverted.
1366
+ #
1367
+ # Because an integer value is conceptually of infinite length, the result acts
1368
+ # as if it had an infinite number of one bits to the left. In hex
1369
+ # representations, this is displayed as two periods to the left of the digits:
1370
+ #
1371
+ # sprintf("%X", ~0x1122334455) # => "..FEEDDCCBBAA"
1372
+ #
1373
+ def ~: () -> Integer
1374
+ end