rbs-relaxed 3.9.0.1

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 (484) hide show
  1. checksums.yaml +7 -0
  2. data/.github/dependabot.yml +22 -0
  3. data/.github/workflows/comments.yml +35 -0
  4. data/.github/workflows/dependabot.yml +30 -0
  5. data/.github/workflows/ruby.yml +82 -0
  6. data/.github/workflows/typecheck.yml +38 -0
  7. data/.github/workflows/windows.yml +43 -0
  8. data/.gitignore +23 -0
  9. data/.rubocop.yml +68 -0
  10. data/BSDL +22 -0
  11. data/CHANGELOG.md +1868 -0
  12. data/COPYING +56 -0
  13. data/README.md +203 -0
  14. data/Rakefile +417 -0
  15. data/Steepfile +44 -0
  16. data/config.yml +313 -0
  17. data/core/array.rbs +4062 -0
  18. data/core/basic_object.rbs +375 -0
  19. data/core/binding.rbs +150 -0
  20. data/core/builtin.rbs +277 -0
  21. data/core/class.rbs +220 -0
  22. data/core/comparable.rbs +171 -0
  23. data/core/complex.rbs +786 -0
  24. data/core/constants.rbs +96 -0
  25. data/core/data.rbs +415 -0
  26. data/core/dir.rbs +981 -0
  27. data/core/encoding.rbs +1371 -0
  28. data/core/enumerable.rbs +2405 -0
  29. data/core/enumerator/product.rbs +92 -0
  30. data/core/enumerator.rbs +630 -0
  31. data/core/env.rbs +6 -0
  32. data/core/errno.rbs +673 -0
  33. data/core/errors.rbs +760 -0
  34. data/core/exception.rbs +485 -0
  35. data/core/false_class.rbs +82 -0
  36. data/core/fiber.rbs +550 -0
  37. data/core/fiber_error.rbs +11 -0
  38. data/core/file.rbs +2936 -0
  39. data/core/file_test.rbs +331 -0
  40. data/core/float.rbs +1151 -0
  41. data/core/gc.rbs +644 -0
  42. data/core/global_variables.rbs +184 -0
  43. data/core/hash.rbs +1861 -0
  44. data/core/integer.rbs +1413 -0
  45. data/core/io/buffer.rbs +984 -0
  46. data/core/io/wait.rbs +70 -0
  47. data/core/io.rbs +3406 -0
  48. data/core/kernel.rbs +3096 -0
  49. data/core/marshal.rbs +207 -0
  50. data/core/match_data.rbs +635 -0
  51. data/core/math.rbs +729 -0
  52. data/core/method.rbs +386 -0
  53. data/core/module.rbs +1704 -0
  54. data/core/nil_class.rbs +209 -0
  55. data/core/numeric.rbs +818 -0
  56. data/core/object.rbs +110 -0
  57. data/core/object_space/weak_key_map.rbs +166 -0
  58. data/core/object_space.rbs +190 -0
  59. data/core/proc.rbs +868 -0
  60. data/core/process.rbs +2296 -0
  61. data/core/ractor.rbs +1068 -0
  62. data/core/random.rbs +237 -0
  63. data/core/range.rbs +1107 -0
  64. data/core/rational.rbs +531 -0
  65. data/core/rb_config.rbs +88 -0
  66. data/core/rbs/unnamed/argf.rbs +1229 -0
  67. data/core/rbs/unnamed/env_class.rbs +1209 -0
  68. data/core/rbs/unnamed/random.rbs +293 -0
  69. data/core/refinement.rbs +59 -0
  70. data/core/regexp.rbs +1930 -0
  71. data/core/ruby_vm.rbs +765 -0
  72. data/core/rubygems/basic_specification.rbs +6 -0
  73. data/core/rubygems/config_file.rbs +38 -0
  74. data/core/rubygems/dependency_installer.rbs +6 -0
  75. data/core/rubygems/errors.rbs +176 -0
  76. data/core/rubygems/installer.rbs +15 -0
  77. data/core/rubygems/path_support.rbs +6 -0
  78. data/core/rubygems/platform.rbs +7 -0
  79. data/core/rubygems/request_set.rbs +49 -0
  80. data/core/rubygems/requirement.rbs +148 -0
  81. data/core/rubygems/rubygems.rbs +1171 -0
  82. data/core/rubygems/source_list.rbs +15 -0
  83. data/core/rubygems/specification.rbs +23 -0
  84. data/core/rubygems/stream_ui.rbs +5 -0
  85. data/core/rubygems/uninstaller.rbs +10 -0
  86. data/core/rubygems/version.rbs +294 -0
  87. data/core/set.rbs +621 -0
  88. data/core/signal.rbs +100 -0
  89. data/core/string.rbs +3583 -0
  90. data/core/struct.rbs +667 -0
  91. data/core/symbol.rbs +475 -0
  92. data/core/thread.rbs +1765 -0
  93. data/core/thread_group.rbs +79 -0
  94. data/core/time.rbs +1762 -0
  95. data/core/trace_point.rbs +477 -0
  96. data/core/true_class.rbs +98 -0
  97. data/core/unbound_method.rbs +329 -0
  98. data/core/warning.rbs +87 -0
  99. data/docs/CONTRIBUTING.md +106 -0
  100. data/docs/architecture.md +110 -0
  101. data/docs/collection.md +192 -0
  102. data/docs/data_and_struct.md +86 -0
  103. data/docs/gem.md +57 -0
  104. data/docs/rbs_by_example.md +309 -0
  105. data/docs/repo.md +125 -0
  106. data/docs/sigs.md +167 -0
  107. data/docs/stdlib.md +147 -0
  108. data/docs/syntax.md +910 -0
  109. data/docs/tools.md +17 -0
  110. data/exe/rbs +7 -0
  111. data/ext/rbs_extension/extconf.rb +15 -0
  112. data/ext/rbs_extension/lexer.c +2728 -0
  113. data/ext/rbs_extension/lexer.h +179 -0
  114. data/ext/rbs_extension/lexer.re +147 -0
  115. data/ext/rbs_extension/lexstate.c +175 -0
  116. data/ext/rbs_extension/location.c +325 -0
  117. data/ext/rbs_extension/location.h +85 -0
  118. data/ext/rbs_extension/main.c +33 -0
  119. data/ext/rbs_extension/parser.c +2973 -0
  120. data/ext/rbs_extension/parser.h +18 -0
  121. data/ext/rbs_extension/parserstate.c +397 -0
  122. data/ext/rbs_extension/parserstate.h +163 -0
  123. data/ext/rbs_extension/rbs_extension.h +31 -0
  124. data/ext/rbs_extension/unescape.c +32 -0
  125. data/goodcheck.yml +91 -0
  126. data/include/rbs/constants.h +82 -0
  127. data/include/rbs/ruby_objs.h +72 -0
  128. data/include/rbs/util/rbs_constant_pool.h +219 -0
  129. data/include/rbs.h +7 -0
  130. data/lib/rbs/ancestor_graph.rb +92 -0
  131. data/lib/rbs/annotate/annotations.rb +199 -0
  132. data/lib/rbs/annotate/formatter.rb +92 -0
  133. data/lib/rbs/annotate/rdoc_annotator.rb +400 -0
  134. data/lib/rbs/annotate/rdoc_source.rb +131 -0
  135. data/lib/rbs/annotate.rb +8 -0
  136. data/lib/rbs/ast/annotation.rb +29 -0
  137. data/lib/rbs/ast/comment.rb +29 -0
  138. data/lib/rbs/ast/declarations.rb +467 -0
  139. data/lib/rbs/ast/directives.rb +49 -0
  140. data/lib/rbs/ast/members.rb +451 -0
  141. data/lib/rbs/ast/type_param.rb +225 -0
  142. data/lib/rbs/ast/visitor.rb +137 -0
  143. data/lib/rbs/buffer.rb +67 -0
  144. data/lib/rbs/builtin_names.rb +58 -0
  145. data/lib/rbs/cli/colored_io.rb +48 -0
  146. data/lib/rbs/cli/diff.rb +83 -0
  147. data/lib/rbs/cli/validate.rb +357 -0
  148. data/lib/rbs/cli.rb +1223 -0
  149. data/lib/rbs/collection/cleaner.rb +38 -0
  150. data/lib/rbs/collection/config/lockfile.rb +92 -0
  151. data/lib/rbs/collection/config/lockfile_generator.rb +218 -0
  152. data/lib/rbs/collection/config.rb +81 -0
  153. data/lib/rbs/collection/installer.rb +32 -0
  154. data/lib/rbs/collection/sources/base.rb +14 -0
  155. data/lib/rbs/collection/sources/git.rb +258 -0
  156. data/lib/rbs/collection/sources/local.rb +81 -0
  157. data/lib/rbs/collection/sources/rubygems.rb +48 -0
  158. data/lib/rbs/collection/sources/stdlib.rb +50 -0
  159. data/lib/rbs/collection/sources.rb +38 -0
  160. data/lib/rbs/collection.rb +16 -0
  161. data/lib/rbs/constant.rb +28 -0
  162. data/lib/rbs/definition.rb +401 -0
  163. data/lib/rbs/definition_builder/ancestor_builder.rb +620 -0
  164. data/lib/rbs/definition_builder/method_builder.rb +254 -0
  165. data/lib/rbs/definition_builder.rb +845 -0
  166. data/lib/rbs/diff.rb +125 -0
  167. data/lib/rbs/environment/use_map.rb +77 -0
  168. data/lib/rbs/environment.rb +829 -0
  169. data/lib/rbs/environment_loader.rb +173 -0
  170. data/lib/rbs/environment_walker.rb +155 -0
  171. data/lib/rbs/errors.rb +645 -0
  172. data/lib/rbs/factory.rb +18 -0
  173. data/lib/rbs/file_finder.rb +28 -0
  174. data/lib/rbs/location_aux.rb +138 -0
  175. data/lib/rbs/locator.rb +243 -0
  176. data/lib/rbs/method_type.rb +143 -0
  177. data/lib/rbs/namespace.rb +125 -0
  178. data/lib/rbs/parser/lex_result.rb +15 -0
  179. data/lib/rbs/parser/token.rb +23 -0
  180. data/lib/rbs/parser_aux.rb +114 -0
  181. data/lib/rbs/prototype/helpers.rb +140 -0
  182. data/lib/rbs/prototype/node_usage.rb +99 -0
  183. data/lib/rbs/prototype/rb.rb +840 -0
  184. data/lib/rbs/prototype/rbi.rb +641 -0
  185. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  186. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  187. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  188. data/lib/rbs/prototype/runtime.rb +667 -0
  189. data/lib/rbs/repository.rb +127 -0
  190. data/lib/rbs/resolver/constant_resolver.rb +219 -0
  191. data/lib/rbs/resolver/type_name_resolver.rb +91 -0
  192. data/lib/rbs/sorter.rb +198 -0
  193. data/lib/rbs/substitution.rb +83 -0
  194. data/lib/rbs/subtractor.rb +201 -0
  195. data/lib/rbs/test/errors.rb +80 -0
  196. data/lib/rbs/test/guaranteed.rb +30 -0
  197. data/lib/rbs/test/hook.rb +212 -0
  198. data/lib/rbs/test/observer.rb +19 -0
  199. data/lib/rbs/test/setup.rb +84 -0
  200. data/lib/rbs/test/setup_helper.rb +50 -0
  201. data/lib/rbs/test/tester.rb +167 -0
  202. data/lib/rbs/test/type_check.rb +435 -0
  203. data/lib/rbs/test.rb +112 -0
  204. data/lib/rbs/type_alias_dependency.rb +100 -0
  205. data/lib/rbs/type_alias_regularity.rb +126 -0
  206. data/lib/rbs/type_name.rb +109 -0
  207. data/lib/rbs/types.rb +1596 -0
  208. data/lib/rbs/unit_test/convertibles.rb +176 -0
  209. data/lib/rbs/unit_test/spy.rb +138 -0
  210. data/lib/rbs/unit_test/type_assertions.rb +347 -0
  211. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  212. data/lib/rbs/unit_test.rb +6 -0
  213. data/lib/rbs/validator.rb +186 -0
  214. data/lib/rbs/variance_calculator.rb +189 -0
  215. data/lib/rbs/vendorer.rb +71 -0
  216. data/lib/rbs/version.rb +5 -0
  217. data/lib/rbs/writer.rb +424 -0
  218. data/lib/rbs.rb +94 -0
  219. data/lib/rdoc/discover.rb +20 -0
  220. data/lib/rdoc_plugin/parser.rb +163 -0
  221. data/rbs-relaxed.gemspec +48 -0
  222. data/schema/annotation.json +14 -0
  223. data/schema/comment.json +26 -0
  224. data/schema/decls.json +326 -0
  225. data/schema/function.json +87 -0
  226. data/schema/location.json +56 -0
  227. data/schema/members.json +266 -0
  228. data/schema/methodType.json +50 -0
  229. data/schema/typeParam.json +36 -0
  230. data/schema/types.json +317 -0
  231. data/sig/ancestor_builder.rbs +163 -0
  232. data/sig/ancestor_graph.rbs +60 -0
  233. data/sig/annotate/annotations.rbs +102 -0
  234. data/sig/annotate/formatter.rbs +24 -0
  235. data/sig/annotate/rdoc_annotater.rbs +82 -0
  236. data/sig/annotate/rdoc_source.rbs +30 -0
  237. data/sig/annotation.rbs +27 -0
  238. data/sig/buffer.rbs +32 -0
  239. data/sig/builtin_names.rbs +44 -0
  240. data/sig/cli/colored_io.rbs +15 -0
  241. data/sig/cli/diff.rbs +21 -0
  242. data/sig/cli/validate.rbs +43 -0
  243. data/sig/cli.rbs +87 -0
  244. data/sig/collection/cleaner.rbs +13 -0
  245. data/sig/collection/config/lockfile.rbs +74 -0
  246. data/sig/collection/config/lockfile_generator.rbs +66 -0
  247. data/sig/collection/config.rbs +46 -0
  248. data/sig/collection/installer.rbs +17 -0
  249. data/sig/collection/sources.rbs +214 -0
  250. data/sig/collection.rbs +4 -0
  251. data/sig/comment.rbs +26 -0
  252. data/sig/constant.rbs +21 -0
  253. data/sig/declarations.rbs +267 -0
  254. data/sig/definition.rbs +173 -0
  255. data/sig/definition_builder.rbs +165 -0
  256. data/sig/diff.rbs +28 -0
  257. data/sig/directives.rbs +77 -0
  258. data/sig/environment.rbs +279 -0
  259. data/sig/environment_loader.rbs +111 -0
  260. data/sig/environment_walker.rbs +65 -0
  261. data/sig/errors.rbs +405 -0
  262. data/sig/factory.rbs +5 -0
  263. data/sig/file_finder.rbs +28 -0
  264. data/sig/location.rbs +110 -0
  265. data/sig/locator.rbs +58 -0
  266. data/sig/manifest.yaml +7 -0
  267. data/sig/members.rbs +258 -0
  268. data/sig/method_builder.rbs +84 -0
  269. data/sig/method_types.rbs +58 -0
  270. data/sig/namespace.rbs +146 -0
  271. data/sig/parser.rbs +100 -0
  272. data/sig/prototype/helpers.rbs +27 -0
  273. data/sig/prototype/node_usage.rbs +20 -0
  274. data/sig/prototype/rb.rbs +96 -0
  275. data/sig/prototype/rbi.rbs +75 -0
  276. data/sig/prototype/runtime.rbs +182 -0
  277. data/sig/rbs.rbs +21 -0
  278. data/sig/rdoc/rbs.rbs +67 -0
  279. data/sig/repository.rbs +85 -0
  280. data/sig/resolver/constant_resolver.rbs +92 -0
  281. data/sig/resolver/context.rbs +34 -0
  282. data/sig/resolver/type_name_resolver.rbs +35 -0
  283. data/sig/shims/bundler.rbs +38 -0
  284. data/sig/shims/enumerable.rbs +5 -0
  285. data/sig/shims/rubygems.rbs +19 -0
  286. data/sig/sorter.rbs +41 -0
  287. data/sig/substitution.rbs +48 -0
  288. data/sig/subtractor.rbs +37 -0
  289. data/sig/test/errors.rbs +52 -0
  290. data/sig/test/guranteed.rbs +9 -0
  291. data/sig/test/type_check.rbs +19 -0
  292. data/sig/test.rbs +82 -0
  293. data/sig/type_alias_dependency.rbs +53 -0
  294. data/sig/type_alias_regularity.rbs +98 -0
  295. data/sig/type_param.rbs +110 -0
  296. data/sig/typename.rbs +79 -0
  297. data/sig/types.rbs +579 -0
  298. data/sig/unit_test/convertibles.rbs +154 -0
  299. data/sig/unit_test/spy.rbs +30 -0
  300. data/sig/unit_test/type_assertions.rbs +196 -0
  301. data/sig/unit_test/with_aliases.rbs +136 -0
  302. data/sig/use_map.rbs +35 -0
  303. data/sig/util.rbs +9 -0
  304. data/sig/validator.rbs +63 -0
  305. data/sig/variance_calculator.rbs +87 -0
  306. data/sig/vendorer.rbs +51 -0
  307. data/sig/version.rbs +3 -0
  308. data/sig/visitor.rbs +47 -0
  309. data/sig/writer.rbs +127 -0
  310. data/src/constants.c +153 -0
  311. data/src/ruby_objs.c +795 -0
  312. data/src/util/rbs_constant_pool.c +342 -0
  313. data/stdlib/abbrev/0/abbrev.rbs +66 -0
  314. data/stdlib/abbrev/0/array.rbs +26 -0
  315. data/stdlib/base64/0/base64.rbs +355 -0
  316. data/stdlib/benchmark/0/benchmark.rbs +452 -0
  317. data/stdlib/bigdecimal/0/big_decimal.rbs +1629 -0
  318. data/stdlib/bigdecimal-math/0/big_math.rbs +119 -0
  319. data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
  320. data/stdlib/cgi/0/core.rbs +1285 -0
  321. data/stdlib/cgi/0/manifest.yaml +3 -0
  322. data/stdlib/coverage/0/coverage.rbs +263 -0
  323. data/stdlib/csv/0/csv.rbs +3776 -0
  324. data/stdlib/csv/0/manifest.yaml +3 -0
  325. data/stdlib/date/0/date.rbs +1585 -0
  326. data/stdlib/date/0/date_time.rbs +616 -0
  327. data/stdlib/date/0/time.rbs +26 -0
  328. data/stdlib/dbm/0/dbm.rbs +421 -0
  329. data/stdlib/delegate/0/delegator.rbs +184 -0
  330. data/stdlib/delegate/0/kernel.rbs +47 -0
  331. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  332. data/stdlib/did_you_mean/0/did_you_mean.rbs +343 -0
  333. data/stdlib/digest/0/digest.rbs +577 -0
  334. data/stdlib/erb/0/erb.rbs +532 -0
  335. data/stdlib/etc/0/etc.rbs +865 -0
  336. data/stdlib/fileutils/0/fileutils.rbs +1734 -0
  337. data/stdlib/find/0/find.rbs +49 -0
  338. data/stdlib/forwardable/0/forwardable.rbs +268 -0
  339. data/stdlib/io-console/0/io-console.rbs +414 -0
  340. data/stdlib/ipaddr/0/ipaddr.rbs +428 -0
  341. data/stdlib/json/0/json.rbs +1916 -0
  342. data/stdlib/kconv/0/kconv.rbs +166 -0
  343. data/stdlib/logger/0/formatter.rbs +45 -0
  344. data/stdlib/logger/0/log_device.rbs +100 -0
  345. data/stdlib/logger/0/logger.rbs +796 -0
  346. data/stdlib/logger/0/manifest.yaml +2 -0
  347. data/stdlib/logger/0/period.rbs +17 -0
  348. data/stdlib/logger/0/severity.rbs +34 -0
  349. data/stdlib/minitest/0/kernel.rbs +42 -0
  350. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
  351. data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
  352. data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
  353. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
  354. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  355. data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
  356. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  357. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  358. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  359. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  360. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  361. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  362. data/stdlib/minitest/0/minitest/mock.rbs +64 -0
  363. data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
  364. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
  365. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  366. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  367. data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
  368. data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
  369. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  370. data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
  371. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  372. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  373. data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
  374. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  375. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  376. data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
  377. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  378. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
  379. data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
  380. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  381. data/stdlib/minitest/0/minitest/test.rbs +69 -0
  382. data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
  383. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  384. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  385. data/stdlib/minitest/0/minitest/unit.rbs +4 -0
  386. data/stdlib/minitest/0/minitest.rbs +115 -0
  387. data/stdlib/monitor/0/monitor.rbs +363 -0
  388. data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
  389. data/stdlib/net-http/0/manifest.yaml +3 -0
  390. data/stdlib/net-http/0/net-http.rbs +5552 -0
  391. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  392. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  393. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  394. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  395. data/stdlib/nkf/0/nkf.rbs +402 -0
  396. data/stdlib/objspace/0/objspace.rbs +487 -0
  397. data/stdlib/observable/0/observable.rbs +217 -0
  398. data/stdlib/open-uri/0/manifest.yaml +4 -0
  399. data/stdlib/open-uri/0/open-uri.rbs +393 -0
  400. data/stdlib/open3/0/open3.rbs +147 -0
  401. data/stdlib/openssl/0/manifest.yaml +3 -0
  402. data/stdlib/openssl/0/openssl.rbs +12113 -0
  403. data/stdlib/optparse/0/optparse.rbs +1725 -0
  404. data/stdlib/pathname/0/pathname.rbs +1406 -0
  405. data/stdlib/pp/0/manifest.yaml +2 -0
  406. data/stdlib/pp/0/pp.rbs +300 -0
  407. data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
  408. data/stdlib/pstore/0/pstore.rbs +603 -0
  409. data/stdlib/psych/0/core_ext.rbs +12 -0
  410. data/stdlib/psych/0/dbm.rbs +237 -0
  411. data/stdlib/psych/0/manifest.yaml +3 -0
  412. data/stdlib/psych/0/psych.rbs +402 -0
  413. data/stdlib/psych/0/store.rbs +59 -0
  414. data/stdlib/pty/0/pty.rbs +237 -0
  415. data/stdlib/rdoc/0/code_object.rbs +51 -0
  416. data/stdlib/rdoc/0/comment.rbs +59 -0
  417. data/stdlib/rdoc/0/context.rbs +153 -0
  418. data/stdlib/rdoc/0/markup.rbs +117 -0
  419. data/stdlib/rdoc/0/parser.rbs +56 -0
  420. data/stdlib/rdoc/0/rdoc.rbs +391 -0
  421. data/stdlib/rdoc/0/ri.rbs +17 -0
  422. data/stdlib/rdoc/0/store.rbs +48 -0
  423. data/stdlib/rdoc/0/top_level.rbs +97 -0
  424. data/stdlib/resolv/0/manifest.yaml +3 -0
  425. data/stdlib/resolv/0/resolv.rbs +1830 -0
  426. data/stdlib/ripper/0/ripper.rbs +1648 -0
  427. data/stdlib/securerandom/0/securerandom.rbs +62 -0
  428. data/stdlib/shellwords/0/shellwords.rbs +229 -0
  429. data/stdlib/singleton/0/singleton.rbs +131 -0
  430. data/stdlib/socket/0/addrinfo.rbs +666 -0
  431. data/stdlib/socket/0/basic_socket.rbs +590 -0
  432. data/stdlib/socket/0/constants.rbs +2295 -0
  433. data/stdlib/socket/0/ip_socket.rbs +92 -0
  434. data/stdlib/socket/0/socket.rbs +4157 -0
  435. data/stdlib/socket/0/socket_error.rbs +5 -0
  436. data/stdlib/socket/0/tcp_server.rbs +192 -0
  437. data/stdlib/socket/0/tcp_socket.rbs +79 -0
  438. data/stdlib/socket/0/udp_socket.rbs +133 -0
  439. data/stdlib/socket/0/unix_server.rbs +169 -0
  440. data/stdlib/socket/0/unix_socket.rbs +172 -0
  441. data/stdlib/stringio/0/stringio.rbs +567 -0
  442. data/stdlib/strscan/0/string_scanner.rbs +1627 -0
  443. data/stdlib/tempfile/0/tempfile.rbs +479 -0
  444. data/stdlib/time/0/time.rbs +432 -0
  445. data/stdlib/timeout/0/timeout.rbs +81 -0
  446. data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
  447. data/stdlib/tsort/0/cyclic.rbs +5 -0
  448. data/stdlib/tsort/0/interfaces.rbs +20 -0
  449. data/stdlib/tsort/0/tsort.rbs +409 -0
  450. data/stdlib/uri/0/common.rbs +582 -0
  451. data/stdlib/uri/0/file.rbs +118 -0
  452. data/stdlib/uri/0/ftp.rbs +13 -0
  453. data/stdlib/uri/0/generic.rbs +1108 -0
  454. data/stdlib/uri/0/http.rbs +104 -0
  455. data/stdlib/uri/0/https.rbs +14 -0
  456. data/stdlib/uri/0/ldap.rbs +230 -0
  457. data/stdlib/uri/0/ldaps.rbs +14 -0
  458. data/stdlib/uri/0/mailto.rbs +92 -0
  459. data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
  460. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  461. data/stdlib/uri/0/ws.rbs +13 -0
  462. data/stdlib/uri/0/wss.rbs +9 -0
  463. data/stdlib/yaml/0/manifest.yaml +2 -0
  464. data/stdlib/yaml/0/yaml.rbs +1 -0
  465. data/stdlib/zlib/0/buf_error.rbs +10 -0
  466. data/stdlib/zlib/0/data_error.rbs +10 -0
  467. data/stdlib/zlib/0/deflate.rbs +210 -0
  468. data/stdlib/zlib/0/error.rbs +20 -0
  469. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  470. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  471. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  472. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  473. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  474. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  475. data/stdlib/zlib/0/gzip_writer.rbs +166 -0
  476. data/stdlib/zlib/0/inflate.rbs +180 -0
  477. data/stdlib/zlib/0/mem_error.rbs +10 -0
  478. data/stdlib/zlib/0/need_dict.rbs +13 -0
  479. data/stdlib/zlib/0/stream_end.rbs +11 -0
  480. data/stdlib/zlib/0/stream_error.rbs +11 -0
  481. data/stdlib/zlib/0/version_error.rbs +11 -0
  482. data/stdlib/zlib/0/zlib.rbs +449 -0
  483. data/stdlib/zlib/0/zstream.rbs +200 -0
  484. metadata +532 -0
data/core/integer.rbs ADDED
@@ -0,0 +1,1413 @@
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
+ # `(0..self-1)`.
92
+ # * #upto: Calls the given block with each integer value from `self` up to the
93
+ # given value.
94
+ #
95
+ class Integer < Numeric
96
+ # <!--
97
+ # rdoc-file=numeric.c
98
+ # - Integer.sqrt(numeric) -> integer
99
+ # -->
100
+ # Returns the integer square root of the non-negative integer `n`, which is the
101
+ # largest non-negative integer less than or equal to the square root of
102
+ # `numeric`.
103
+ #
104
+ # Integer.sqrt(0) # => 0
105
+ # Integer.sqrt(1) # => 1
106
+ # Integer.sqrt(24) # => 4
107
+ # Integer.sqrt(25) # => 5
108
+ # Integer.sqrt(10**400) # => 10**200
109
+ #
110
+ # If `numeric` is not an Integer, it is converted to an Integer:
111
+ #
112
+ # Integer.sqrt(Complex(4, 0)) # => 2
113
+ # Integer.sqrt(Rational(4, 1)) # => 2
114
+ # Integer.sqrt(4.0) # => 2
115
+ # Integer.sqrt(3.14159) # => 1
116
+ #
117
+ # This method is equivalent to `Math.sqrt(numeric).floor`, except that the
118
+ # result of the latter code may differ from the true value due to the limited
119
+ # precision of floating point arithmetic.
120
+ #
121
+ # Integer.sqrt(10**46) # => 100000000000000000000000
122
+ # Math.sqrt(10**46).floor # => 99999999999999991611392
123
+ #
124
+ # Raises an exception if `numeric` is negative.
125
+ #
126
+ def self.sqrt: (int n) -> Integer
127
+
128
+ # <!--
129
+ # rdoc-file=numeric.c
130
+ # - Integer.try_convert(object) -> object, integer, or nil
131
+ # -->
132
+ # If `object` is an Integer object, returns `object`.
133
+ # Integer.try_convert(1) # => 1
134
+ #
135
+ # Otherwise if `object` responds to `:to_int`, calls `object.to_int` and returns
136
+ # the result.
137
+ # Integer.try_convert(1.25) # => 1
138
+ #
139
+ # Returns `nil` if `object` does not respond to `:to_int`
140
+ # Integer.try_convert([]) # => nil
141
+ #
142
+ # Raises an exception unless `object.to_int` returns an Integer object.
143
+ #
144
+ def self.try_convert: (int) -> Integer
145
+ | (untyped) -> Integer?
146
+
147
+ # <!--
148
+ # rdoc-file=numeric.c
149
+ # - self % other -> real_number
150
+ # -->
151
+ # Returns `self` modulo `other` as a real number.
152
+ #
153
+ # For integer `n` and real number `r`, these expressions are equivalent:
154
+ #
155
+ # n % r
156
+ # n-r*(n/r).floor
157
+ # n.divmod(r)[1]
158
+ #
159
+ # See Numeric#divmod.
160
+ #
161
+ # Examples:
162
+ #
163
+ # 10 % 2 # => 0
164
+ # 10 % 3 # => 1
165
+ # 10 % 4 # => 2
166
+ #
167
+ # 10 % -2 # => 0
168
+ # 10 % -3 # => -2
169
+ # 10 % -4 # => -2
170
+ #
171
+ # 10 % 3.0 # => 1.0
172
+ # 10 % Rational(3, 1) # => (1/1)
173
+ #
174
+ def %: (Float) -> Float
175
+ | (Rational) -> Rational
176
+ | (Integer) -> Integer
177
+ | (Numeric) -> Numeric
178
+
179
+ # <!--
180
+ # rdoc-file=numeric.c
181
+ # - self & other -> integer
182
+ # -->
183
+ # Bitwise AND; each bit in the result is 1 if both corresponding bits in `self`
184
+ # and `other` are 1, 0 otherwise:
185
+ #
186
+ # "%04b" % (0b0101 & 0b0110) # => "0100"
187
+ #
188
+ # Raises an exception if `other` is not an Integer.
189
+ #
190
+ # Related: Integer#| (bitwise OR), Integer#^ (bitwise EXCLUSIVE OR).
191
+ #
192
+ def &: (Integer) -> Integer
193
+
194
+ # <!--
195
+ # rdoc-file=numeric.c
196
+ # - self * numeric -> numeric_result
197
+ # -->
198
+ # Performs multiplication:
199
+ #
200
+ # 4 * 2 # => 8
201
+ # 4 * -2 # => -8
202
+ # -4 * 2 # => -8
203
+ # 4 * 2.0 # => 8.0
204
+ # 4 * Rational(1, 3) # => (4/3)
205
+ # 4 * Complex(2, 0) # => (8+0i)
206
+ #
207
+ def *: (Float) -> Float
208
+ | (Rational) -> Rational
209
+ | (Complex) -> Complex
210
+ | (Integer) -> Integer
211
+
212
+ # <!--
213
+ # rdoc-file=numeric.c
214
+ # - self ** numeric -> numeric_result
215
+ # -->
216
+ # Raises `self` to the power of `numeric`:
217
+ #
218
+ # 2 ** 3 # => 8
219
+ # 2 ** -3 # => (1/8)
220
+ # -2 ** 3 # => -8
221
+ # -2 ** -3 # => (-1/8)
222
+ # 2 ** 3.3 # => 9.849155306759329
223
+ # 2 ** Rational(3, 1) # => (8/1)
224
+ # 2 ** Complex(3, 0) # => (8+0i)
225
+ #
226
+ def **: (Integer) -> Numeric
227
+ | (Float) -> Numeric
228
+ | (Rational) -> Numeric
229
+ | (Complex) -> Complex
230
+
231
+ # <!--
232
+ # rdoc-file=numeric.c
233
+ # - self + numeric -> numeric_result
234
+ # -->
235
+ # Performs addition:
236
+ #
237
+ # 2 + 2 # => 4
238
+ # -2 + 2 # => 0
239
+ # -2 + -2 # => -4
240
+ # 2 + 2.0 # => 4.0
241
+ # 2 + Rational(2, 1) # => (4/1)
242
+ # 2 + Complex(2, 0) # => (4+0i)
243
+ #
244
+ def +: (Integer) -> Integer
245
+ | (Float) -> Float
246
+ | (Rational) -> Rational
247
+ | (Complex) -> Complex
248
+
249
+ def +@: () -> Integer
250
+
251
+ # <!--
252
+ # rdoc-file=numeric.c
253
+ # - self - numeric -> numeric_result
254
+ # -->
255
+ # Performs subtraction:
256
+ #
257
+ # 4 - 2 # => 2
258
+ # -4 - 2 # => -6
259
+ # -4 - -2 # => -2
260
+ # 4 - 2.0 # => 2.0
261
+ # 4 - Rational(2, 1) # => (2/1)
262
+ # 4 - Complex(2, 0) # => (2+0i)
263
+ #
264
+ def -: (Integer) -> Integer
265
+ | (Float) -> Float
266
+ | (Rational) -> Rational
267
+ | (Complex) -> Complex
268
+
269
+ # <!--
270
+ # rdoc-file=numeric.rb
271
+ # - -int -> integer
272
+ # -->
273
+ # Returns `self`, negated.
274
+ #
275
+ def -@: () -> Integer
276
+
277
+ # <!--
278
+ # rdoc-file=numeric.c
279
+ # - self / numeric -> numeric_result
280
+ # -->
281
+ # Performs division; for integer `numeric`, truncates the result to an integer:
282
+ #
283
+ # 4 / 3 # => 1
284
+ # 4 / -3 # => -2
285
+ # -4 / 3 # => -2
286
+ # -4 / -3 # => 1
287
+ #
288
+ # For other +numeric+, returns non-integer result:
289
+ #
290
+ # 4 / 3.0 # => 1.3333333333333333
291
+ # 4 / Rational(3, 1) # => (4/3)
292
+ # 4 / Complex(3, 0) # => ((4/3)+0i)
293
+ #
294
+ def /: (Integer) -> Integer
295
+ | (Float) -> Float
296
+ | (Rational) -> Rational
297
+ | (Complex) -> Complex
298
+
299
+ # <!--
300
+ # rdoc-file=numeric.c
301
+ # - self < other -> true or false
302
+ # -->
303
+ # Returns `true` if the value of `self` is less than that of `other`:
304
+ #
305
+ # 1 < 0 # => false
306
+ # 1 < 1 # => false
307
+ # 1 < 2 # => true
308
+ # 1 < 0.5 # => false
309
+ # 1 < Rational(1, 2) # => false
310
+ #
311
+ # Raises an exception if the comparison cannot be made.
312
+ #
313
+ def <: (Numeric) -> bool
314
+
315
+ # <!--
316
+ # rdoc-file=numeric.c
317
+ # - self << count -> integer
318
+ # -->
319
+ # Returns `self` with bits shifted `count` positions to the left, or to the
320
+ # right if `count` is negative:
321
+ #
322
+ # n = 0b11110000
323
+ # "%08b" % (n << 1) # => "111100000"
324
+ # "%08b" % (n << 3) # => "11110000000"
325
+ # "%08b" % (n << -1) # => "01111000"
326
+ # "%08b" % (n << -3) # => "00011110"
327
+ #
328
+ # Related: Integer#>>.
329
+ #
330
+ def <<: (int) -> Integer
331
+
332
+ # <!--
333
+ # rdoc-file=numeric.c
334
+ # - self <= real -> true or false
335
+ # -->
336
+ # Returns `true` if the value of `self` is less than or equal to that of
337
+ # `other`:
338
+ #
339
+ # 1 <= 0 # => false
340
+ # 1 <= 1 # => true
341
+ # 1 <= 2 # => true
342
+ # 1 <= 0.5 # => false
343
+ # 1 <= Rational(1, 2) # => false
344
+ #
345
+ # Raises an exception if the comparison cannot be made.
346
+ #
347
+ def <=: (Numeric) -> bool
348
+
349
+ # <!--
350
+ # rdoc-file=numeric.c
351
+ # - self <=> other -> -1, 0, +1, or nil
352
+ # -->
353
+ # Returns:
354
+ #
355
+ # * -1, if `self` is less than `other`.
356
+ # * 0, if `self` is equal to `other`.
357
+ # * 1, if `self` is greater then `other`.
358
+ # * `nil`, if `self` and `other` are incomparable.
359
+ #
360
+ # Examples:
361
+ #
362
+ # 1 <=> 2 # => -1
363
+ # 1 <=> 1 # => 0
364
+ # 1 <=> 0 # => 1
365
+ # 1 <=> 'foo' # => nil
366
+ #
367
+ # 1 <=> 1.0 # => 0
368
+ # 1 <=> Rational(1, 1) # => 0
369
+ # 1 <=> Complex(1, 0) # => 0
370
+ #
371
+ # This method is the basis for comparisons in module Comparable.
372
+ #
373
+ def <=>: (Integer | Rational) -> Integer
374
+ | (untyped) -> Integer?
375
+
376
+ # <!-- rdoc-file=numeric.c -->
377
+ # Returns `true` if `self` is numerically equal to `other`; `false` otherwise.
378
+ #
379
+ # 1 == 2 #=> false
380
+ # 1 == 1.0 #=> true
381
+ #
382
+ # Related: Integer#eql? (requires `other` to be an Integer).
383
+ #
384
+ def ==: (untyped) -> bool
385
+
386
+ # <!--
387
+ # rdoc-file=numeric.c
388
+ # - self == other -> true or false
389
+ # -->
390
+ # Returns `true` if `self` is numerically equal to `other`; `false` otherwise.
391
+ #
392
+ # 1 == 2 #=> false
393
+ # 1 == 1.0 #=> true
394
+ #
395
+ # Related: Integer#eql? (requires `other` to be an Integer).
396
+ #
397
+ def ===: (untyped) -> bool
398
+
399
+ # <!--
400
+ # rdoc-file=numeric.c
401
+ # - self > other -> true or false
402
+ # -->
403
+ # Returns `true` if the value of `self` is greater than that of `other`:
404
+ #
405
+ # 1 > 0 # => true
406
+ # 1 > 1 # => false
407
+ # 1 > 2 # => false
408
+ # 1 > 0.5 # => true
409
+ # 1 > Rational(1, 2) # => true
410
+ #
411
+ # Raises an exception if the comparison cannot be made.
412
+ #
413
+ def >: (Numeric) -> bool
414
+
415
+ # <!--
416
+ # rdoc-file=numeric.c
417
+ # - self >= real -> true or false
418
+ # -->
419
+ # Returns `true` if the value of `self` is greater than or equal to that of
420
+ # `other`:
421
+ #
422
+ # 1 >= 0 # => true
423
+ # 1 >= 1 # => true
424
+ # 1 >= 2 # => false
425
+ # 1 >= 0.5 # => true
426
+ # 1 >= Rational(1, 2) # => true
427
+ #
428
+ # Raises an exception if the comparison cannot be made.
429
+ #
430
+ def >=: (Numeric) -> bool
431
+
432
+ # <!--
433
+ # rdoc-file=numeric.c
434
+ # - self >> count -> integer
435
+ # -->
436
+ # Returns `self` with bits shifted `count` positions to the right, or to the
437
+ # left if `count` is negative:
438
+ #
439
+ # n = 0b11110000
440
+ # "%08b" % (n >> 1) # => "01111000"
441
+ # "%08b" % (n >> 3) # => "00011110"
442
+ # "%08b" % (n >> -1) # => "111100000"
443
+ # "%08b" % (n >> -3) # => "11110000000"
444
+ #
445
+ # Related: Integer#<<.
446
+ #
447
+ def >>: (int) -> Integer
448
+
449
+ # <!--
450
+ # rdoc-file=numeric.c
451
+ # - self[offset] -> 0 or 1
452
+ # - self[offset, size] -> integer
453
+ # - self[range] -> integer
454
+ # -->
455
+ # Returns a slice of bits from `self`.
456
+ #
457
+ # With argument `offset`, returns the bit at the given offset, where offset 0
458
+ # refers to the least significant bit:
459
+ #
460
+ # n = 0b10 # => 2
461
+ # n[0] # => 0
462
+ # n[1] # => 1
463
+ # n[2] # => 0
464
+ # n[3] # => 0
465
+ #
466
+ # In principle, `n[i]` is equivalent to `(n >> i) & 1`. Thus, negative index
467
+ # always returns zero:
468
+ #
469
+ # 255[-1] # => 0
470
+ #
471
+ # With arguments `offset` and `size`, returns `size` bits from `self`, beginning
472
+ # at `offset` and including bits of greater significance:
473
+ #
474
+ # n = 0b111000 # => 56
475
+ # "%010b" % n[0, 10] # => "0000111000"
476
+ # "%010b" % n[4, 10] # => "0000000011"
477
+ #
478
+ # With argument `range`, returns `range.size` bits from `self`, beginning at
479
+ # `range.begin` and including bits of greater significance:
480
+ #
481
+ # n = 0b111000 # => 56
482
+ # "%010b" % n[0..9] # => "0000111000"
483
+ # "%010b" % n[4..9] # => "0000000011"
484
+ #
485
+ # Raises an exception if the slice cannot be constructed.
486
+ #
487
+ def []: (int) -> Integer
488
+ | (int i, int len) -> Integer
489
+ | (Range[int]) -> Integer
490
+
491
+ # <!--
492
+ # rdoc-file=numeric.c
493
+ # - self ^ other -> integer
494
+ # -->
495
+ # Bitwise EXCLUSIVE OR; each bit in the result is 1 if the corresponding bits in
496
+ # `self` and `other` are different, 0 otherwise:
497
+ #
498
+ # "%04b" % (0b0101 ^ 0b0110) # => "0011"
499
+ #
500
+ # Raises an exception if `other` is not an Integer.
501
+ #
502
+ # Related: Integer#& (bitwise AND), Integer#| (bitwise OR).
503
+ #
504
+ def ^: (Integer) -> Integer
505
+
506
+ # <!--
507
+ # rdoc-file=numeric.rb
508
+ # - abs -> integer
509
+ # -->
510
+ # Returns the absolute value of `self`.
511
+ #
512
+ # (-12345).abs # => 12345
513
+ # -12345.abs # => 12345
514
+ # 12345.abs # => 12345
515
+ #
516
+ def abs: () -> Integer
517
+
518
+ def abs2: () -> Integer
519
+
520
+ # <!--
521
+ # rdoc-file=numeric.c
522
+ # - allbits?(mask) -> true or false
523
+ # -->
524
+ # Returns `true` if all bits that are set (=1) in `mask` are also set in `self`;
525
+ # returns `false` otherwise.
526
+ #
527
+ # Example values:
528
+ #
529
+ # 0b1010101 self
530
+ # 0b1010100 mask
531
+ # 0b1010100 self & mask
532
+ # true self.allbits?(mask)
533
+ #
534
+ # 0b1010100 self
535
+ # 0b1010101 mask
536
+ # 0b1010100 self & mask
537
+ # false self.allbits?(mask)
538
+ #
539
+ # Related: Integer#anybits?, Integer#nobits?.
540
+ #
541
+ def allbits?: (int mask) -> bool
542
+
543
+ def angle: () -> (Integer | Float)
544
+
545
+ # <!--
546
+ # rdoc-file=numeric.c
547
+ # - anybits?(mask) -> true or false
548
+ # -->
549
+ # Returns `true` if any bit that is set (=1) in `mask` is also set in `self`;
550
+ # returns `false` otherwise.
551
+ #
552
+ # Example values:
553
+ #
554
+ # 0b10000010 self
555
+ # 0b11111111 mask
556
+ # 0b10000010 self & mask
557
+ # true self.anybits?(mask)
558
+ #
559
+ # 0b00000000 self
560
+ # 0b11111111 mask
561
+ # 0b00000000 self & mask
562
+ # false self.anybits?(mask)
563
+ #
564
+ # Related: Integer#allbits?, Integer#nobits?.
565
+ #
566
+ def anybits?: (int mask) -> bool
567
+
568
+ alias arg angle
569
+
570
+ # <!--
571
+ # rdoc-file=numeric.rb
572
+ # - bit_length -> integer
573
+ # -->
574
+ # Returns the number of bits of the value of `self`, which is the bit position
575
+ # of the highest-order bit that is different from the sign bit (where the least
576
+ # significant bit has bit position 1). If there is no such bit (zero or minus
577
+ # one), returns zero.
578
+ #
579
+ # This method returns `ceil(log2(self < 0 ? -self : self + 1))`>.
580
+ #
581
+ # (-2**1000-1).bit_length # => 1001
582
+ # (-2**1000).bit_length # => 1000
583
+ # (-2**1000+1).bit_length # => 1000
584
+ # (-2**12-1).bit_length # => 13
585
+ # (-2**12).bit_length # => 12
586
+ # (-2**12+1).bit_length # => 12
587
+ # -0x101.bit_length # => 9
588
+ # -0x100.bit_length # => 8
589
+ # -0xff.bit_length # => 8
590
+ # -2.bit_length # => 1
591
+ # -1.bit_length # => 0
592
+ # 0.bit_length # => 0
593
+ # 1.bit_length # => 1
594
+ # 0xff.bit_length # => 8
595
+ # 0x100.bit_length # => 9
596
+ # (2**12-1).bit_length # => 12
597
+ # (2**12).bit_length # => 13
598
+ # (2**12+1).bit_length # => 13
599
+ # (2**1000-1).bit_length # => 1000
600
+ # (2**1000).bit_length # => 1001
601
+ # (2**1000+1).bit_length # => 1001
602
+ #
603
+ # For Integer *n*, this method can be used to detect overflow in Array#pack:
604
+ #
605
+ # if n.bit_length < 32
606
+ # [n].pack('l') # No overflow.
607
+ # else
608
+ # raise 'Overflow'
609
+ # end
610
+ #
611
+ def bit_length: () -> Integer
612
+
613
+ # <!--
614
+ # rdoc-file=numeric.c
615
+ # - ceil(ndigits = 0) -> integer
616
+ # -->
617
+ # Returns an integer that is a "ceiling" value for `self`,
618
+ # as specified by the given `ndigits`,
619
+ # which must be an
620
+ # [integer-convertible
621
+ # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
622
+ # * When `self` is zero, returns zero (regardless of the value of `ndigits`):
623
+ # 0.ceil(2) # => 0
624
+ # 0.ceil(-2) # => 0
625
+ #
626
+ # * When `self` is non-zero and `ndigits` is non-negative, returns `self`:
627
+ # 555.ceil # => 555
628
+ # 555.ceil(50) # => 555
629
+ #
630
+ # * When `self` is non-zero and `ndigits` is negative,
631
+ # returns a value based on a computed granularity:
632
+ # * The granularity is `10 ** ndigits.abs`.
633
+ # * The returned value is the smallest multiple of the granularity
634
+ # that is greater than or equal to `self`.
635
+ # Examples with positive `self`:
636
+ # ndigits|Granularity|1234.ceil(ndigits)
637
+ # -------|-----------|------------------
638
+ # -1| 10| 1240
639
+ # -2| 100| 1300
640
+ # -3| 1000| 2000
641
+ # -4| 10000| 10000
642
+ # -5| 100000| 100000
643
+ # Examples with negative `self`:
644
+ # ndigits|Granularity|-1234.ceil(ndigits)
645
+ # -------|-----------|-------------------
646
+ # -1| 10| -1230
647
+ # -2| 100| -1200
648
+ # -3| 1000| -1000
649
+ # -4| 10000| 0
650
+ # -5| 100000| 0
651
+ # Related: Integer#floor.
652
+ #
653
+ def ceil: () -> Integer
654
+ | (int digits) -> (Integer | Float)
655
+
656
+ # <!--
657
+ # rdoc-file=numeric.rb
658
+ # - ceildiv(numeric) -> integer
659
+ # -->
660
+ # Returns the result of division `self` by `numeric`. rounded up to the nearest
661
+ # integer.
662
+ #
663
+ # 3.ceildiv(3) # => 1
664
+ # 4.ceildiv(3) # => 2
665
+ #
666
+ # 4.ceildiv(-3) # => -1
667
+ # -4.ceildiv(3) # => -1
668
+ # -4.ceildiv(-3) # => 2
669
+ #
670
+ # 3.ceildiv(1.2) # => 3
671
+ #
672
+ def ceildiv: (Numeric other) -> Integer
673
+
674
+ # <!--
675
+ # rdoc-file=numeric.c
676
+ # - chr -> string
677
+ # - chr(encoding) -> string
678
+ # -->
679
+ # Returns a 1-character string containing the character represented by the value
680
+ # of `self`, according to the given `encoding`.
681
+ #
682
+ # 65.chr # => "A"
683
+ # 0.chr # => "\x00"
684
+ # 255.chr # => "\xFF"
685
+ # string = 255.chr(Encoding::UTF_8)
686
+ # string.encoding # => Encoding::UTF_8
687
+ #
688
+ # Raises an exception if `self` is negative.
689
+ #
690
+ # Related: Integer#ord.
691
+ #
692
+ def chr: (?encoding) -> String
693
+
694
+ # <!--
695
+ # rdoc-file=bignum.c
696
+ # - int.coerce(numeric) -> array
697
+ # -->
698
+ # Returns an array with both a `numeric` and a `int` represented as Integer
699
+ # objects or Float objects.
700
+ #
701
+ # This is achieved by converting `numeric` to an Integer or a Float.
702
+ #
703
+ # A TypeError is raised if the `numeric` is not an Integer or a Float type.
704
+ #
705
+ # (0x3FFFFFFFFFFFFFFF+1).coerce(42) #=> [42, 4611686018427387904]
706
+ #
707
+ def coerce: (Numeric) -> [ Numeric, Numeric ]
708
+
709
+ def conj: () -> Integer
710
+
711
+ def conjugate: () -> Integer
712
+
713
+ # <!--
714
+ # rdoc-file=numeric.rb
715
+ # - denominator -> 1
716
+ # -->
717
+ # Returns `1`.
718
+ #
719
+ def denominator: () -> Integer
720
+
721
+ # <!--
722
+ # rdoc-file=numeric.c
723
+ # - digits(base = 10) -> array_of_integers
724
+ # -->
725
+ # Returns an array of integers representing the `base`-radix digits of `self`;
726
+ # the first element of the array represents the least significant digit:
727
+ #
728
+ # 12345.digits # => [5, 4, 3, 2, 1]
729
+ # 12345.digits(7) # => [4, 6, 6, 0, 5]
730
+ # 12345.digits(100) # => [45, 23, 1]
731
+ #
732
+ # Raises an exception if `self` is negative or `base` is less than 2.
733
+ #
734
+ def digits: (?int base) -> ::Array[Integer]
735
+
736
+ # <!--
737
+ # rdoc-file=numeric.c
738
+ # - div(numeric) -> integer
739
+ # -->
740
+ # Performs integer division; returns the integer result of dividing `self` by
741
+ # `numeric`:
742
+ #
743
+ # 4.div(3) # => 1
744
+ # 4.div(-3) # => -2
745
+ # -4.div(3) # => -2
746
+ # -4.div(-3) # => 1
747
+ # 4.div(3.0) # => 1
748
+ # 4.div(Rational(3, 1)) # => 1
749
+ #
750
+ # Raises an exception if `numeric` does not have method `div`.
751
+ #
752
+ def div: (Numeric) -> Integer
753
+
754
+ # <!--
755
+ # rdoc-file=numeric.c
756
+ # - divmod(other) -> array
757
+ # -->
758
+ # Returns a 2-element array `[q, r]`, where
759
+ #
760
+ # q = (self/other).floor # Quotient
761
+ # r = self % other # Remainder
762
+ #
763
+ # Examples:
764
+ #
765
+ # 11.divmod(4) # => [2, 3]
766
+ # 11.divmod(-4) # => [-3, -1]
767
+ # -11.divmod(4) # => [-3, 1]
768
+ # -11.divmod(-4) # => [2, -3]
769
+ #
770
+ # 12.divmod(4) # => [3, 0]
771
+ # 12.divmod(-4) # => [-3, 0]
772
+ # -12.divmod(4) # => [-3, 0]
773
+ # -12.divmod(-4) # => [3, 0]
774
+ #
775
+ # 13.divmod(4.0) # => [3, 1.0]
776
+ # 13.divmod(Rational(4, 1)) # => [3, (1/1)]
777
+ #
778
+ def divmod: (Integer) -> [ Integer, Integer ]
779
+ | (Float) -> [ Integer, Float ]
780
+ | (Rational) -> [ Integer, Rational ]
781
+ | (Numeric) -> [ Numeric, Numeric ]
782
+
783
+ # <!--
784
+ # rdoc-file=numeric.c
785
+ # - downto(limit) {|i| ... } -> self
786
+ # - downto(limit) -> enumerator
787
+ # -->
788
+ # Calls the given block with each integer value from `self` down to `limit`;
789
+ # returns `self`:
790
+ #
791
+ # a = []
792
+ # 10.downto(5) {|i| a << i } # => 10
793
+ # a # => [10, 9, 8, 7, 6, 5]
794
+ # a = []
795
+ # 0.downto(-5) {|i| a << i } # => 0
796
+ # a # => [0, -1, -2, -3, -4, -5]
797
+ # 4.downto(5) {|i| fail 'Cannot happen' } # => 4
798
+ #
799
+ # With no block given, returns an Enumerator.
800
+ #
801
+ def downto: (Numeric limit) { (Integer) -> void } -> Integer
802
+ | (Numeric limit) -> ::Enumerator[Integer, self]
803
+
804
+ def dup: () -> self
805
+
806
+ def eql?: (untyped) -> bool
807
+
808
+ # <!--
809
+ # rdoc-file=numeric.rb
810
+ # - even? -> true or false
811
+ # -->
812
+ # Returns `true` if `self` is an even number, `false` otherwise.
813
+ #
814
+ def even?: () -> bool
815
+
816
+ # <!--
817
+ # rdoc-file=numeric.c
818
+ # - fdiv(numeric) -> float
819
+ # -->
820
+ # Returns the Float result of dividing `self` by `numeric`:
821
+ #
822
+ # 4.fdiv(2) # => 2.0
823
+ # 4.fdiv(-2) # => -2.0
824
+ # -4.fdiv(2) # => -2.0
825
+ # 4.fdiv(2.0) # => 2.0
826
+ # 4.fdiv(Rational(3, 4)) # => 5.333333333333333
827
+ #
828
+ # Raises an exception if `numeric` cannot be converted to a Float.
829
+ #
830
+ def fdiv: (Numeric) -> Float
831
+
832
+ def finite?: () -> bool
833
+
834
+ # <!--
835
+ # rdoc-file=numeric.c
836
+ # - floor(ndigits = 0) -> integer
837
+ # -->
838
+ # Returns an integer that is a "floor" value for `self`,
839
+ # as specified by the given `ndigits`,
840
+ # which must be an
841
+ # [integer-convertible
842
+ # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
843
+ # * When `self` is zero, returns zero (regardless of the value of `ndigits`):
844
+ # 0.floor(2) # => 0
845
+ # 0.floor(-2) # => 0
846
+ #
847
+ # * When `self` is non-zero and `ndigits` is non-negative, returns `self`:
848
+ # 555.floor # => 555
849
+ # 555.floor(50) # => 555
850
+ #
851
+ # * When `self` is non-zero and `ndigits` is negative,
852
+ # returns a value based on a computed granularity:
853
+ # * The granularity is `10 ** ndigits.abs`.
854
+ # * The returned value is the largest multiple of the granularity
855
+ # that is less than or equal to `self`.
856
+ # Examples with positive `self`:
857
+ # ndigits|Granularity|1234.floor(ndigits)
858
+ # -------|-----------|-------------------
859
+ # -1| 10| 1230
860
+ # -2| 100| 1200
861
+ # -3| 1000| 1000
862
+ # -4| 10000| 0
863
+ # -5| 100000| 0
864
+ # Examples with negative `self`:
865
+ # ndigits|Granularity|-1234.floor(ndigits)
866
+ # -------|-----------|--------------------
867
+ # -1| 10| -1240
868
+ # -2| 100| -1300
869
+ # -3| 1000| -2000
870
+ # -4| 10000| -10000
871
+ # -5| 100000| -100000
872
+ # Related: Integer#ceil.
873
+ #
874
+ def floor: (?int digits) -> Integer
875
+
876
+ # <!--
877
+ # rdoc-file=rational.c
878
+ # - int.gcd(other_int) -> integer
879
+ # -->
880
+ # Returns the greatest common divisor of the two integers. The result is always
881
+ # positive. 0.gcd(x) and x.gcd(0) return x.abs.
882
+ #
883
+ # 36.gcd(60) #=> 12
884
+ # 2.gcd(2) #=> 2
885
+ # 3.gcd(-7) #=> 1
886
+ # ((1<<31)-1).gcd((1<<61)-1) #=> 1
887
+ #
888
+ def gcd: (Integer) -> Integer
889
+
890
+ # <!--
891
+ # rdoc-file=rational.c
892
+ # - int.gcdlcm(other_int) -> array
893
+ # -->
894
+ # Returns an array with the greatest common divisor and the least common
895
+ # multiple of the two integers, [gcd, lcm].
896
+ #
897
+ # 36.gcdlcm(60) #=> [12, 180]
898
+ # 2.gcdlcm(2) #=> [2, 2]
899
+ # 3.gcdlcm(-7) #=> [1, 21]
900
+ # ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297]
901
+ #
902
+ def gcdlcm: (Integer) -> [ Integer, Integer ]
903
+
904
+ def i: () -> Complex
905
+
906
+ def imag: () -> Integer
907
+
908
+ def imaginary: () -> Integer
909
+
910
+ def infinite?: () -> Integer?
911
+
912
+ # <!-- rdoc-file=numeric.c -->
913
+ # Returns a string containing the place-value representation of `self` in radix
914
+ # `base` (in 2..36).
915
+ #
916
+ # 12345.to_s # => "12345"
917
+ # 12345.to_s(2) # => "11000000111001"
918
+ # 12345.to_s(8) # => "30071"
919
+ # 12345.to_s(10) # => "12345"
920
+ # 12345.to_s(16) # => "3039"
921
+ # 12345.to_s(36) # => "9ix"
922
+ # 78546939656932.to_s(36) # => "rubyrules"
923
+ #
924
+ # Raises an exception if `base` is out of range.
925
+ #
926
+ alias inspect to_s
927
+
928
+ # <!--
929
+ # rdoc-file=numeric.rb
930
+ # - integer? -> true
931
+ # -->
932
+ # Since `self` is already an Integer, always returns `true`.
933
+ #
934
+ def integer?: () -> true
935
+
936
+ # <!--
937
+ # rdoc-file=rational.c
938
+ # - int.lcm(other_int) -> integer
939
+ # -->
940
+ # Returns the least common multiple of the two integers. The result is always
941
+ # positive. 0.lcm(x) and x.lcm(0) return zero.
942
+ #
943
+ # 36.lcm(60) #=> 180
944
+ # 2.lcm(2) #=> 2
945
+ # 3.lcm(-7) #=> 21
946
+ # ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297
947
+ #
948
+ def lcm: (Integer) -> Integer
949
+
950
+ # <!--
951
+ # rdoc-file=numeric.rb
952
+ # - magnitude()
953
+ # -->
954
+ #
955
+ def magnitude: () -> Integer
956
+
957
+ # <!-- rdoc-file=numeric.c -->
958
+ # Returns `self` modulo `other` as a real number.
959
+ #
960
+ # For integer `n` and real number `r`, these expressions are equivalent:
961
+ #
962
+ # n % r
963
+ # n-r*(n/r).floor
964
+ # n.divmod(r)[1]
965
+ #
966
+ # See Numeric#divmod.
967
+ #
968
+ # Examples:
969
+ #
970
+ # 10 % 2 # => 0
971
+ # 10 % 3 # => 1
972
+ # 10 % 4 # => 2
973
+ #
974
+ # 10 % -2 # => 0
975
+ # 10 % -3 # => -2
976
+ # 10 % -4 # => -2
977
+ #
978
+ # 10 % 3.0 # => 1.0
979
+ # 10 % Rational(3, 1) # => (1/1)
980
+ #
981
+ alias modulo %
982
+
983
+ def negative?: () -> bool
984
+
985
+ # <!-- rdoc-file=numeric.c -->
986
+ # Returns the successor integer of `self` (equivalent to `self + 1`):
987
+ #
988
+ # 1.succ #=> 2
989
+ # -1.succ #=> 0
990
+ #
991
+ # Related: Integer#pred (predecessor value).
992
+ #
993
+ def next: () -> Integer
994
+
995
+ # <!--
996
+ # rdoc-file=numeric.c
997
+ # - nobits?(mask) -> true or false
998
+ # -->
999
+ # Returns `true` if no bit that is set (=1) in `mask` is also set in `self`;
1000
+ # returns `false` otherwise.
1001
+ #
1002
+ # Example values:
1003
+ #
1004
+ # 0b11110000 self
1005
+ # 0b00001111 mask
1006
+ # 0b00000000 self & mask
1007
+ # true self.nobits?(mask)
1008
+ #
1009
+ # 0b00000001 self
1010
+ # 0b11111111 mask
1011
+ # 0b00000001 self & mask
1012
+ # false self.nobits?(mask)
1013
+ #
1014
+ # Related: Integer#allbits?, Integer#anybits?.
1015
+ #
1016
+ def nobits?: (int mask) -> bool
1017
+
1018
+ def nonzero?: () -> self?
1019
+
1020
+ # <!--
1021
+ # rdoc-file=numeric.rb
1022
+ # - numerator -> self
1023
+ # -->
1024
+ # Returns `self`.
1025
+ #
1026
+ def numerator: () -> Integer
1027
+
1028
+ # <!--
1029
+ # rdoc-file=numeric.rb
1030
+ # - odd? -> true or false
1031
+ # -->
1032
+ # Returns `true` if `self` is an odd number, `false` otherwise.
1033
+ #
1034
+ def odd?: () -> bool
1035
+
1036
+ # <!--
1037
+ # rdoc-file=numeric.rb
1038
+ # - ord -> self
1039
+ # -->
1040
+ # Returns `self`; intended for compatibility to character literals in Ruby 1.9.
1041
+ #
1042
+ def ord: () -> Integer
1043
+
1044
+ alias phase angle
1045
+
1046
+ def polar: () -> [ Integer, Integer | Float ]
1047
+
1048
+ def positive?: () -> bool
1049
+
1050
+ # <!--
1051
+ # rdoc-file=numeric.c
1052
+ # - integer.pow(numeric) -> numeric
1053
+ # - integer.pow(integer, integer) -> integer
1054
+ # -->
1055
+ # Returns (modular) exponentiation as:
1056
+ #
1057
+ # a.pow(b) #=> same as a**b
1058
+ # a.pow(b, m) #=> same as (a**b) % m, but avoids huge temporary values
1059
+ #
1060
+ def pow: (Integer other) -> (Integer | Rational)
1061
+ | (Integer other, Integer modulo) -> Integer
1062
+ | (Float) -> (Float | Complex)
1063
+ | (Rational) -> (Float | Rational | Complex)
1064
+ | (Complex) -> Complex
1065
+
1066
+ # <!--
1067
+ # rdoc-file=numeric.c
1068
+ # - pred -> next_integer
1069
+ # -->
1070
+ # Returns the predecessor of `self` (equivalent to `self - 1`):
1071
+ #
1072
+ # 1.pred #=> 0
1073
+ # -1.pred #=> -2
1074
+ #
1075
+ # Related: Integer#succ (successor value).
1076
+ #
1077
+ def pred: () -> Integer
1078
+
1079
+ def quo: (Integer) -> Rational
1080
+ | (Float) -> Float
1081
+ | (Rational) -> Rational
1082
+ | (Complex) -> Complex
1083
+ | (Numeric) -> Numeric
1084
+
1085
+ # <!--
1086
+ # rdoc-file=rational.c
1087
+ # - int.rationalize([eps]) -> rational
1088
+ # -->
1089
+ # Returns the value as a rational. The optional argument `eps` is always
1090
+ # ignored.
1091
+ #
1092
+ def rationalize: (?Numeric eps) -> Rational
1093
+
1094
+ def real: () -> self
1095
+
1096
+ def real?: () -> true
1097
+
1098
+ def rect: () -> [ Integer, Numeric ]
1099
+
1100
+ alias rectangular rect
1101
+
1102
+ # <!--
1103
+ # rdoc-file=numeric.c
1104
+ # - remainder(other) -> real_number
1105
+ # -->
1106
+ # Returns the remainder after dividing `self` by `other`.
1107
+ #
1108
+ # Examples:
1109
+ #
1110
+ # 11.remainder(4) # => 3
1111
+ # 11.remainder(-4) # => 3
1112
+ # -11.remainder(4) # => -3
1113
+ # -11.remainder(-4) # => -3
1114
+ #
1115
+ # 12.remainder(4) # => 0
1116
+ # 12.remainder(-4) # => 0
1117
+ # -12.remainder(4) # => 0
1118
+ # -12.remainder(-4) # => 0
1119
+ #
1120
+ # 13.remainder(4.0) # => 1.0
1121
+ # 13.remainder(Rational(4, 1)) # => (1/1)
1122
+ #
1123
+ def remainder: (Integer) -> Integer
1124
+ | (Float) -> Float
1125
+ | (Rational) -> Rational
1126
+ | (Numeric) -> Numeric
1127
+
1128
+ # <!--
1129
+ # rdoc-file=numeric.c
1130
+ # - round(ndigits= 0, half: :up) -> integer
1131
+ # -->
1132
+ # Returns `self` rounded to the nearest value with a precision of `ndigits`
1133
+ # decimal digits.
1134
+ #
1135
+ # When `ndigits` is negative, the returned value has at least `ndigits.abs`
1136
+ # trailing zeros:
1137
+ #
1138
+ # 555.round(-1) # => 560
1139
+ # 555.round(-2) # => 600
1140
+ # 555.round(-3) # => 1000
1141
+ # -555.round(-2) # => -600
1142
+ # 555.round(-4) # => 0
1143
+ #
1144
+ # Returns `self` when `ndigits` is zero or positive.
1145
+ #
1146
+ # 555.round # => 555
1147
+ # 555.round(1) # => 555
1148
+ # 555.round(50) # => 555
1149
+ #
1150
+ # If keyword argument `half` is given, and `self` is equidistant from the two
1151
+ # candidate values, the rounding is according to the given `half` value:
1152
+ #
1153
+ # * `:up` or `nil`: round away from zero:
1154
+ #
1155
+ # 25.round(-1, half: :up) # => 30
1156
+ # (-25).round(-1, half: :up) # => -30
1157
+ #
1158
+ # * `:down`: round toward zero:
1159
+ #
1160
+ # 25.round(-1, half: :down) # => 20
1161
+ # (-25).round(-1, half: :down) # => -20
1162
+ #
1163
+ # * `:even`: round toward the candidate whose last nonzero digit is even:
1164
+ #
1165
+ # 25.round(-1, half: :even) # => 20
1166
+ # 15.round(-1, half: :even) # => 20
1167
+ # (-25).round(-1, half: :even) # => -20
1168
+ #
1169
+ # Raises and exception if the value for `half` is invalid.
1170
+ #
1171
+ # Related: Integer#truncate.
1172
+ #
1173
+ def round: (?half: :up | :down | :even) -> Integer
1174
+ | (int digits, ?half: :up | :down | :even) -> (Integer | Float)
1175
+
1176
+ # <!--
1177
+ # rdoc-file=numeric.rb
1178
+ # - size -> integer
1179
+ # -->
1180
+ # Returns the number of bytes in the machine representation of `self`; the value
1181
+ # is system-dependent:
1182
+ #
1183
+ # 1.size # => 8
1184
+ # -1.size # => 8
1185
+ # 2147483647.size # => 8
1186
+ # (256**10 - 1).size # => 10
1187
+ # (256**20 - 1).size # => 20
1188
+ # (256**40 - 1).size # => 40
1189
+ #
1190
+ def size: () -> Integer
1191
+
1192
+ def step: () { (Integer) -> void } -> void
1193
+ | (Numeric limit, ?Integer step) { (Integer) -> void } -> void
1194
+ | (Numeric limit, ?Numeric step) { (Numeric) -> void } -> void
1195
+ | (to: Numeric, ?by: Integer) { (Integer) -> void } -> void
1196
+ | (by: Numeric, ?to: Numeric) { (Numeric) -> void } -> void
1197
+ | () -> Enumerator[Integer, bot]
1198
+ | (Numeric limit, ?Integer step) -> Enumerator[Integer]
1199
+ | (Numeric limit, ?Numeric step) -> Enumerator[Numeric]
1200
+ | (to: Numeric, ?by: Integer) -> Enumerator[Integer]
1201
+ | (by: Numeric, ?to: Numeric) -> Enumerator[Numeric]
1202
+
1203
+ # <!--
1204
+ # rdoc-file=numeric.c
1205
+ # - succ -> next_integer
1206
+ # -->
1207
+ # Returns the successor integer of `self` (equivalent to `self + 1`):
1208
+ #
1209
+ # 1.succ #=> 2
1210
+ # -1.succ #=> 0
1211
+ #
1212
+ # Related: Integer#pred (predecessor value).
1213
+ #
1214
+ def succ: () -> Integer
1215
+
1216
+ # <!--
1217
+ # rdoc-file=numeric.rb
1218
+ # - times {|i| ... } -> self
1219
+ # - times -> enumerator
1220
+ # -->
1221
+ # Calls the given block `self` times with each integer in `(0..self-1)`:
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) -> void } -> self
1230
+ | () -> ::Enumerator[Integer, self]
1231
+
1232
+ def to_c: () -> Complex
1233
+
1234
+ # <!--
1235
+ # rdoc-file=numeric.c
1236
+ # - to_f -> float
1237
+ # -->
1238
+ # Converts `self` to a Float:
1239
+ #
1240
+ # 1.to_f # => 1.0
1241
+ # -1.to_f # => -1.0
1242
+ #
1243
+ # If the value of `self` does not fit in a Float, the result is infinity:
1244
+ #
1245
+ # (10**400).to_f # => Infinity
1246
+ # (-10**400).to_f # => -Infinity
1247
+ #
1248
+ def to_f: () -> Float
1249
+
1250
+ # <!--
1251
+ # rdoc-file=numeric.rb
1252
+ # - to_i -> self
1253
+ # -->
1254
+ # Returns `self` (which is already an Integer).
1255
+ #
1256
+ def to_i: () -> Integer
1257
+
1258
+ # <!--
1259
+ # rdoc-file=numeric.rb
1260
+ # - to_int -> self
1261
+ # -->
1262
+ # Returns `self` (which is already an Integer).
1263
+ #
1264
+ alias to_int to_i
1265
+
1266
+ # <!--
1267
+ # rdoc-file=rational.c
1268
+ # - int.to_r -> rational
1269
+ # -->
1270
+ # Returns the value as a rational.
1271
+ #
1272
+ # 1.to_r #=> (1/1)
1273
+ # (1<<64).to_r #=> (18446744073709551616/1)
1274
+ #
1275
+ def to_r: () -> Rational
1276
+
1277
+ # <!--
1278
+ # rdoc-file=numeric.c
1279
+ # - to_s(base = 10) -> string
1280
+ # -->
1281
+ # Returns a string containing the place-value representation of `self` in radix
1282
+ # `base` (in 2..36).
1283
+ #
1284
+ # 12345.to_s # => "12345"
1285
+ # 12345.to_s(2) # => "11000000111001"
1286
+ # 12345.to_s(8) # => "30071"
1287
+ # 12345.to_s(10) # => "12345"
1288
+ # 12345.to_s(16) # => "3039"
1289
+ # 12345.to_s(36) # => "9ix"
1290
+ # 78546939656932.to_s(36) # => "rubyrules"
1291
+ #
1292
+ # Raises an exception if `base` is out of range.
1293
+ #
1294
+ def to_s: () -> String
1295
+ | (2) -> String
1296
+ | (3) -> String
1297
+ | (4) -> String
1298
+ | (5) -> String
1299
+ | (6) -> String
1300
+ | (7) -> String
1301
+ | (8) -> String
1302
+ | (9) -> String
1303
+ | (10) -> String
1304
+ | (11) -> String
1305
+ | (12) -> String
1306
+ | (13) -> String
1307
+ | (14) -> String
1308
+ | (15) -> String
1309
+ | (16) -> String
1310
+ | (17) -> String
1311
+ | (18) -> String
1312
+ | (19) -> String
1313
+ | (20) -> String
1314
+ | (21) -> String
1315
+ | (22) -> String
1316
+ | (23) -> String
1317
+ | (24) -> String
1318
+ | (25) -> String
1319
+ | (26) -> String
1320
+ | (27) -> String
1321
+ | (28) -> String
1322
+ | (29) -> String
1323
+ | (30) -> String
1324
+ | (31) -> String
1325
+ | (32) -> String
1326
+ | (33) -> String
1327
+ | (34) -> String
1328
+ | (35) -> String
1329
+ | (36) -> String
1330
+ | (int base) -> String
1331
+
1332
+ # <!--
1333
+ # rdoc-file=numeric.c
1334
+ # - truncate(ndigits = 0) -> integer
1335
+ # -->
1336
+ # Returns `self` truncated (toward zero) to a precision of `ndigits` decimal
1337
+ # digits.
1338
+ #
1339
+ # When `ndigits` is negative, the returned value has at least `ndigits.abs`
1340
+ # trailing zeros:
1341
+ #
1342
+ # 555.truncate(-1) # => 550
1343
+ # 555.truncate(-2) # => 500
1344
+ # -555.truncate(-2) # => -500
1345
+ #
1346
+ # Returns `self` when `ndigits` is zero or positive.
1347
+ #
1348
+ # 555.truncate # => 555
1349
+ # 555.truncate(50) # => 555
1350
+ #
1351
+ # Related: Integer#round.
1352
+ #
1353
+ def truncate: () -> Integer
1354
+ | (int ndigits) -> Integer
1355
+
1356
+ # <!--
1357
+ # rdoc-file=numeric.c
1358
+ # - upto(limit) {|i| ... } -> self
1359
+ # - upto(limit) -> enumerator
1360
+ # -->
1361
+ # Calls the given block with each integer value from `self` up to `limit`;
1362
+ # returns `self`:
1363
+ #
1364
+ # a = []
1365
+ # 5.upto(10) {|i| a << i } # => 5
1366
+ # a # => [5, 6, 7, 8, 9, 10]
1367
+ # a = []
1368
+ # -5.upto(0) {|i| a << i } # => -5
1369
+ # a # => [-5, -4, -3, -2, -1, 0]
1370
+ # 5.upto(4) {|i| fail 'Cannot happen' } # => 5
1371
+ #
1372
+ # With no block given, returns an Enumerator.
1373
+ #
1374
+ def upto: (Numeric limit) { (Integer) -> void } -> Integer
1375
+ | (Numeric limit) -> ::Enumerator[Integer, self]
1376
+
1377
+ # <!--
1378
+ # rdoc-file=numeric.rb
1379
+ # - zero? -> true or false
1380
+ # -->
1381
+ # Returns `true` if `self` has a zero value, `false` otherwise.
1382
+ #
1383
+ def zero?: () -> bool
1384
+
1385
+ # <!--
1386
+ # rdoc-file=numeric.c
1387
+ # - self | other -> integer
1388
+ # -->
1389
+ # Bitwise OR; each bit in the result is 1 if either corresponding bit in `self`
1390
+ # or `other` is 1, 0 otherwise:
1391
+ #
1392
+ # "%04b" % (0b0101 | 0b0110) # => "0111"
1393
+ #
1394
+ # Raises an exception if `other` is not an Integer.
1395
+ #
1396
+ # Related: Integer#& (bitwise AND), Integer#^ (bitwise EXCLUSIVE OR).
1397
+ #
1398
+ def |: (Integer) -> Integer
1399
+
1400
+ # <!--
1401
+ # rdoc-file=numeric.rb
1402
+ # - ~int -> integer
1403
+ # -->
1404
+ # One's complement: returns the value of `self` with each bit inverted.
1405
+ #
1406
+ # Because an integer value is conceptually of infinite length, the result acts
1407
+ # as if it had an infinite number of one bits to the left. In hex
1408
+ # representations, this is displayed as two periods to the left of the digits:
1409
+ #
1410
+ # sprintf("%X", ~0x1122334455) # => "..FEEDDCCBBAA"
1411
+ #
1412
+ def ~: () -> Integer
1413
+ end