rbs 2.8.4 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (434) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -4
  3. data/.github/workflows/comments.yml +11 -11
  4. data/.github/workflows/dependabot.yml +30 -0
  5. data/.github/workflows/ruby.yml +40 -49
  6. data/.github/workflows/typecheck.yml +36 -0
  7. data/.github/workflows/windows.yml +28 -0
  8. data/.gitignore +1 -0
  9. data/.rubocop.yml +42 -2
  10. data/CHANGELOG.md +845 -1
  11. data/README.md +64 -4
  12. data/Rakefile +198 -18
  13. data/Steepfile +11 -11
  14. data/config.yml +311 -0
  15. data/core/array.rbs +2189 -1914
  16. data/core/basic_object.rbs +59 -84
  17. data/core/binding.rbs +7 -69
  18. data/core/builtin.rbs +210 -11
  19. data/core/class.rbs +37 -0
  20. data/core/comparable.rbs +23 -25
  21. data/core/complex.rbs +449 -227
  22. data/core/constants.rbs +29 -21
  23. data/core/data.rbs +415 -0
  24. data/core/dir.rbs +698 -415
  25. data/core/encoding.rbs +468 -843
  26. data/core/enumerable.rbs +495 -455
  27. data/core/enumerator/product.rbs +92 -0
  28. data/core/enumerator.rbs +106 -9
  29. data/core/env.rbs +1 -1
  30. data/core/errno.rbs +506 -605
  31. data/core/errors.rbs +15 -17
  32. data/core/exception.rbs +361 -145
  33. data/core/false_class.rbs +39 -26
  34. data/core/fiber.rbs +121 -14
  35. data/core/file.rbs +1262 -320
  36. data/core/file_test.rbs +62 -45
  37. data/core/float.rbs +187 -208
  38. data/core/gc.rbs +446 -196
  39. data/core/global_variables.rbs +29 -29
  40. data/core/hash.rbs +242 -349
  41. data/core/integer.rbs +246 -308
  42. data/core/io/buffer.rbs +373 -122
  43. data/core/io/wait.rbs +29 -17
  44. data/core/io.rbs +1881 -1518
  45. data/core/kernel.rbs +2116 -1538
  46. data/core/marshal.rbs +24 -14
  47. data/core/match_data.rbs +413 -166
  48. data/core/math.rbs +531 -291
  49. data/core/method.rbs +101 -32
  50. data/core/module.rbs +228 -64
  51. data/core/nil_class.rbs +106 -47
  52. data/core/numeric.rbs +206 -292
  53. data/core/object.rbs +73 -1168
  54. data/core/object_space/weak_key_map.rbs +166 -0
  55. data/core/object_space.rbs +5 -3
  56. data/core/proc.rbs +280 -39
  57. data/core/process.rbs +1318 -658
  58. data/core/ractor.rbs +200 -134
  59. data/core/random.rbs +21 -4
  60. data/core/range.rbs +309 -153
  61. data/core/rational.rbs +4 -12
  62. data/core/rb_config.rbs +64 -43
  63. data/core/rbs/unnamed/argf.rbs +411 -147
  64. data/core/rbs/unnamed/env_class.rbs +137 -253
  65. data/core/rbs/unnamed/random.rbs +49 -26
  66. data/core/refinement.rbs +16 -1
  67. data/core/regexp.rbs +1568 -862
  68. data/core/ruby_vm.rbs +719 -7
  69. data/core/rubygems/config_file.rbs +3 -0
  70. data/core/rubygems/errors.rbs +69 -6
  71. data/core/rubygems/rubygems.rbs +71 -17
  72. data/core/rubygems/version.rbs +11 -7
  73. data/{stdlib/set/0 → core}/set.rbs +80 -91
  74. data/core/signal.rbs +14 -8
  75. data/core/string.rbs +1732 -1607
  76. data/core/struct.rbs +467 -95
  77. data/core/symbol.rbs +215 -245
  78. data/core/thread.rbs +133 -89
  79. data/core/thread_group.rbs +9 -9
  80. data/core/time.rbs +1141 -841
  81. data/core/trace_point.rbs +181 -121
  82. data/core/true_class.rbs +58 -32
  83. data/core/unbound_method.rbs +103 -30
  84. data/core/warning.rbs +50 -5
  85. data/docs/CONTRIBUTING.md +1 -1
  86. data/docs/architecture.md +110 -0
  87. data/docs/collection.md +59 -5
  88. data/docs/data_and_struct.md +86 -0
  89. data/docs/gem.md +57 -0
  90. data/docs/rbs_by_example.md +16 -35
  91. data/docs/repo.md +1 -1
  92. data/docs/sigs.md +7 -7
  93. data/docs/stdlib.md +63 -5
  94. data/docs/syntax.md +255 -61
  95. data/docs/tools.md +1 -0
  96. data/ext/rbs_extension/extconf.rb +10 -0
  97. data/ext/rbs_extension/lexer.c +1741 -1548
  98. data/ext/rbs_extension/lexer.h +11 -1
  99. data/ext/rbs_extension/lexer.re +12 -6
  100. data/ext/rbs_extension/lexstate.c +26 -3
  101. data/ext/rbs_extension/location.c +119 -111
  102. data/ext/rbs_extension/location.h +32 -7
  103. data/ext/rbs_extension/main.c +3 -0
  104. data/ext/rbs_extension/parser.c +883 -481
  105. data/ext/rbs_extension/parserstate.c +65 -25
  106. data/ext/rbs_extension/parserstate.h +13 -3
  107. data/ext/rbs_extension/rbs_extension.h +1 -10
  108. data/ext/rbs_extension/unescape.c +7 -47
  109. data/goodcheck.yml +2 -2
  110. data/{ext/rbs_extension → include/rbs}/constants.h +26 -15
  111. data/include/rbs/ruby_objs.h +72 -0
  112. data/include/rbs.h +7 -0
  113. data/lib/rbs/annotate/annotations.rb +3 -3
  114. data/lib/rbs/annotate/formatter.rb +13 -3
  115. data/lib/rbs/annotate/rdoc_annotator.rb +1 -1
  116. data/lib/rbs/annotate/rdoc_source.rb +12 -3
  117. data/lib/rbs/ast/declarations.rb +85 -2
  118. data/lib/rbs/ast/directives.rb +39 -0
  119. data/lib/rbs/ast/members.rb +49 -15
  120. data/lib/rbs/ast/type_param.rb +104 -15
  121. data/lib/rbs/ast/visitor.rb +137 -0
  122. data/lib/rbs/buffer.rb +5 -0
  123. data/lib/rbs/cli/colored_io.rb +48 -0
  124. data/lib/rbs/cli/diff.rb +83 -0
  125. data/lib/rbs/cli/validate.rb +356 -0
  126. data/lib/rbs/cli.rb +253 -143
  127. data/lib/rbs/collection/cleaner.rb +8 -1
  128. data/lib/rbs/collection/config/lockfile.rb +92 -0
  129. data/lib/rbs/collection/config/lockfile_generator.rb +154 -65
  130. data/lib/rbs/collection/config.rb +19 -46
  131. data/lib/rbs/collection/installer.rb +12 -13
  132. data/lib/rbs/collection/sources/base.rb +2 -2
  133. data/lib/rbs/collection/sources/git.rb +146 -69
  134. data/lib/rbs/collection/sources/local.rb +81 -0
  135. data/lib/rbs/collection/sources/rubygems.rb +10 -12
  136. data/lib/rbs/collection/sources/stdlib.rb +14 -13
  137. data/lib/rbs/collection/sources.rb +15 -2
  138. data/lib/rbs/collection.rb +2 -1
  139. data/lib/rbs/definition.rb +13 -16
  140. data/lib/rbs/definition_builder/ancestor_builder.rb +100 -24
  141. data/lib/rbs/definition_builder/method_builder.rb +4 -4
  142. data/lib/rbs/definition_builder.rb +489 -584
  143. data/lib/rbs/diff.rb +125 -0
  144. data/lib/rbs/environment/use_map.rb +77 -0
  145. data/lib/rbs/environment.rb +406 -105
  146. data/lib/rbs/environment_loader.rb +48 -44
  147. data/lib/rbs/environment_walker.rb +1 -1
  148. data/lib/rbs/errors.rb +175 -56
  149. data/lib/rbs/file_finder.rb +28 -0
  150. data/lib/rbs/location_aux.rb +8 -7
  151. data/lib/rbs/locator.rb +37 -15
  152. data/lib/rbs/method_type.rb +23 -0
  153. data/lib/rbs/namespace.rb +1 -0
  154. data/lib/rbs/parser/lex_result.rb +15 -0
  155. data/lib/rbs/parser/token.rb +23 -0
  156. data/lib/rbs/parser_aux.rb +22 -13
  157. data/lib/rbs/prototype/helpers.rb +48 -22
  158. data/lib/rbs/prototype/node_usage.rb +99 -0
  159. data/lib/rbs/prototype/rb.rb +125 -31
  160. data/lib/rbs/prototype/rbi.rb +49 -36
  161. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  162. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  163. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  164. data/lib/rbs/prototype/runtime.rb +273 -159
  165. data/lib/rbs/resolver/constant_resolver.rb +24 -8
  166. data/lib/rbs/resolver/type_name_resolver.rb +41 -7
  167. data/lib/rbs/sorter.rb +153 -123
  168. data/lib/rbs/substitution.rb +19 -0
  169. data/lib/rbs/subtractor.rb +201 -0
  170. data/lib/rbs/test/errors.rb +24 -11
  171. data/lib/rbs/test/guaranteed.rb +30 -0
  172. data/lib/rbs/test/hook.rb +45 -40
  173. data/lib/rbs/test/setup.rb +1 -1
  174. data/lib/rbs/test/tester.rb +1 -1
  175. data/lib/rbs/test/type_check.rb +120 -23
  176. data/lib/rbs/test.rb +6 -3
  177. data/lib/rbs/type_alias_dependency.rb +13 -3
  178. data/lib/rbs/type_alias_regularity.rb +21 -14
  179. data/lib/rbs/type_name.rb +18 -13
  180. data/lib/rbs/types.rb +352 -18
  181. data/lib/rbs/unit_test/convertibles.rb +176 -0
  182. data/lib/rbs/unit_test/spy.rb +136 -0
  183. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  184. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  185. data/lib/rbs/unit_test.rb +6 -0
  186. data/lib/rbs/validator.rb +55 -30
  187. data/lib/rbs/variance_calculator.rb +26 -23
  188. data/lib/rbs/vendorer.rb +3 -3
  189. data/lib/rbs/version.rb +1 -1
  190. data/lib/rbs/writer.rb +69 -22
  191. data/lib/rbs.rb +7 -2
  192. data/lib/rdoc/discover.rb +1 -1
  193. data/lib/rdoc_plugin/parser.rb +5 -5
  194. data/rbs.gemspec +12 -2
  195. data/schema/decls.json +1 -1
  196. data/schema/members.json +15 -10
  197. data/sig/ancestor_builder.rbs +4 -0
  198. data/sig/ancestor_graph.rbs +22 -2
  199. data/sig/annotate/formatter.rbs +2 -2
  200. data/sig/annotate/rdoc_annotater.rbs +1 -1
  201. data/sig/cli/colored_io.rbs +15 -0
  202. data/sig/cli/diff.rbs +21 -0
  203. data/sig/cli/validate.rbs +43 -0
  204. data/sig/cli.rbs +4 -0
  205. data/sig/collection/config/lockfile.rbs +74 -0
  206. data/sig/collection/config/lockfile_generator.rbs +66 -0
  207. data/sig/collection/config.rbs +5 -48
  208. data/sig/collection/installer.rbs +1 -1
  209. data/sig/collection/sources.rbs +105 -33
  210. data/sig/constant.rbs +1 -1
  211. data/sig/declarations.rbs +42 -3
  212. data/sig/definition.rbs +26 -10
  213. data/sig/definition_builder.rbs +103 -81
  214. data/sig/diff.rbs +28 -0
  215. data/sig/directives.rbs +61 -0
  216. data/sig/environment.rbs +175 -29
  217. data/sig/environment_loader.rbs +20 -18
  218. data/sig/errors.rbs +123 -2
  219. data/sig/file_finder.rbs +28 -0
  220. data/sig/location.rbs +0 -3
  221. data/sig/locator.rbs +14 -2
  222. data/sig/manifest.yaml +0 -1
  223. data/sig/members.rbs +32 -9
  224. data/sig/method_types.rbs +10 -4
  225. data/sig/namespace.rbs +2 -3
  226. data/sig/parser.rbs +55 -16
  227. data/sig/prototype/helpers.rbs +4 -0
  228. data/sig/prototype/node_usage.rbs +20 -0
  229. data/sig/prototype/rb.rbs +10 -2
  230. data/sig/prototype/rbi.rbs +2 -0
  231. data/sig/prototype/runtime.rbs +182 -0
  232. data/sig/rbs.rbs +1 -1
  233. data/sig/rdoc/rbs.rbs +4 -0
  234. data/sig/repository.rbs +7 -5
  235. data/sig/resolver/constant_resolver.rbs +3 -4
  236. data/sig/resolver/context.rbs +1 -1
  237. data/sig/resolver/type_name_resolver.rbs +5 -1
  238. data/sig/shims/bundler.rbs +38 -0
  239. data/sig/shims/rubygems.rbs +19 -0
  240. data/sig/sorter.rbs +23 -5
  241. data/sig/substitution.rbs +6 -0
  242. data/sig/subtractor.rbs +37 -0
  243. data/sig/test/errors.rbs +52 -0
  244. data/sig/test/guranteed.rbs +9 -0
  245. data/sig/test/type_check.rbs +19 -0
  246. data/sig/test.rbs +82 -0
  247. data/sig/type_alias_dependency.rbs +31 -0
  248. data/sig/type_alias_regularity.rbs +12 -6
  249. data/sig/type_param.rbs +45 -9
  250. data/sig/typename.rbs +8 -5
  251. data/sig/types.rbs +119 -12
  252. data/sig/unit_test/convertibles.rbs +154 -0
  253. data/sig/unit_test/spy.rbs +28 -0
  254. data/sig/unit_test/type_assertions.rbs +194 -0
  255. data/sig/unit_test/with_aliases.rbs +136 -0
  256. data/sig/use_map.rbs +35 -0
  257. data/sig/validator.rbs +12 -5
  258. data/sig/variance_calculator.rbs +3 -1
  259. data/sig/vendorer.rbs +1 -1
  260. data/sig/visitor.rbs +47 -0
  261. data/sig/writer.rbs +6 -2
  262. data/src/constants.c +153 -0
  263. data/src/ruby_objs.c +793 -0
  264. data/stdlib/base64/0/base64.rbs +298 -45
  265. data/stdlib/benchmark/0/benchmark.rbs +12 -3
  266. data/stdlib/bigdecimal/0/big_decimal.rbs +62 -198
  267. data/stdlib/cgi/0/core.rbs +68 -15
  268. data/stdlib/cgi/0/manifest.yaml +1 -0
  269. data/stdlib/coverage/0/coverage.rbs +50 -11
  270. data/stdlib/csv/0/csv.rbs +90 -119
  271. data/stdlib/csv/0/manifest.yaml +1 -0
  272. data/stdlib/date/0/date.rbs +806 -735
  273. data/stdlib/date/0/date_time.rbs +70 -211
  274. data/stdlib/dbm/0/dbm.rbs +0 -2
  275. data/stdlib/delegate/0/delegator.rbs +184 -0
  276. data/stdlib/delegate/0/kernel.rbs +47 -0
  277. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  278. data/stdlib/did_you_mean/0/did_you_mean.rbs +3 -8
  279. data/stdlib/digest/0/digest.rbs +48 -35
  280. data/stdlib/erb/0/erb.rbs +15 -39
  281. data/stdlib/etc/0/etc.rbs +174 -54
  282. data/stdlib/fileutils/0/fileutils.rbs +1234 -385
  283. data/stdlib/forwardable/0/forwardable.rbs +4 -4
  284. data/stdlib/io-console/0/io-console.rbs +82 -17
  285. data/stdlib/ipaddr/0/ipaddr.rbs +11 -6
  286. data/stdlib/json/0/json.rbs +434 -151
  287. data/stdlib/kconv/0/kconv.rbs +166 -0
  288. data/stdlib/logger/0/formatter.rbs +0 -2
  289. data/stdlib/logger/0/log_device.rbs +1 -3
  290. data/stdlib/logger/0/logger.rbs +465 -328
  291. data/stdlib/minitest/0/kernel.rbs +2 -2
  292. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
  293. data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
  294. data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
  295. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
  296. data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
  297. data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
  298. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  299. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  300. data/stdlib/minitest/0/minitest/mock.rbs +9 -5
  301. data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
  302. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
  303. data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
  304. data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
  305. data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
  306. data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
  307. data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
  308. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
  309. data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
  310. data/stdlib/minitest/0/minitest/spec.rbs +1 -1
  311. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
  312. data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
  313. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +7 -7
  314. data/stdlib/minitest/0/minitest/test.rbs +7 -14
  315. data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
  316. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  317. data/stdlib/minitest/0/minitest/unit.rbs +1 -2
  318. data/stdlib/minitest/0/minitest.rbs +41 -892
  319. data/stdlib/monitor/0/monitor.rbs +91 -10
  320. data/stdlib/mutex_m/0/mutex_m.rbs +0 -2
  321. data/stdlib/net-http/0/manifest.yaml +1 -1
  322. data/stdlib/net-http/0/net-http.rbs +3858 -964
  323. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  324. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  325. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  326. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  327. data/stdlib/nkf/0/nkf.rbs +35 -5
  328. data/stdlib/objspace/0/objspace.rbs +40 -18
  329. data/stdlib/observable/0/observable.rbs +217 -0
  330. data/stdlib/open-uri/0/manifest.yaml +4 -0
  331. data/stdlib/open-uri/0/open-uri.rbs +393 -0
  332. data/stdlib/open3/0/open3.rbs +147 -0
  333. data/stdlib/openssl/0/manifest.yaml +1 -0
  334. data/stdlib/openssl/0/openssl.rbs +681 -316
  335. data/stdlib/optparse/0/optparse.rbs +100 -65
  336. data/stdlib/pathname/0/pathname.rbs +24 -15
  337. data/stdlib/pp/0/manifest.yaml +2 -0
  338. data/stdlib/pp/0/pp.rbs +300 -0
  339. data/stdlib/prettyprint/0/prettyprint.rbs +2 -6
  340. data/stdlib/pstore/0/pstore.rbs +370 -156
  341. data/stdlib/psych/0/core_ext.rbs +12 -0
  342. data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
  343. data/stdlib/psych/0/manifest.yaml +3 -0
  344. data/stdlib/psych/0/psych.rbs +402 -0
  345. data/stdlib/{yaml → psych}/0/store.rbs +2 -2
  346. data/stdlib/pty/0/pty.rbs +63 -11
  347. data/stdlib/rdoc/0/code_object.rbs +51 -0
  348. data/stdlib/rdoc/0/comment.rbs +59 -0
  349. data/stdlib/rdoc/0/context.rbs +153 -0
  350. data/stdlib/rdoc/0/markup.rbs +117 -0
  351. data/stdlib/rdoc/0/parser.rbs +56 -0
  352. data/stdlib/rdoc/0/rdoc.rbs +13 -380
  353. data/stdlib/rdoc/0/ri.rbs +17 -0
  354. data/stdlib/rdoc/0/store.rbs +48 -0
  355. data/stdlib/rdoc/0/top_level.rbs +97 -0
  356. data/stdlib/resolv/0/resolv.rbs +16 -79
  357. data/stdlib/ripper/0/ripper.rbs +1648 -0
  358. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  359. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  360. data/stdlib/singleton/0/singleton.rbs +0 -3
  361. data/stdlib/socket/0/addrinfo.rbs +13 -18
  362. data/stdlib/socket/0/basic_socket.rbs +5 -10
  363. data/stdlib/socket/0/ip_socket.rbs +0 -2
  364. data/stdlib/socket/0/socket.rbs +77 -46
  365. data/stdlib/socket/0/tcp_server.rbs +0 -5
  366. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  367. data/stdlib/socket/0/udp_socket.rbs +4 -5
  368. data/stdlib/socket/0/unix_server.rbs +0 -5
  369. data/stdlib/socket/0/unix_socket.rbs +2 -4
  370. data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +188 -107
  371. data/stdlib/strscan/0/string_scanner.rbs +1269 -425
  372. data/stdlib/tempfile/0/tempfile.rbs +224 -61
  373. data/stdlib/time/0/time.rbs +48 -35
  374. data/stdlib/timeout/0/timeout.rbs +17 -8
  375. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  376. data/stdlib/tsort/0/tsort.rbs +0 -4
  377. data/stdlib/uri/0/common.rbs +271 -144
  378. data/stdlib/uri/0/file.rbs +5 -0
  379. data/stdlib/uri/0/ftp.rbs +1 -1
  380. data/stdlib/uri/0/generic.rbs +26 -22
  381. data/stdlib/uri/0/http.rbs +4 -4
  382. data/stdlib/uri/0/ldap.rbs +1 -1
  383. data/stdlib/uri/0/mailto.rbs +84 -0
  384. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  385. data/stdlib/yaml/0/manifest.yaml +1 -2
  386. data/stdlib/yaml/0/yaml.rbs +1 -199
  387. data/stdlib/zlib/0/buf_error.rbs +10 -0
  388. data/stdlib/zlib/0/data_error.rbs +10 -0
  389. data/stdlib/zlib/0/deflate.rbs +210 -0
  390. data/stdlib/zlib/0/error.rbs +20 -0
  391. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  392. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  393. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  394. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  395. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  396. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  397. data/stdlib/zlib/0/gzip_writer.rbs +166 -0
  398. data/stdlib/zlib/0/inflate.rbs +180 -0
  399. data/stdlib/zlib/0/mem_error.rbs +10 -0
  400. data/stdlib/zlib/0/need_dict.rbs +13 -0
  401. data/stdlib/zlib/0/stream_end.rbs +11 -0
  402. data/stdlib/zlib/0/stream_error.rbs +11 -0
  403. data/stdlib/zlib/0/version_error.rbs +11 -0
  404. data/stdlib/zlib/0/zlib.rbs +1 -3
  405. data/stdlib/zlib/0/zstream.rbs +200 -0
  406. data/templates/include/rbs/constants.h.erb +20 -0
  407. data/templates/include/rbs/ruby_objs.h.erb +10 -0
  408. data/templates/src/constants.c.erb +36 -0
  409. data/templates/src/ruby_objs.c.erb +27 -0
  410. data/templates/template.rb +122 -0
  411. metadata +136 -36
  412. data/Gemfile +0 -33
  413. data/Gemfile.lock +0 -118
  414. data/core/deprecated.rbs +0 -9
  415. data/ext/rbs_extension/constants.c +0 -135
  416. data/ext/rbs_extension/ruby_objs.c +0 -525
  417. data/ext/rbs_extension/ruby_objs.h +0 -43
  418. data/lib/rbs/constant_table.rb +0 -167
  419. data/lib/rbs/parser_compat/lexer_error.rb +0 -6
  420. data/lib/rbs/parser_compat/located_value.rb +0 -7
  421. data/lib/rbs/parser_compat/semantics_error.rb +0 -6
  422. data/lib/rbs/parser_compat/syntax_error.rb +0 -6
  423. data/lib/rbs/test/spy.rb +0 -6
  424. data/lib/rbs/type_name_resolver.rb +0 -67
  425. data/sig/constant_table.rbs +0 -30
  426. data/sig/shims/abstract_syntax_tree.rbs +0 -25
  427. data/sig/shims/pp.rbs +0 -3
  428. data/sig/shims/ripper.rbs +0 -8
  429. data/sig/shims.rbs +0 -69
  430. data/sig/type_name_resolver.rbs +0 -26
  431. data/stdlib/minitest/0/manifest.yaml +0 -2
  432. data/stdlib/prime/0/integer-extension.rbs +0 -41
  433. data/stdlib/prime/0/manifest.yaml +0 -2
  434. data/stdlib/prime/0/prime.rbs +0 -372
data/core/object.rbs CHANGED
@@ -18,1188 +18,93 @@
18
18
  #
19
19
  # First, what's elsewhere. Class Object:
20
20
  #
21
- # * Inherits from [class
22
- # BasicObject](BasicObject.html#class-BasicObject-label-What-27s+Here).
23
- # * Includes [module Kernel](Kernel.html#module-Kernel-label-What-27s+Here).
24
- #
21
+ # * Inherits from [class BasicObject](rdoc-ref:BasicObject@What-27s+Here).
22
+ # * Includes [module Kernel](rdoc-ref:Kernel@What-27s+Here).
25
23
  #
26
24
  # Here, class Object provides methods for:
27
25
  #
28
- # * [Querying](#class-Object-label-Querying)
29
- # * [Instance Variables](#class-Object-label-Instance+Variables)
30
- # * [Other](#class-Object-label-Other)
31
- #
26
+ # * [Querying](rdoc-ref:Object@Querying)
27
+ # * [Instance Variables](rdoc-ref:Object@Instance+Variables)
28
+ # * [Other](rdoc-ref:Object@Other)
32
29
  #
33
30
  # ### Querying
34
31
  #
35
- # [!~](#method-i-21~)
36
- # : Returns `true` if `self` does not match the given object, otherwise
37
- # `false`.
38
- #
39
- # [<=>](#method-i-3C-3D-3E)
40
- # : Returns 0 if `self` and the given object `object` are the same object,
41
- # or if `self == object`; otherwise returns `nil`.
42
- #
43
- # #===
44
- # : Implements case equality, effectively the same as calling #==.
45
- #
46
- # #eql?
47
- # : Implements hash equality, effectively the same as calling #==.
48
- #
49
- # #kind_of? (aliased as #is_a?)
50
- # : Returns whether given argument is an ancestor of the singleton class
51
- # of `self`.
52
- #
53
- # #instance_of?
54
- # : Returns whether `self` is an instance of the given class.
55
- #
56
- # #instance_variable_defined?
57
- # : Returns whether the given instance variable is defined in `self`.
58
- #
59
- # #method
60
- # : Returns the Method object for the given method in `self`.
61
- #
62
- # #methods
63
- # : Returns an array of symbol names of public and protected methods in
64
- # `self`.
65
- #
66
- # #nil?
67
- # : Returns `false`. (Only `nil` responds `true` to method `nil?`.)
68
- #
69
- # #object_id
70
- # : Returns an integer corresponding to `self` that is unique for the
71
- # current process
72
- #
73
- # #private_methods
74
- # : Returns an array of the symbol names of the private methods in `self`.
75
- #
76
- # #protected_methods
77
- # : Returns an array of the symbol names of the protected methods in
78
- # `self`.
79
- #
80
- # #public_method
81
- # : Returns the Method object for the given public method in `self`.
82
- #
83
- # #public_methods
84
- # : Returns an array of the symbol names of the public methods in `self`.
85
- #
86
- # #respond_to?
87
- # : Returns whether `self` responds to the given method.
88
- #
89
- # #singleton_class
90
- # : Returns the singleton class of `self`.
91
- #
92
- # #singleton_method
93
- # : Returns the Method object for the given singleton method in `self`.
94
- #
95
- # #singleton_methods
96
- # : Returns an array of the symbol names of the singleton methods in
97
- # `self`.
98
- #
99
- #
100
- # #define_singleton_method
101
- # : Defines a singleton method in `self` for the given symbol method-name
102
- # and block or proc.
103
- #
104
- # #extend
105
- # : Includes the given modules in the singleton class of `self`.
106
- #
107
- # #public_send
108
- # : Calls the given public method in `self` with the given argument.
109
- #
110
- # #send
111
- # : Calls the given method in `self` with the given argument.
112
- #
113
- #
32
+ # * #!~: Returns `true` if `self` does not match the given object, otherwise
33
+ # `false`.
34
+ # * #<=>: Returns 0 if `self` and the given object `object` are the same
35
+ # object, or if `self == object`; otherwise returns `nil`.
36
+ # * #===: Implements case equality, effectively the same as calling #==.
37
+ # * #eql?: Implements hash equality, effectively the same as calling #==.
38
+ # * #kind_of? (aliased as #is_a?): Returns whether given argument is an
39
+ # ancestor of the singleton class of `self`.
40
+ # * #instance_of?: Returns whether `self` is an instance of the given class.
41
+ # * #instance_variable_defined?: Returns whether the given instance variable
42
+ # is defined in `self`.
43
+ # * #method: Returns the Method object for the given method in `self`.
44
+ # * #methods: Returns an array of symbol names of public and protected methods
45
+ # in `self`.
46
+ # * #nil?: Returns `false`. (Only `nil` responds `true` to method `nil?`.)
47
+ # * #object_id: Returns an integer corresponding to `self` that is unique for
48
+ # the current process
49
+ # * #private_methods: Returns an array of the symbol names of the private
50
+ # methods in `self`.
51
+ # * #protected_methods: Returns an array of the symbol names of the protected
52
+ # methods in `self`.
53
+ # * #public_method: Returns the Method object for the given public method in
54
+ # `self`.
55
+ # * #public_methods: Returns an array of the symbol names of the public
56
+ # methods in `self`.
57
+ # * #respond_to?: Returns whether `self` responds to the given method.
58
+ # * #singleton_class: Returns the singleton class of `self`.
59
+ # * #singleton_method: Returns the Method object for the given singleton
60
+ # method in `self`.
61
+ # * #singleton_methods: Returns an array of the symbol names of the singleton
62
+ # methods in `self`.
63
+ #
64
+ # * #define_singleton_method: Defines a singleton method in `self` for the
65
+ # given symbol method-name and block or proc.
66
+ # * #extend: Includes the given modules in the singleton class of `self`.
67
+ # * #public_send: Calls the given public method in `self` with the given
68
+ # argument.
69
+ # * #send: Calls the given method in `self` with the given argument.
114
70
  #
115
71
  # ### Instance Variables
116
72
  #
117
- # #instance_variable_get
118
- # : Returns the value of the given instance variable in `self`, or `nil`
119
- # if the instance variable is not set.
120
- #
121
- # #instance_variable_set
122
- # : Sets the value of the given instance variable in `self` to the given
123
- # object.
124
- #
125
- # #instance_variables
126
- # : Returns an array of the symbol names of the instance variables in
127
- # `self`.
128
- #
129
- # #remove_instance_variable
130
- # : Removes the named instance variable from `self`.
131
- #
132
- #
73
+ # * #instance_variable_get: Returns the value of the given instance variable
74
+ # in `self`, or `nil` if the instance variable is not set.
75
+ # * #instance_variable_set: Sets the value of the given instance variable in
76
+ # `self` to the given object.
77
+ # * #instance_variables: Returns an array of the symbol names of the instance
78
+ # variables in `self`.
79
+ # * #remove_instance_variable: Removes the named instance variable from
80
+ # `self`.
133
81
  #
134
82
  # ### Other
135
83
  #
136
- # #clone
137
- # : Returns a shallow copy of `self`, including singleton class and frozen
138
- # state.
139
- #
140
- # #define_singleton_method
141
- # : Defines a singleton method in `self` for the given symbol method-name
142
- # and block or proc.
143
- #
144
- # #display
145
- # : Prints `self` to the given IO stream or `$stdout`.
146
- #
147
- # #dup
148
- # : Returns a shallow unfrozen copy of `self`.
149
- #
150
- # #enum_for (aliased as #to_enum)
151
- # : Returns an Enumerator for `self` using the using the given method,
152
- # arguments, and block.
153
- #
154
- # #extend
155
- # : Includes the given modules in the singleton class of `self`.
156
- #
157
- # #freeze
158
- # : Prevents further modifications to `self`.
159
- #
160
- # #hash
161
- # : Returns the integer hash value for `self`.
162
- #
163
- # #inspect
164
- # : Returns a human-readable string representation of `self`.
165
- #
166
- # #itself
167
- # : Returns `self`.
168
- #
169
- # #public_send
170
- # : Calls the given public method in `self` with the given argument.
171
- #
172
- # #send
173
- # : Calls the given method in `self` with the given argument.
174
- #
175
- # #to_s
176
- # : Returns a string representation of `self`.
84
+ # * #clone: Returns a shallow copy of `self`, including singleton class and
85
+ # frozen state.
86
+ # * #define_singleton_method: Defines a singleton method in `self` for the
87
+ # given symbol method-name and block or proc.
88
+ # * #display: Prints `self` to the given IO stream or `$stdout`.
89
+ # * #dup: Returns a shallow unfrozen copy of `self`.
90
+ # * #enum_for (aliased as #to_enum): Returns an Enumerator for `self` using
91
+ # the using the given method, arguments, and block.
92
+ # * #extend: Includes the given modules in the singleton class of `self`.
93
+ # * #freeze: Prevents further modifications to `self`.
94
+ # * #hash: Returns the integer hash value for `self`.
95
+ # * #inspect: Returns a human-readable string representation of `self`.
96
+ # * #itself: Returns `self`.
97
+ # * #method_missing: Method called when an undefined method is called on
98
+ # `self`.
99
+ # * #public_send: Calls the given public method in `self` with the given
100
+ # argument.
101
+ # * #send: Calls the given method in `self` with the given argument.
102
+ # * #to_s: Returns a string representation of `self`.
177
103
  #
178
104
  class Object < BasicObject
179
105
  include Kernel
180
-
181
- # <!--
182
- # rdoc-file=object.c
183
- # - obj !~ other -> true or false
184
- # -->
185
- # Returns true if two objects do not match (using the *=~* method), otherwise
186
- # false.
187
- #
188
- def !~: (untyped) -> bool
189
-
190
- # <!--
191
- # rdoc-file=object.c
192
- # - obj <=> other -> 0 or nil
193
- # -->
194
- # Returns 0 if `obj` and `other` are the same object or `obj == other`,
195
- # otherwise nil.
196
- #
197
- # The #<=> is used by various methods to compare objects, for example
198
- # Enumerable#sort, Enumerable#max etc.
199
- #
200
- # Your implementation of #<=> should return one of the following values: -1, 0,
201
- # 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
202
- # 1 means self is bigger than other. Nil means the two values could not be
203
- # compared.
204
- #
205
- # When you define #<=>, you can include Comparable to gain the methods #<=, #<,
206
- # #==, #>=, #> and #between?.
207
- #
208
- def <=>: (untyped) -> Integer?
209
-
210
- # <!--
211
- # rdoc-file=object.c
212
- # - obj === other -> true or false
213
- # -->
214
- # Case Equality -- For class Object, effectively the same as calling `#==`, but
215
- # typically overridden by descendants to provide meaningful semantics in `case`
216
- # statements.
217
- #
218
- def ===: (untyped) -> bool
219
-
220
- # <!--
221
- # rdoc-file=object.c
222
- # - obj =~ other -> nil
223
- # -->
224
- # This method is deprecated.
225
- #
226
- # This is not only useless but also troublesome because it may hide a type
227
- # error.
228
- #
229
- def =~: (untyped) -> bool
230
-
231
- # Returns the class of *obj*. This method must always be called with an explicit
232
- # receiver, as `class` is also a reserved word in Ruby.
233
- #
234
- # 1.class #=> Integer
235
- # self.class #=> Object
236
- #
237
- def class: () -> untyped
238
-
239
- # Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
240
- # but not the objects they reference. `clone` copies the frozen (unless :freeze
241
- # keyword argument is given with a false value) and tainted state of *obj*. See
242
- # also the discussion under `Object#dup`.
243
- #
244
- # class Klass
245
- # attr_accessor :str
246
- # end
247
- # s1 = Klass.new #=> #<Klass:0x401b3a38>
248
- # s1.str = "Hello" #=> "Hello"
249
- # s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello">
250
- # s2.str[1,4] = "i" #=> "i"
251
- # s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
252
- # s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
253
- #
254
- # This method may have class-specific behavior. If so, that behavior will be
255
- # documented under the #`initialize_copy` method of the class.
256
- #
257
- def clone: (?freeze: bool?) -> self
258
-
259
- # <!--
260
- # rdoc-file=proc.c
261
- # - define_singleton_method(symbol, method) -> symbol
262
- # - define_singleton_method(symbol) { block } -> symbol
263
- # -->
264
- # Defines a singleton method in the receiver. The *method* parameter can be a
265
- # `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, it
266
- # is used as the method body. If a block or a method has parameters, they're
267
- # used as method parameters.
268
- #
269
- # class A
270
- # class << self
271
- # def class_name
272
- # to_s
273
- # end
274
- # end
275
- # end
276
- # A.define_singleton_method(:who_am_i) do
277
- # "I am: #{class_name}"
278
- # end
279
- # A.who_am_i # ==> "I am: A"
280
- #
281
- # guy = "Bob"
282
- # guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
283
- # guy.hello #=> "Bob: Hello there!"
284
- #
285
- # chris = "Chris"
286
- # chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" }
287
- # chris.greet("Hi") #=> "Hi, I'm Chris!"
288
- #
289
- def define_singleton_method: (Symbol, Method | UnboundMethod) -> Symbol
290
- | (Symbol) { (*untyped) -> untyped } -> Symbol
291
-
292
- # <!--
293
- # rdoc-file=io.c
294
- # - obj.display(port=$>) -> nil
295
- # -->
296
- # Prints *obj* on the given port (default `$>`). Equivalent to:
297
- #
298
- # def display(port=$>)
299
- # port.write self
300
- # nil
301
- # end
302
- #
303
- # For example:
304
- #
305
- # 1.display
306
- # "cat".display
307
- # [ 4, 5, 6 ].display
308
- # puts
309
- #
310
- # *produces:*
311
- #
312
- # 1cat[4, 5, 6]
313
- #
314
- def display: (?_Writeable port) -> void
315
-
316
- # <!--
317
- # rdoc-file=object.c
318
- # - obj.dup -> an_object
319
- # -->
320
- # Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
321
- # but not the objects they reference.
322
- #
323
- # This method may have class-specific behavior. If so, that behavior will be
324
- # documented under the #`initialize_copy` method of the class.
325
- #
326
- # ### on dup vs clone
327
- #
328
- # In general, #clone and #dup may have different semantics in descendant
329
- # classes. While #clone is used to duplicate an object, including its internal
330
- # state, #dup typically uses the class of the descendant object to create the
331
- # new instance.
332
- #
333
- # When using #dup, any modules that the object has been extended with will not
334
- # be copied.
335
- #
336
- # class Klass
337
- # attr_accessor :str
338
- # end
339
- #
340
- # module Foo
341
- # def foo; 'foo'; end
342
- # end
343
- #
344
- # s1 = Klass.new #=> #<Klass:0x401b3a38>
345
- # s1.extend(Foo) #=> #<Klass:0x401b3a38>
346
- # s1.foo #=> "foo"
347
- #
348
- # s2 = s1.clone #=> #<Klass:0x401be280>
349
- # s2.foo #=> "foo"
350
- #
351
- # s3 = s1.dup #=> #<Klass:0x401c1084>
352
- # s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401c1084>
353
- #
354
- def dup: () -> self
355
-
356
- # <!-- rdoc-file=enumerator.c -->
357
- # Creates a new Enumerator which will enumerate by calling `method` on `obj`,
358
- # passing `args` if any. What was *yielded* by method becomes values of
359
- # enumerator.
360
- #
361
- # If a block is given, it will be used to calculate the size of the enumerator
362
- # without the need to iterate it (see Enumerator#size).
363
- #
364
- # ### Examples
365
- #
366
- # str = "xyz"
367
- #
368
- # enum = str.enum_for(:each_byte)
369
- # enum.each { |b| puts b }
370
- # # => 120
371
- # # => 121
372
- # # => 122
373
- #
374
- # # protect an array from being modified by some_method
375
- # a = [1, 2, 3]
376
- # some_method(a.to_enum)
377
- #
378
- # # String#split in block form is more memory-effective:
379
- # very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') }
380
- # # This could be rewritten more idiomatically with to_enum:
381
- # very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first
382
- #
383
- # It is typical to call to_enum when defining methods for a generic Enumerable,
384
- # in case no block is passed.
385
- #
386
- # Here is such an example, with parameter passing and a sizing block:
387
- #
388
- # module Enumerable
389
- # # a generic method to repeat the values of any enumerable
390
- # def repeat(n)
391
- # raise ArgumentError, "#{n} is negative!" if n < 0
392
- # unless block_given?
393
- # return to_enum(__method__, n) do # __method__ is :repeat here
394
- # sz = size # Call size and multiply by n...
395
- # sz * n if sz # but return nil if size itself is nil
396
- # end
397
- # end
398
- # each do |*val|
399
- # n.times { yield *val }
400
- # end
401
- # end
402
- # end
403
- #
404
- # %i[hello world].repeat(2) { |w| puts w }
405
- # # => Prints 'hello', 'hello', 'world', 'world'
406
- # enum = (1..14).repeat(3)
407
- # # => returns an Enumerator when called without a block
408
- # enum.first(4) # => [1, 1, 1, 2]
409
- # enum.size # => 42
410
- #
411
- def enum_for: (Symbol method, *untyped args) ?{ (*untyped args) -> Integer } -> Enumerator[untyped, untyped]
412
- | () ?{ () -> Integer } -> Enumerator[untyped, self]
413
-
414
- # <!--
415
- # rdoc-file=enumerator.c
416
- # - obj.to_enum(method = :each, *args) -> enum
417
- # - obj.enum_for(method = :each, *args) -> enum
418
- # - obj.to_enum(method = :each, *args) {|*args| block} -> enum
419
- # - obj.enum_for(method = :each, *args){|*args| block} -> enum
420
- # -->
421
- # Creates a new Enumerator which will enumerate by calling `method` on `obj`,
422
- # passing `args` if any. What was *yielded* by method becomes values of
423
- # enumerator.
424
- #
425
- # If a block is given, it will be used to calculate the size of the enumerator
426
- # without the need to iterate it (see Enumerator#size).
427
- #
428
- # ### Examples
429
- #
430
- # str = "xyz"
431
- #
432
- # enum = str.enum_for(:each_byte)
433
- # enum.each { |b| puts b }
434
- # # => 120
435
- # # => 121
436
- # # => 122
437
- #
438
- # # protect an array from being modified by some_method
439
- # a = [1, 2, 3]
440
- # some_method(a.to_enum)
441
- #
442
- # # String#split in block form is more memory-effective:
443
- # very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') }
444
- # # This could be rewritten more idiomatically with to_enum:
445
- # very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first
446
- #
447
- # It is typical to call to_enum when defining methods for a generic Enumerable,
448
- # in case no block is passed.
449
- #
450
- # Here is such an example, with parameter passing and a sizing block:
451
- #
452
- # module Enumerable
453
- # # a generic method to repeat the values of any enumerable
454
- # def repeat(n)
455
- # raise ArgumentError, "#{n} is negative!" if n < 0
456
- # unless block_given?
457
- # return to_enum(__method__, n) do # __method__ is :repeat here
458
- # sz = size # Call size and multiply by n...
459
- # sz * n if sz # but return nil if size itself is nil
460
- # end
461
- # end
462
- # each do |*val|
463
- # n.times { yield *val }
464
- # end
465
- # end
466
- # end
467
- #
468
- # %i[hello world].repeat(2) { |w| puts w }
469
- # # => Prints 'hello', 'hello', 'world', 'world'
470
- # enum = (1..14).repeat(3)
471
- # # => returns an Enumerator when called without a block
472
- # enum.first(4) # => [1, 1, 1, 2]
473
- # enum.size # => 42
474
- #
475
- alias to_enum enum_for
476
-
477
- # <!--
478
- # rdoc-file=object.c
479
- # - obj == other -> true or false
480
- # - obj.equal?(other) -> true or false
481
- # - obj.eql?(other) -> true or false
482
- # -->
483
- # Equality --- At the Object level, #== returns `true` only if `obj` and `other`
484
- # are the same object. Typically, this method is overridden in descendant
485
- # classes to provide class-specific meaning.
486
- #
487
- # Unlike #==, the #equal? method should never be overridden by subclasses as it
488
- # is used to determine object identity (that is, `a.equal?(b)` if and only if
489
- # `a` is the same object as `b`):
490
- #
491
- # obj = "a"
492
- # other = obj.dup
493
- #
494
- # obj == other #=> true
495
- # obj.equal? other #=> false
496
- # obj.equal? obj #=> true
497
- #
498
- # The #eql? method returns `true` if `obj` and `other` refer to the same hash
499
- # key. This is used by Hash to test members for equality. For any pair of
500
- # objects where #eql? returns `true`, the #hash value of both objects must be
501
- # equal. So any subclass that overrides #eql? should also override #hash
502
- # appropriately.
503
- #
504
- # For objects of class Object, #eql? is synonymous with #==. Subclasses
505
- # normally continue this tradition by aliasing #eql? to their overridden #==
506
- # method, but there are exceptions. Numeric types, for example, perform type
507
- # conversion across #==, but not across #eql?, so:
508
- #
509
- # 1 == 1.0 #=> true
510
- # 1.eql? 1.0 #=> false
511
- #
512
- def eql?: (untyped) -> bool
513
-
514
- # <!--
515
- # rdoc-file=eval.c
516
- # - obj.extend(module, ...) -> obj
517
- # -->
518
- # Adds to *obj* the instance methods from each module given as a parameter.
519
- #
520
- # module Mod
521
- # def hello
522
- # "Hello from Mod.\n"
523
- # end
524
- # end
525
- #
526
- # class Klass
527
- # def hello
528
- # "Hello from Klass.\n"
529
- # end
530
- # end
531
- #
532
- # k = Klass.new
533
- # k.hello #=> "Hello from Klass.\n"
534
- # k.extend(Mod) #=> #<Klass:0x401b3bc8>
535
- # k.hello #=> "Hello from Mod.\n"
536
- #
537
- def extend: (*Module) -> self
538
-
539
- # <!--
540
- # rdoc-file=object.c
541
- # - obj.freeze -> obj
542
- # -->
543
- # Prevents further modifications to *obj*. A FrozenError will be raised if
544
- # modification is attempted. There is no way to unfreeze a frozen object. See
545
- # also Object#frozen?.
546
- #
547
- # This method returns self.
548
- #
549
- # a = [ "a", "b", "c" ]
550
- # a.freeze
551
- # a << "z"
552
- #
553
- # *produces:*
554
- #
555
- # prog.rb:3:in `<<': can't modify frozen Array (FrozenError)
556
- # from prog.rb:3
557
- #
558
- # Objects of the following classes are always frozen: Integer, Float, Symbol.
559
- #
560
- def freeze: () -> self
561
-
562
- # Returns the freeze status of *obj*.
563
- #
564
- # a = [ "a", "b", "c" ]
565
- # a.freeze #=> ["a", "b", "c"]
566
- # a.frozen? #=> true
567
- #
568
- def frozen?: () -> bool
569
-
570
- # <!--
571
- # rdoc-file=object.c
572
- # - obj.hash -> integer
573
- # -->
574
- # Generates an Integer hash value for this object. This function must have the
575
- # property that `a.eql?(b)` implies `a.hash == b.hash`.
576
- #
577
- # The hash value is used along with #eql? by the Hash class to determine if two
578
- # objects reference the same hash key. Any hash value that exceeds the capacity
579
- # of an Integer will be truncated before being used.
580
- #
581
- # The hash value for an object may not be identical across invocations or
582
- # implementations of Ruby. If you need a stable identifier across Ruby
583
- # invocations and implementations you will need to generate one with a custom
584
- # method.
585
- #
586
- # Certain core classes such as Integer use built-in hash calculations and do not
587
- # call the #hash method when used as a hash key.
588
- #
589
- def hash: () -> Integer
590
-
591
- # <!--
592
- # rdoc-file=object.c
593
- # - obj.inspect -> string
594
- # -->
595
- # Returns a string containing a human-readable representation of *obj*. The
596
- # default #inspect shows the object's class name, an encoding of its memory
597
- # address, and a list of the instance variables and their values (by calling
598
- # #inspect on each of them). User defined classes should override this method
599
- # to provide a better representation of *obj*. When overriding this method, it
600
- # should return a string whose encoding is compatible with the default external
601
- # encoding.
602
- #
603
- # [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
604
- # Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
605
- #
606
- # class Foo
607
- # end
608
- # Foo.new.inspect #=> "#<Foo:0x0300c868>"
609
- #
610
- # class Bar
611
- # def initialize
612
- # @bar = 1
613
- # end
614
- # end
615
- # Bar.new.inspect #=> "#<Bar:0x0300c868 @bar=1>"
616
- #
617
- def inspect: () -> String
618
-
619
- # <!--
620
- # rdoc-file=object.c
621
- # - obj.instance_of?(class) -> true or false
622
- # -->
623
- # Returns `true` if *obj* is an instance of the given class. See also
624
- # Object#kind_of?.
625
- #
626
- # class A; end
627
- # class B < A; end
628
- # class C < B; end
629
- #
630
- # b = B.new
631
- # b.instance_of? A #=> false
632
- # b.instance_of? B #=> true
633
- # b.instance_of? C #=> false
634
- #
635
- def instance_of?: (Module) -> bool
636
-
637
- # <!--
638
- # rdoc-file=object.c
639
- # - obj.instance_variable_defined?(symbol) -> true or false
640
- # - obj.instance_variable_defined?(string) -> true or false
641
- # -->
642
- # Returns `true` if the given instance variable is defined in *obj*. String
643
- # arguments are converted to symbols.
644
- #
645
- # class Fred
646
- # def initialize(p1, p2)
647
- # @a, @b = p1, p2
648
- # end
649
- # end
650
- # fred = Fred.new('cat', 99)
651
- # fred.instance_variable_defined?(:@a) #=> true
652
- # fred.instance_variable_defined?("@b") #=> true
653
- # fred.instance_variable_defined?("@c") #=> false
654
- #
655
- def instance_variable_defined?: (String | Symbol var) -> bool
656
-
657
- # <!--
658
- # rdoc-file=object.c
659
- # - obj.instance_variable_get(symbol) -> obj
660
- # - obj.instance_variable_get(string) -> obj
661
- # -->
662
- # Returns the value of the given instance variable, or nil if the instance
663
- # variable is not set. The `@` part of the variable name should be included for
664
- # regular instance variables. Throws a NameError exception if the supplied
665
- # symbol is not valid as an instance variable name. String arguments are
666
- # converted to symbols.
667
- #
668
- # class Fred
669
- # def initialize(p1, p2)
670
- # @a, @b = p1, p2
671
- # end
672
- # end
673
- # fred = Fred.new('cat', 99)
674
- # fred.instance_variable_get(:@a) #=> "cat"
675
- # fred.instance_variable_get("@b") #=> 99
676
- #
677
- def instance_variable_get: (String | Symbol var) -> untyped
678
-
679
- # <!--
680
- # rdoc-file=object.c
681
- # - obj.instance_variable_set(symbol, obj) -> obj
682
- # - obj.instance_variable_set(string, obj) -> obj
683
- # -->
684
- # Sets the instance variable named by *symbol* to the given object. This may
685
- # circumvent the encapsulation intended by the author of the class, so it should
686
- # be used with care. The variable does not have to exist prior to this call. If
687
- # the instance variable name is passed as a string, that string is converted to
688
- # a symbol.
689
- #
690
- # class Fred
691
- # def initialize(p1, p2)
692
- # @a, @b = p1, p2
693
- # end
694
- # end
695
- # fred = Fred.new('cat', 99)
696
- # fred.instance_variable_set(:@a, 'dog') #=> "dog"
697
- # fred.instance_variable_set(:@c, 'cat') #=> "cat"
698
- # fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
699
- #
700
- def instance_variable_set: [X] (String | Symbol var, X value) -> X
701
-
702
- # <!--
703
- # rdoc-file=object.c
704
- # - obj.instance_variables -> array
705
- # -->
706
- # Returns an array of instance variable names for the receiver. Note that simply
707
- # defining an accessor does not create the corresponding instance variable.
708
- #
709
- # class Fred
710
- # attr_accessor :a1
711
- # def initialize
712
- # @iv = 3
713
- # end
714
- # end
715
- # Fred.new.instance_variables #=> [:@iv]
716
- #
717
- def instance_variables: () -> Array[Symbol]
718
-
719
- # <!-- rdoc-file=object.c -->
720
- # Returns `true` if *class* is the class of *obj*, or if *class* is one of the
721
- # superclasses of *obj* or modules included in *obj*.
722
- #
723
- # module M; end
724
- # class A
725
- # include M
726
- # end
727
- # class B < A; end
728
- # class C < B; end
729
- #
730
- # b = B.new
731
- # b.is_a? A #=> true
732
- # b.is_a? B #=> true
733
- # b.is_a? C #=> false
734
- # b.is_a? M #=> true
735
- #
736
- # b.kind_of? A #=> true
737
- # b.kind_of? B #=> true
738
- # b.kind_of? C #=> false
739
- # b.kind_of? M #=> true
740
- #
741
- def is_a?: (Module) -> bool
742
-
743
- # <!--
744
- # rdoc-file=object.c
745
- # - obj.is_a?(class) -> true or false
746
- # - obj.kind_of?(class) -> true or false
747
- # -->
748
- # Returns `true` if *class* is the class of *obj*, or if *class* is one of the
749
- # superclasses of *obj* or modules included in *obj*.
750
- #
751
- # module M; end
752
- # class A
753
- # include M
754
- # end
755
- # class B < A; end
756
- # class C < B; end
757
- #
758
- # b = B.new
759
- # b.is_a? A #=> true
760
- # b.is_a? B #=> true
761
- # b.is_a? C #=> false
762
- # b.is_a? M #=> true
763
- #
764
- # b.kind_of? A #=> true
765
- # b.kind_of? B #=> true
766
- # b.kind_of? C #=> false
767
- # b.kind_of? M #=> true
768
- #
769
- alias kind_of? is_a?
770
-
771
- # <!--
772
- # rdoc-file=object.c
773
- # - obj.itself -> obj
774
- # -->
775
- # Returns the receiver.
776
- #
777
- # string = "my string"
778
- # string.itself.object_id == string.object_id #=> true
779
- #
780
- def itself: () -> self
781
-
782
- # <!--
783
- # rdoc-file=proc.c
784
- # - obj.method(sym) -> method
785
- # -->
786
- # Looks up the named method as a receiver in *obj*, returning a Method object
787
- # (or raising NameError). The Method object acts as a closure in *obj*'s object
788
- # instance, so instance variables and the value of `self` remain available.
789
- #
790
- # class Demo
791
- # def initialize(n)
792
- # @iv = n
793
- # end
794
- # def hello()
795
- # "Hello, @iv = #{@iv}"
796
- # end
797
- # end
798
- #
799
- # k = Demo.new(99)
800
- # m = k.method(:hello)
801
- # m.call #=> "Hello, @iv = 99"
802
- #
803
- # l = Demo.new('Fred')
804
- # m = l.method("hello")
805
- # m.call #=> "Hello, @iv = Fred"
806
- #
807
- # Note that Method implements `to_proc` method, which means it can be used with
808
- # iterators.
809
- #
810
- # [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
811
- #
812
- # out = File.open('test.txt', 'w')
813
- # [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
814
- #
815
- # require 'date'
816
- # %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
817
- # #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
818
- #
819
- def method: (String | Symbol name) -> Method
820
-
821
- # <!--
822
- # rdoc-file=object.c
823
- # - obj.methods(regular=true) -> array
824
- # -->
825
- # Returns a list of the names of public and protected methods of *obj*. This
826
- # will include all the methods accessible in *obj*'s ancestors. If the optional
827
- # parameter is `false`, it returns an array of *obj*'s public and protected
828
- # singleton methods, the array will not include methods in modules included in
829
- # *obj*.
830
- #
831
- # class Klass
832
- # def klass_method()
833
- # end
834
- # end
835
- # k = Klass.new
836
- # k.methods[0..9] #=> [:klass_method, :nil?, :===,
837
- # # :==~, :!, :eql?
838
- # # :hash, :<=>, :class, :singleton_class]
839
- # k.methods.length #=> 56
840
- #
841
- # k.methods(false) #=> []
842
- # def k.singleton_method; end
843
- # k.methods(false) #=> [:singleton_method]
844
- #
845
- # module M123; def m123; end end
846
- # k.extend M123
847
- # k.methods(false) #=> [:singleton_method]
848
- #
849
- def methods: () -> Array[Symbol]
850
-
851
- # <!--
852
- # rdoc-file=object.c
853
- # - obj.nil? -> true or false
854
- # -->
855
- # Only the object *nil* responds `true` to `nil?`.
856
- #
857
- # Object.new.nil? #=> false
858
- # nil.nil? #=> true
859
- #
860
- def nil?: () -> bool
861
-
862
- # <!--
863
- # rdoc-file=gc.c
864
- # - obj.__id__ -> integer
865
- # - obj.object_id -> integer
866
- # -->
867
- # Returns an integer identifier for `obj`.
868
- #
869
- # The same number will be returned on all calls to `object_id` for a given
870
- # object, and no two active objects will share an id.
871
- #
872
- # Note: that some objects of builtin classes are reused for optimization. This
873
- # is the case for immediate values and frozen string literals.
874
- #
875
- # BasicObject implements +__id__+, Kernel implements `object_id`.
876
- #
877
- # Immediate values are not passed by reference but are passed by value: `nil`,
878
- # `true`, `false`, Fixnums, Symbols, and some Floats.
879
- #
880
- # Object.new.object_id == Object.new.object_id # => false
881
- # (21 * 2).object_id == (21 * 2).object_id # => true
882
- # "hello".object_id == "hello".object_id # => false
883
- # "hi".freeze.object_id == "hi".freeze.object_id # => true
884
- #
885
- def object_id: () -> Integer
886
-
887
- # <!--
888
- # rdoc-file=object.c
889
- # - obj.private_methods(all=true) -> array
890
- # -->
891
- # Returns the list of private methods accessible to *obj*. If the *all*
892
- # parameter is set to `false`, only those methods in the receiver will be
893
- # listed.
894
- #
895
- def private_methods: () -> Array[Symbol]
896
-
897
- # <!--
898
- # rdoc-file=object.c
899
- # - obj.protected_methods(all=true) -> array
900
- # -->
901
- # Returns the list of protected methods accessible to *obj*. If the *all*
902
- # parameter is set to `false`, only those methods in the receiver will be
903
- # listed.
904
- #
905
- def protected_methods: () -> Array[Symbol]
906
-
907
- # <!--
908
- # rdoc-file=proc.c
909
- # - obj.public_method(sym) -> method
910
- # -->
911
- # Similar to *method*, searches public method only.
912
- #
913
- def public_method: (name name) -> Method
914
-
915
- # <!--
916
- # rdoc-file=object.c
917
- # - obj.public_methods(all=true) -> array
918
- # -->
919
- # Returns the list of public methods accessible to *obj*. If the *all* parameter
920
- # is set to `false`, only those methods in the receiver will be listed.
921
- #
922
- def public_methods: (?boolish all) -> Array[Symbol]
923
-
924
- # <!--
925
- # rdoc-file=vm_eval.c
926
- # - obj.public_send(symbol [, args...]) -> obj
927
- # - obj.public_send(string [, args...]) -> obj
928
- # -->
929
- # Invokes the method identified by *symbol*, passing it any arguments specified.
930
- # Unlike send, public_send calls public methods only. When the method is
931
- # identified by a string, the string is converted to a symbol.
932
- #
933
- # 1.public_send(:puts, "hello") # causes NoMethodError
934
- #
935
- def public_send: (name name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
936
-
937
- # <!--
938
- # rdoc-file=object.c
939
- # - obj.remove_instance_variable(symbol) -> obj
940
- # - obj.remove_instance_variable(string) -> obj
941
- # -->
942
- # Removes the named instance variable from *obj*, returning that variable's
943
- # value. String arguments are converted to symbols.
944
- #
945
- # class Dummy
946
- # attr_reader :var
947
- # def initialize
948
- # @var = 99
949
- # end
950
- # def remove
951
- # remove_instance_variable(:@var)
952
- # end
953
- # end
954
- # d = Dummy.new
955
- # d.var #=> 99
956
- # d.remove #=> 99
957
- # d.var #=> nil
958
- #
959
- def remove_instance_variable: (name name) -> untyped
960
-
961
- # <!--
962
- # rdoc-file=vm_method.c
963
- # - obj.respond_to?(symbol, include_all=false) -> true or false
964
- # - obj.respond_to?(string, include_all=false) -> true or false
965
- # -->
966
- # Returns `true` if *obj* responds to the given method. Private and protected
967
- # methods are included in the search only if the optional second parameter
968
- # evaluates to `true`.
969
- #
970
- # If the method is not implemented, as Process.fork on Windows, File.lchmod on
971
- # GNU/Linux, etc., false is returned.
972
- #
973
- # If the method is not defined, `respond_to_missing?` method is called and the
974
- # result is returned.
975
- #
976
- # When the method name parameter is given as a string, the string is converted
977
- # to a symbol.
978
- #
979
- def respond_to?: (name name, ?boolish include_all) -> bool
980
-
981
- # <!--
982
- # rdoc-file=vm_eval.c
983
- # - foo.send(symbol [, args...]) -> obj
984
- # - foo.__send__(symbol [, args...]) -> obj
985
- # - foo.send(string [, args...]) -> obj
986
- # - foo.__send__(string [, args...]) -> obj
987
- # -->
988
- # Invokes the method identified by *symbol*, passing it any arguments specified.
989
- # When the method is identified by a string, the string is converted to a
990
- # symbol.
991
- #
992
- # BasicObject implements +__send__+, Kernel implements `send`. `__send__` is
993
- # safer than `send` when *obj* has the same method name like `Socket`. See also
994
- # `public_send`.
995
- #
996
- # class Klass
997
- # def hello(*args)
998
- # "Hello " + args.join(' ')
999
- # end
1000
- # end
1001
- # k = Klass.new
1002
- # k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
1003
- #
1004
- def send: (name name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
1005
-
1006
- # <!--
1007
- # rdoc-file=object.c
1008
- # - obj.singleton_class -> class
1009
- # -->
1010
- # Returns the singleton class of *obj*. This method creates a new singleton
1011
- # class if *obj* does not have one.
1012
- #
1013
- # If *obj* is `nil`, `true`, or `false`, it returns NilClass, TrueClass, or
1014
- # FalseClass, respectively. If *obj* is an Integer, a Float or a Symbol, it
1015
- # raises a TypeError.
1016
- #
1017
- # Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
1018
- # String.singleton_class #=> #<Class:String>
1019
- # nil.singleton_class #=> NilClass
1020
- #
1021
- def singleton_class: () -> Class
1022
-
1023
- # <!--
1024
- # rdoc-file=proc.c
1025
- # - obj.singleton_method(sym) -> method
1026
- # -->
1027
- # Similar to *method*, searches singleton method only.
1028
- #
1029
- # class Demo
1030
- # def initialize(n)
1031
- # @iv = n
1032
- # end
1033
- # def hello()
1034
- # "Hello, @iv = #{@iv}"
1035
- # end
1036
- # end
1037
- #
1038
- # k = Demo.new(99)
1039
- # def k.hi
1040
- # "Hi, @iv = #{@iv}"
1041
- # end
1042
- # m = k.singleton_method(:hi)
1043
- # m.call #=> "Hi, @iv = 99"
1044
- # m = k.singleton_method(:hello) #=> NameError
1045
- #
1046
- def singleton_method: (name name) -> Method
1047
-
1048
- # <!--
1049
- # rdoc-file=object.c
1050
- # - obj.singleton_methods(all=true) -> array
1051
- # -->
1052
- # Returns an array of the names of singleton methods for *obj*. If the optional
1053
- # *all* parameter is true, the list will include methods in modules included in
1054
- # *obj*. Only public and protected singleton methods are returned.
1055
- #
1056
- # module Other
1057
- # def three() end
1058
- # end
1059
- #
1060
- # class Single
1061
- # def Single.four() end
1062
- # end
1063
- #
1064
- # a = Single.new
1065
- #
1066
- # def a.one()
1067
- # end
1068
- #
1069
- # class << a
1070
- # include Other
1071
- # def two()
1072
- # end
1073
- # end
1074
- #
1075
- # Single.singleton_methods #=> [:four]
1076
- # a.singleton_methods(false) #=> [:two, :one]
1077
- # a.singleton_methods #=> [:two, :one, :three]
1078
- #
1079
- def singleton_methods: () -> Array[Symbol]
1080
-
1081
- # <!--
1082
- # rdoc-file=object.c
1083
- # - obj.taint -> obj
1084
- # -->
1085
- # Returns object. This method is deprecated and will be removed in Ruby 3.2.
1086
- #
1087
- def taint: () -> self
1088
-
1089
- # <!--
1090
- # rdoc-file=object.c
1091
- # - obj.untrust -> obj
1092
- # -->
1093
- # Returns object. This method is deprecated and will be removed in Ruby 3.2.
1094
- #
1095
- alias untrust taint
1096
-
1097
- # <!--
1098
- # rdoc-file=object.c
1099
- # - obj.tainted? -> false
1100
- # -->
1101
- # Returns false. This method is deprecated and will be removed in Ruby 3.2.
1102
- #
1103
- def tainted?: () -> bool
1104
-
1105
- # <!--
1106
- # rdoc-file=object.c
1107
- # - obj.untrusted? -> false
1108
- # -->
1109
- # Returns false. This method is deprecated and will be removed in Ruby 3.2.
1110
- #
1111
- alias untrusted? tainted?
1112
-
1113
- # Yields self to the block, and then returns self. The primary purpose of this
1114
- # method is to "tap into" a method chain, in order to perform operations on
1115
- # intermediate results within the chain.
1116
- #
1117
- # (1..10) .tap {|x| puts "original: #{x}" }
1118
- # .to_a .tap {|x| puts "array: #{x}" }
1119
- # .select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
1120
- # .map {|x| x*x } .tap {|x| puts "squares: #{x}" }
1121
- #
1122
- def tap: () { (self) -> void } -> self
1123
-
1124
- # Yields self to the block and returns the result of the block.
1125
- #
1126
- # 3.next.then {|x| x**x }.to_s #=> "256"
1127
- # "my string".yield_self {|s| s.upcase } #=> "MY STRING"
1128
- #
1129
- # Good usage for `yield_self` is value piping in method chains:
1130
- #
1131
- # require 'open-uri'
1132
- # require 'json'
1133
- #
1134
- # construct_url(arguments).
1135
- # yield_self {|url| open(url).read }.
1136
- # yield_self {|response| JSON.parse(response) }
1137
- #
1138
- # When called without block, the method returns `Enumerator`, which can be used,
1139
- # for example, for conditional circuit-breaking:
1140
- #
1141
- # # meets condition, no-op
1142
- # 1.yield_self.detect(&:odd?) # => 1
1143
- # # does not meet condition, drop value
1144
- # 2.yield_self.detect(&:odd?) # => nil
1145
- #
1146
- def yield_self: [X] () { (self) -> X } -> X
1147
- | () -> Enumerator[self, untyped]
1148
-
1149
- # <!--
1150
- # rdoc-file=object.c
1151
- # - obj.to_s -> string
1152
- # -->
1153
- # Returns a string representing *obj*. The default #to_s prints the object's
1154
- # class and an encoding of the object id. As a special case, the top-level
1155
- # object that is the initial execution context of Ruby programs returns
1156
- # ``main''.
1157
- #
1158
- def to_s: () -> String
1159
-
1160
- # <!--
1161
- # rdoc-file=object.c
1162
- # - obj.untaint -> obj
1163
- # -->
1164
- # Returns object. This method is deprecated and will be removed in Ruby 3.2.
1165
- #
1166
- def untaint: () -> self
1167
-
1168
- # <!--
1169
- # rdoc-file=object.c
1170
- # - obj.trust -> obj
1171
- # -->
1172
- # Returns object. This method is deprecated and will be removed in Ruby 3.2.
1173
- #
1174
- alias trust untaint
1175
-
1176
- # Yields self to the block and returns the result of the block.
1177
- #
1178
- # 3.next.then {|x| x**x }.to_s #=> "256"
1179
- # "my string".yield_self {|s| s.upcase } #=> "MY STRING"
1180
- #
1181
- # Good usage for `yield_self` is value piping in method chains:
1182
- #
1183
- # require 'open-uri'
1184
- # require 'json'
1185
- #
1186
- # construct_url(arguments).
1187
- # yield_self {|url| open(url).read }.
1188
- # yield_self {|response| JSON.parse(response) }
1189
- #
1190
- # When called without block, the method returns `Enumerator`, which can be used,
1191
- # for example, for conditional circuit-breaking:
1192
- #
1193
- # # meets condition, no-op
1194
- # 1.yield_self.detect(&:odd?) # => 1
1195
- # # does not meet condition, drop value
1196
- # 2.yield_self.detect(&:odd?) # => nil
1197
- #
1198
- alias then yield_self
1199
- end
1200
-
1201
- interface _Writeable
1202
- def write: (untyped) -> void
1203
106
  end
1204
107
 
1205
- type Object::name = Symbol | String
108
+ # A previous incarnation of `interned` for backward-compatibility (see #1499)
109
+ %a{steep:deprecated}
110
+ type Object::name = interned