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
@@ -8,6 +8,8 @@ end
8
8
 
9
9
  interface _JsonWrite
10
10
  def write: (String json) -> void
11
+
12
+ def flush: () -> void
11
13
  end
12
14
 
13
15
  interface _JsonReadableIO
@@ -115,7 +117,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
115
117
  # name is double-quoted text; the values may be any JSON values:
116
118
  # {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}
117
119
  #
118
- #
119
120
  # A JSON array or object may contain nested arrays, objects, and scalars to any
120
121
  # depth:
121
122
  # {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}
@@ -134,13 +135,11 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
134
135
  # * `JSON.parse(source, opts)`
135
136
  # * `JSON.parse!(source, opts)`
136
137
  #
137
- #
138
138
  # where
139
139
  # * `source` is a Ruby object.
140
140
  # * `opts` is a Hash object containing options that control both input allowed
141
141
  # and output formatting.
142
142
  #
143
- #
144
143
  # The difference between the two methods is that JSON.parse! omits some checks
145
144
  # and may not be safe for some `source` data; use it only for data from trusted
146
145
  # sources. Use the safer method JSON.parse for less trusted sources.
@@ -298,7 +297,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
298
297
  # * `opts` is a Hash object containing options that control both input allowed
299
298
  # and output formatting.
300
299
  #
301
- #
302
300
  # #### Generating JSON from Arrays
303
301
  #
304
302
  # When the source is a Ruby Array, JSON.generate returns a String containing a
@@ -385,6 +383,15 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
385
383
  # # Raises JSON::NestingError (nesting of 2 is too deep):
386
384
  # JSON.generate(obj, max_nesting: 2)
387
385
  #
386
+ # ###### Escaping Options
387
+ #
388
+ # Options `script_safe` (boolean) specifies wether `'\u2028'`, `'\u2029'` and
389
+ # `'/'` should be escaped as to make the JSON object safe to interpolate in
390
+ # script tags.
391
+ #
392
+ # Options `ascii_only` (boolean) specifies wether all characters outside the
393
+ # ASCII range should be escaped.
394
+ #
388
395
  # ###### Output Options
389
396
  #
390
397
  # The default formatting options generate the most compact JSON data, all on one
@@ -408,7 +415,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
408
415
  # inserted before the colon in each JSON object's pair; defaults to the
409
416
  # empty String, `''`.
410
417
  #
411
- #
412
418
  # In this example, `obj` is used first to generate the shortest JSON data (no
413
419
  # whitespace), then again with all formatting options specified:
414
420
  #
@@ -456,7 +462,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
456
462
  # * JSON.parse, called with option `create_additions`, uses that information
457
463
  # to create a proper Ruby object.
458
464
  #
459
- #
460
465
  # This example shows a Range being generated into JSON and parsed back into
461
466
  # Ruby, both without and with the addition for Range:
462
467
  # ruby = Range.new(0, 2)
@@ -468,13 +473,13 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
468
473
  # json1 = JSON.generate(ruby)
469
474
  # ruby1 = JSON.parse(json1, create_additions: true)
470
475
  # # Make a nice display.
471
- # display = <<EOT
472
- # Generated JSON:
473
- # Without addition: #{json0} (#{json0.class})
474
- # With addition: #{json1} (#{json1.class})
475
- # Parsed JSON:
476
- # Without addition: #{ruby0.inspect} (#{ruby0.class})
477
- # With addition: #{ruby1.inspect} (#{ruby1.class})
476
+ # display = <<~EOT
477
+ # Generated JSON:
478
+ # Without addition: #{json0} (#{json0.class})
479
+ # With addition: #{json1} (#{json1.class})
480
+ # Parsed JSON:
481
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
482
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
478
483
  # EOT
479
484
  # puts display
480
485
  #
@@ -508,7 +513,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
508
513
  # * Symbol: `require 'json/add/symbol'`
509
514
  # * Time: `require 'json/add/time'`
510
515
  #
511
- #
512
516
  # To reduce punctuation clutter, the examples below show the generated JSON via
513
517
  # `puts`, rather than the usual `inspect`,
514
518
  #
@@ -651,13 +655,13 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
651
655
  # json1 = JSON.generate(foo1)
652
656
  # obj1 = JSON.parse(json1, create_additions: true)
653
657
  # # Make a nice display.
654
- # display = <<EOT
655
- # Generated JSON:
656
- # Without custom addition: #{json0} (#{json0.class})
657
- # With custom addition: #{json1} (#{json1.class})
658
- # Parsed JSON:
659
- # Without custom addition: #{obj0.inspect} (#{obj0.class})
660
- # With custom addition: #{obj1.inspect} (#{obj1.class})
658
+ # display = <<~EOT
659
+ # Generated JSON:
660
+ # Without custom addition: #{json0} (#{json0.class})
661
+ # With custom addition: #{json1} (#{json1.class})
662
+ # Parsed JSON:
663
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
664
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
661
665
  # EOT
662
666
  # puts display
663
667
  #
@@ -705,7 +709,7 @@ module JSON
705
709
  #
706
710
  def self.create_id=: (_ToS create_id) -> _ToS
707
711
 
708
- def self.deep_const_get: (_ToS path) -> untyped
712
+ def self.deep_const_get: (interned path) -> untyped
709
713
 
710
714
  # <!--
711
715
  # rdoc-file=ext/json/lib/json/common.rb
@@ -722,7 +726,6 @@ module JSON
722
726
  # * Argument `limit`, if given, is passed to JSON.generate as option
723
727
  # `max_nesting`.
724
728
  #
725
- #
726
729
  # ---
727
730
  #
728
731
  # When argument `io` is not given, returns the JSON String generated from `obj`:
@@ -747,14 +750,14 @@ module JSON
747
750
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
748
751
  # Sets or returns the default options for the JSON.dump method. Initially:
749
752
  # opts = JSON.dump_default_options
750
- # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
753
+ # opts # => {:max_nesting=>false, :allow_nan=>true}
751
754
  #
752
755
  def self.dump_default_options: () -> json_options
753
756
 
754
757
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
755
758
  # Sets or returns the default options for the JSON.dump method. Initially:
756
759
  # opts = JSON.dump_default_options
757
- # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
760
+ # opts # => {:max_nesting=>false, :allow_nan=>true}
758
761
  #
759
762
  def self.dump_default_options=: (json_options) -> json_options
760
763
 
@@ -819,9 +822,7 @@ module JSON
819
822
  def self?.generate: (_ToJson obj, ?json_options opts) -> String
820
823
 
821
824
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
822
- # Returns the JSON generator module that is used by JSON. This is either
823
- # JSON::Ext::Generator or JSON::Pure::Generator:
824
- # JSON.generator # => JSON::Ext::Generator
825
+ # Returns the JSON generator module that is used by JSON.
825
826
  #
826
827
  def self.generator: () -> json_generator
827
828
 
@@ -841,6 +842,15 @@ module JSON
841
842
  # -->
842
843
  # Returns the Ruby objects created by parsing the given `source`.
843
844
  #
845
+ # BEWARE: This method is meant to serialise data from trusted user input, like
846
+ # from your own database server or clients under your control, it could be
847
+ # dangerous to allow untrusted users to pass JSON sources into it. If you must
848
+ # use it, use JSON.unsafe_load instead to make it clear.
849
+ #
850
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a non native
851
+ # type is deserialized, without `create_additions` being explicitly enabled, and
852
+ # in JSON version 3.0, `load` will have `create_additions` disabled by default.
853
+ #
844
854
  # * Argument `source` must be, or be convertible to, a String:
845
855
  # * If `source` responds to instance method `to_str`, `source.to_str`
846
856
  # becomes the source.
@@ -851,37 +861,31 @@ module JSON
851
861
  # * If both of the following are true, source becomes the String `'null'`:
852
862
  # * Option `allow_blank` specifies a truthy value.
853
863
  # * The source, as defined above, is `nil` or the empty String `''`.
854
- #
855
864
  # * Otherwise, `source` remains the source.
856
- #
857
865
  # * Argument `proc`, if given, must be a Proc that accepts one argument. It
858
866
  # will be called recursively with each result (depth-first order). See
859
- # details below. BEWARE: This method is meant to serialise data from trusted
860
- # user input, like from your own database server or clients under your
861
- # control, it could be dangerous to allow untrusted users to pass JSON
862
- # sources into it.
867
+ # details below.
863
868
  # * Argument `opts`, if given, contains a Hash of options for the parsing. See
864
869
  # [Parsing Options](#module-JSON-label-Parsing+Options). The default options
865
870
  # can be changed via method JSON.load_default_options=.
866
871
  #
867
- #
868
872
  # ---
869
873
  #
870
874
  # When no `proc` is given, modifies `source` as above and returns the result of
871
875
  # `parse(source, opts)`; see #parse.
872
876
  #
873
877
  # Source for following examples:
874
- # source = <<-EOT
875
- # {
876
- # "name": "Dave",
877
- # "age" :40,
878
- # "hats": [
879
- # "Cattleman's",
880
- # "Panama",
881
- # "Tophat"
882
- # ]
883
- # }
884
- # EOT
878
+ # source = <<~JSON
879
+ # {
880
+ # "name": "Dave",
881
+ # "age" :40,
882
+ # "hats": [
883
+ # "Cattleman's",
884
+ # "Panama",
885
+ # "Tophat"
886
+ # ]
887
+ # }
888
+ # JSON
885
889
  #
886
890
  # Load a String:
887
891
  # ruby = JSON.load(source)
@@ -907,7 +911,6 @@ module JSON
907
911
  # * Recursively calls `proc(result)`.
908
912
  # * Returns the final result.
909
913
  #
910
- #
911
914
  # Example:
912
915
  # require 'json'
913
916
  #
@@ -971,6 +974,28 @@ module JSON
971
974
  #
972
975
  def self?.load: (string | _JsonReadableIO | _JsonRead source, ?Proc proc, ?json_options options) -> untyped
973
976
 
977
+ # <!--
978
+ # rdoc-file=ext/json/lib/json/common.rb
979
+ # - JSON.load_file(path, opts={}) -> object
980
+ # -->
981
+ # Calls:
982
+ # parse(File.read(path), opts)
983
+ #
984
+ # See method #parse.
985
+ #
986
+ def self?.load_file: (string path, ?json_options opts) -> untyped
987
+
988
+ # <!--
989
+ # rdoc-file=ext/json/lib/json/common.rb
990
+ # - JSON.load_file!(path, opts = {})
991
+ # -->
992
+ # Calls:
993
+ # JSON.parse!(File.read(path, opts))
994
+ #
995
+ # See method #parse!
996
+ #
997
+ def self?.load_file!: (string path, ?json_options opts) -> untyped
998
+
974
999
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
975
1000
  # Sets or returns default options for the JSON.load method. Initially:
976
1001
  # opts = JSON.load_default_options
@@ -1014,17 +1039,17 @@ module JSON
1014
1039
  # \JSON](#module-JSON-label-Parsing+JSON).
1015
1040
  #
1016
1041
  # Parses nested JSON objects:
1017
- # source = <<-EOT
1018
- # {
1019
- # "name": "Dave",
1020
- # "age" :40,
1021
- # "hats": [
1022
- # "Cattleman's",
1023
- # "Panama",
1024
- # "Tophat"
1025
- # ]
1026
- # }
1027
- # EOT
1042
+ # source = <<~JSON
1043
+ # {
1044
+ # "name": "Dave",
1045
+ # "age" :40,
1046
+ # "hats": [
1047
+ # "Cattleman's",
1048
+ # "Panama",
1049
+ # "Tophat"
1050
+ # ]
1051
+ # }
1052
+ # JSON
1028
1053
  # ruby = JSON.parse(source)
1029
1054
  # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1030
1055
  #
@@ -1053,9 +1078,7 @@ module JSON
1053
1078
  def self?.parse!: (string source, ?json_options opts) -> untyped
1054
1079
 
1055
1080
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1056
- # Returns the JSON parser class that is used by JSON. This is either
1057
- # JSON::Ext::Parser or JSON::Pure::Parser:
1058
- # JSON.parser # => JSON::Ext::Parser
1081
+ # Returns the JSON parser class that is used by JSON.
1059
1082
  #
1060
1083
  def self.parser: () -> json_parser
1061
1084
 
@@ -1106,29 +1129,25 @@ module JSON
1106
1129
 
1107
1130
  # <!--
1108
1131
  # rdoc-file=ext/json/lib/json/common.rb
1109
- # - restore(source, proc = nil, options = {})
1132
+ # - restore(source, proc = nil, options = nil)
1110
1133
  # -->
1111
1134
  #
1112
1135
  alias self.restore self.load
1113
1136
 
1114
1137
  # <!--
1115
1138
  # rdoc-file=ext/json/lib/json/common.rb
1116
- # - restore(source, proc = nil, options = {})
1139
+ # - restore(source, proc = nil, options = nil)
1117
1140
  # -->
1118
1141
  #
1119
1142
  alias restore load
1120
1143
 
1121
1144
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1122
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1123
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1124
- # JSON.state # => JSON::Ext::Generator::State
1145
+ # Sets or Returns the JSON generator state class that is used by JSON.
1125
1146
  #
1126
1147
  def self.state: () -> json_state
1127
1148
 
1128
1149
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1129
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1130
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1131
- # JSON.state # => JSON::Ext::Generator::State
1150
+ # Sets or Returns the JSON generator state class that is used by JSON.
1132
1151
  #
1133
1152
  def self.state=: (json_state) -> json_state
1134
1153
 
@@ -1151,9 +1170,6 @@ JSON::PRETTY_STATE_PROTOTYPE: json_state
1151
1170
 
1152
1171
  JSON::SAFE_STATE_PROTOTYPE: json_state
1153
1172
 
1154
- # <!-- rdoc-file=ext/json/lib/json/version.rb -->
1155
- # JSON version
1156
- #
1157
1173
  JSON::VERSION: String
1158
1174
 
1159
1175
  JSON::VERSION_ARRAY: Array[Integer]
@@ -1164,6 +1180,43 @@ JSON::VERSION_MAJOR: Integer
1164
1180
 
1165
1181
  JSON::VERSION_MINOR: Integer
1166
1182
 
1183
+ %a{annotate:rdoc:skip}
1184
+ module Kernel
1185
+ private
1186
+
1187
+ # <!--
1188
+ # rdoc-file=ext/json/lib/json/common.rb
1189
+ # - j(*objs)
1190
+ # -->
1191
+ # Outputs *objs* to STDOUT as JSON strings in the shortest form, that is in one
1192
+ # line.
1193
+ #
1194
+ def j: (*_ToJson) -> nil
1195
+
1196
+ # <!--
1197
+ # rdoc-file=ext/json/lib/json/common.rb
1198
+ # - jj(*objs)
1199
+ # -->
1200
+ # Outputs *objs* to STDOUT as JSON strings in a pretty format, with indentation
1201
+ # and over many lines.
1202
+ #
1203
+ def jj: (*_ToJson) -> nil
1204
+
1205
+ # <!--
1206
+ # rdoc-file=ext/json/lib/json/common.rb
1207
+ # - JSON(object, *args)
1208
+ # -->
1209
+ # If *object* is string-like, parse the string and return the parsed result as a
1210
+ # Ruby data structure. Otherwise, generate a JSON text from the Ruby data
1211
+ # structure object and return it.
1212
+ #
1213
+ # The *opts* argument is passed through to generate/parse respectively. See
1214
+ # generate and parse for their documentation.
1215
+ #
1216
+ def JSON: (string source, ?json_options opts) -> untyped
1217
+ | (_ToJson obj, ?json_options opts) -> String
1218
+ end
1219
+
1167
1220
  %a{annotate:rdoc:skip}
1168
1221
  class Object
1169
1222
  # Converts this object to a string (calling #to_s), converts
@@ -1243,9 +1296,7 @@ class BigDecimal
1243
1296
  # rdoc-file=ext/json/lib/json/add/bigdecimal.rb
1244
1297
  # - json_create(object)
1245
1298
  # -->
1246
- # Import a JSON Marshalled object.
1247
- #
1248
- # method used for JSON marshalling support.
1299
+ # See #as_json.
1249
1300
  #
1250
1301
  def self.json_create: (Hash[String, String] object) -> instance
1251
1302
 
@@ -1253,9 +1304,23 @@ class BigDecimal
1253
1304
  # rdoc-file=ext/json/lib/json/add/bigdecimal.rb
1254
1305
  # - as_json(*)
1255
1306
  # -->
1256
- # Marshal the object to JSON.
1307
+ # Methods `BigDecimal#as_json` and `BigDecimal.json_create` may be used to
1308
+ # serialize and deserialize a BigDecimal object; see
1309
+ # [Marshal](rdoc-ref:Marshal).
1310
+ #
1311
+ # Method `BigDecimal#as_json` serializes `self`, returning a 2-element hash
1312
+ # representing `self`:
1257
1313
  #
1258
- # method used for JSON marshalling support.
1314
+ # require 'json/add/bigdecimal'
1315
+ # x = BigDecimal(2).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
1316
+ # y = BigDecimal(2.0, 4).as_json # => {"json_class"=>"BigDecimal", "b"=>"36:0.2e1"}
1317
+ # z = BigDecimal(Complex(2, 0)).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
1318
+ #
1319
+ # Method `JSON.create` deserializes such a hash, returning a BigDecimal object:
1320
+ #
1321
+ # BigDecimal.json_create(x) # => 0.2e1
1322
+ # BigDecimal.json_create(y) # => 0.2e1
1323
+ # BigDecimal.json_create(z) # => 0.2e1
1259
1324
  #
1260
1325
  def as_json: (*untyped) -> Hash[String, String]
1261
1326
 
@@ -1263,7 +1328,18 @@ class BigDecimal
1263
1328
  # rdoc-file=ext/json/lib/json/add/bigdecimal.rb
1264
1329
  # - to_json(*args)
1265
1330
  # -->
1266
- # return the JSON value
1331
+ # Returns a JSON string representing `self`:
1332
+ #
1333
+ # require 'json/add/bigdecimal'
1334
+ # puts BigDecimal(2).to_json
1335
+ # puts BigDecimal(2.0, 4).to_json
1336
+ # puts BigDecimal(Complex(2, 0)).to_json
1337
+ #
1338
+ # Output:
1339
+ #
1340
+ # {"json_class":"BigDecimal","b":"27:0.2e1"}
1341
+ # {"json_class":"BigDecimal","b":"36:0.2e1"}
1342
+ # {"json_class":"BigDecimal","b":"27:0.2e1"}
1267
1343
  #
1268
1344
  def to_json: (?JSON::State state) -> String
1269
1345
  end
@@ -1274,8 +1350,7 @@ class Complex
1274
1350
  # rdoc-file=ext/json/lib/json/add/complex.rb
1275
1351
  # - json_create(object)
1276
1352
  # -->
1277
- # Deserializes JSON string by converting Real value `r`, imaginary value `i`, to
1278
- # a Complex object.
1353
+ # See #as_json.
1279
1354
  #
1280
1355
  def self.json_create: (Hash[String, String | Numeric] object) -> instance
1281
1356
 
@@ -1283,8 +1358,20 @@ class Complex
1283
1358
  # rdoc-file=ext/json/lib/json/add/complex.rb
1284
1359
  # - as_json(*)
1285
1360
  # -->
1286
- # Returns a hash, that will be turned into a JSON object and represent this
1287
- # object.
1361
+ # Methods `Complex#as_json` and `Complex.json_create` may be used to serialize
1362
+ # and deserialize a Complex object; see [Marshal](rdoc-ref:Marshal).
1363
+ #
1364
+ # Method `Complex#as_json` serializes `self`, returning a 2-element hash
1365
+ # representing `self`:
1366
+ #
1367
+ # require 'json/add/complex'
1368
+ # x = Complex(2).as_json # => {"json_class"=>"Complex", "r"=>2, "i"=>0}
1369
+ # y = Complex(2.0, 4).as_json # => {"json_class"=>"Complex", "r"=>2.0, "i"=>4}
1370
+ #
1371
+ # Method `JSON.create` deserializes such a hash, returning a Complex object:
1372
+ #
1373
+ # Complex.json_create(x) # => (2+0i)
1374
+ # Complex.json_create(y) # => (2.0+4i)
1288
1375
  #
1289
1376
  def as_json: (*untyped) -> Hash[String, String | Numeric]
1290
1377
 
@@ -1292,8 +1379,16 @@ class Complex
1292
1379
  # rdoc-file=ext/json/lib/json/add/complex.rb
1293
1380
  # - to_json(*args)
1294
1381
  # -->
1295
- # Stores class name (Complex) along with real value `r` and imaginary value `i`
1296
- # as JSON string
1382
+ # Returns a JSON string representing `self`:
1383
+ #
1384
+ # require 'json/add/complex'
1385
+ # puts Complex(2).to_json
1386
+ # puts Complex(2.0, 4).to_json
1387
+ #
1388
+ # Output:
1389
+ #
1390
+ # {"json_class":"Complex","r":2,"i":0}
1391
+ # {"json_class":"Complex","r":2.0,"i":4}
1297
1392
  #
1298
1393
  def to_json: (?JSON::State state) -> String
1299
1394
  end
@@ -1304,8 +1399,7 @@ class Date
1304
1399
  # rdoc-file=ext/json/lib/json/add/date.rb
1305
1400
  # - json_create(object)
1306
1401
  # -->
1307
- # Deserializes JSON string by converting Julian year `y`, month `m`, day `d` and
1308
- # Day of Calendar Reform `sg` to Date.
1402
+ # See #as_json.
1309
1403
  #
1310
1404
  def self.json_create: (Hash[String, String | Integer | Float] object) -> instance
1311
1405
 
@@ -1313,8 +1407,20 @@ class Date
1313
1407
  # rdoc-file=ext/json/lib/json/add/date.rb
1314
1408
  # - as_json(*)
1315
1409
  # -->
1316
- # Returns a hash, that will be turned into a JSON object and represent this
1317
- # object.
1410
+ # Methods `Date#as_json` and `Date.json_create` may be used to serialize and
1411
+ # deserialize a Date object; see [Marshal](rdoc-ref:Marshal).
1412
+ #
1413
+ # Method `Date#as_json` serializes `self`, returning a 2-element hash
1414
+ # representing `self`:
1415
+ #
1416
+ # require 'json/add/date'
1417
+ # x = Date.today.as_json
1418
+ # # => {"json_class"=>"Date", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
1419
+ #
1420
+ # Method `JSON.create` deserializes such a hash, returning a Date object:
1421
+ #
1422
+ # Date.json_create(x)
1423
+ # # => #<Date: 2023-11-21 ((2460270j,0s,0n),+0s,2299161j)>
1318
1424
  #
1319
1425
  def as_json: (*untyped) -> Hash[String, String | Integer | Float]
1320
1426
 
@@ -1322,8 +1428,14 @@ class Date
1322
1428
  # rdoc-file=ext/json/lib/json/add/date.rb
1323
1429
  # - to_json(*args)
1324
1430
  # -->
1325
- # Stores class name (Date) with Julian year `y`, month `m`, day `d` and Day of
1326
- # Calendar Reform `sg` as JSON string
1431
+ # Returns a JSON string representing `self`:
1432
+ #
1433
+ # require 'json/add/date'
1434
+ # puts Date.today.to_json
1435
+ #
1436
+ # Output:
1437
+ #
1438
+ # {"json_class":"Date","y":2023,"m":11,"d":21,"sg":2299161.0}
1327
1439
  #
1328
1440
  def to_json: (?JSON::State state) -> String
1329
1441
  end
@@ -1334,9 +1446,7 @@ class DateTime
1334
1446
  # rdoc-file=ext/json/lib/json/add/date_time.rb
1335
1447
  # - json_create(object)
1336
1448
  # -->
1337
- # Deserializes JSON string by converting year `y`, month `m`, day `d`, hour `H`,
1338
- # minute `M`, second `S`, offset `of` and Day of Calendar Reform `sg` to
1339
- # DateTime.
1449
+ # See #as_json.
1340
1450
  #
1341
1451
  def self.json_create: (Hash[String, String | Integer | Float] object) -> instance
1342
1452
 
@@ -1344,8 +1454,19 @@ class DateTime
1344
1454
  # rdoc-file=ext/json/lib/json/add/date_time.rb
1345
1455
  # - as_json(*)
1346
1456
  # -->
1347
- # Returns a hash, that will be turned into a JSON object and represent this
1348
- # object.
1457
+ # Methods `DateTime#as_json` and `DateTime.json_create` may be used to serialize
1458
+ # and deserialize a DateTime object; see [Marshal](rdoc-ref:Marshal).
1459
+ #
1460
+ # Method `DateTime#as_json` serializes `self`, returning a 2-element hash
1461
+ # representing `self`:
1462
+ #
1463
+ # require 'json/add/datetime'
1464
+ # x = DateTime.now.as_json
1465
+ # # => {"json_class"=>"DateTime", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
1466
+ #
1467
+ # Method `JSON.create` deserializes such a hash, returning a DateTime object:
1468
+ #
1469
+ # DateTime.json_create(x) # BUG? Raises Date::Error "invalid date"
1349
1470
  #
1350
1471
  def as_json: (*untyped) -> Hash[String, String | Integer | Float]
1351
1472
 
@@ -1353,9 +1474,14 @@ class DateTime
1353
1474
  # rdoc-file=ext/json/lib/json/add/date_time.rb
1354
1475
  # - to_json(*args)
1355
1476
  # -->
1356
- # Stores class name (DateTime) with Julian year `y`, month `m`, day `d`, hour
1357
- # `H`, minute `M`, second `S`, offset `of` and Day of Calendar Reform `sg` as
1358
- # JSON string
1477
+ # Returns a JSON string representing `self`:
1478
+ #
1479
+ # require 'json/add/datetime'
1480
+ # puts DateTime.now.to_json
1481
+ #
1482
+ # Output:
1483
+ #
1484
+ # {"json_class":"DateTime","y":2023,"m":11,"d":21,"sg":2299161.0}
1359
1485
  #
1360
1486
  def to_json: (?JSON::State state) -> String
1361
1487
  end
@@ -1366,8 +1492,7 @@ class Exception
1366
1492
  # rdoc-file=ext/json/lib/json/add/exception.rb
1367
1493
  # - json_create(object)
1368
1494
  # -->
1369
- # Deserializes JSON string by constructing new Exception object with message `m`
1370
- # and backtrace `b` serialized with `to_json`
1495
+ # See #as_json.
1371
1496
  #
1372
1497
  def self.json_create: (Hash[String, String | Array[String] | nil] object) -> instance
1373
1498
 
@@ -1375,8 +1500,18 @@ class Exception
1375
1500
  # rdoc-file=ext/json/lib/json/add/exception.rb
1376
1501
  # - as_json(*)
1377
1502
  # -->
1378
- # Returns a hash, that will be turned into a JSON object and represent this
1379
- # object.
1503
+ # Methods `Exception#as_json` and `Exception.json_create` may be used to
1504
+ # serialize and deserialize a Exception object; see [Marshal](rdoc-ref:Marshal).
1505
+ #
1506
+ # Method `Exception#as_json` serializes `self`, returning a 2-element hash
1507
+ # representing `self`:
1508
+ #
1509
+ # require 'json/add/exception'
1510
+ # x = Exception.new('Foo').as_json # => {"json_class"=>"Exception", "m"=>"Foo", "b"=>nil}
1511
+ #
1512
+ # Method `JSON.create` deserializes such a hash, returning a Exception object:
1513
+ #
1514
+ # Exception.json_create(x) # => #<Exception: Foo>
1380
1515
  #
1381
1516
  def as_json: (*untyped) -> Hash[String, String | Array[String] | nil]
1382
1517
 
@@ -1384,8 +1519,14 @@ class Exception
1384
1519
  # rdoc-file=ext/json/lib/json/add/exception.rb
1385
1520
  # - to_json(*args)
1386
1521
  # -->
1387
- # Stores class name (Exception) with message `m` and backtrace array `b` as JSON
1388
- # string
1522
+ # Returns a JSON string representing `self`:
1523
+ #
1524
+ # require 'json/add/exception'
1525
+ # puts Exception.new('Foo').to_json
1526
+ #
1527
+ # Output:
1528
+ #
1529
+ # {"json_class":"Exception","m":"Foo","b":null}
1389
1530
  #
1390
1531
  def to_json: (?JSON::State state) -> String
1391
1532
  end
@@ -1396,8 +1537,7 @@ class OpenStruct
1396
1537
  # rdoc-file=ext/json/lib/json/add/ostruct.rb
1397
1538
  # - json_create(object)
1398
1539
  # -->
1399
- # Deserializes JSON string by constructing new Struct object with values `t`
1400
- # serialized by `to_json`.
1540
+ # See #as_json.
1401
1541
  #
1402
1542
  def self.json_create: (Hash[String, String | Hash[Symbol, untyped]] object) -> instance
1403
1543
 
@@ -1405,8 +1545,21 @@ class OpenStruct
1405
1545
  # rdoc-file=ext/json/lib/json/add/ostruct.rb
1406
1546
  # - as_json(*)
1407
1547
  # -->
1408
- # Returns a hash, that will be turned into a JSON object and represent this
1409
- # object.
1548
+ # Methods `OpenStruct#as_json` and `OpenStruct.json_create` may be used to
1549
+ # serialize and deserialize a OpenStruct object; see
1550
+ # [Marshal](rdoc-ref:Marshal).
1551
+ #
1552
+ # Method `OpenStruct#as_json` serializes `self`, returning a 2-element hash
1553
+ # representing `self`:
1554
+ #
1555
+ # require 'json/add/ostruct'
1556
+ # x = OpenStruct.new('name' => 'Rowdy', :age => nil).as_json
1557
+ # # => {"json_class"=>"OpenStruct", "t"=>{:name=>'Rowdy', :age=>nil}}
1558
+ #
1559
+ # Method `JSON.create` deserializes such a hash, returning a OpenStruct object:
1560
+ #
1561
+ # OpenStruct.json_create(x)
1562
+ # # => #<OpenStruct name='Rowdy', age=nil>
1410
1563
  #
1411
1564
  def as_json: (*untyped) -> Hash[String, String | Hash[Symbol, untyped]]
1412
1565
 
@@ -1414,7 +1567,14 @@ class OpenStruct
1414
1567
  # rdoc-file=ext/json/lib/json/add/ostruct.rb
1415
1568
  # - to_json(*args)
1416
1569
  # -->
1417
- # Stores class name (OpenStruct) with this struct's values `t` as a JSON string.
1570
+ # Returns a JSON string representing `self`:
1571
+ #
1572
+ # require 'json/add/ostruct'
1573
+ # puts OpenStruct.new('name' => 'Rowdy', :age => nil).to_json
1574
+ #
1575
+ # Output:
1576
+ #
1577
+ # {"json_class":"OpenStruct","t":{'name':'Rowdy',"age":null}}
1418
1578
  #
1419
1579
  def to_json: (?JSON::State state) -> String
1420
1580
  end
@@ -1425,8 +1585,7 @@ class Range[out Elem]
1425
1585
  # rdoc-file=ext/json/lib/json/add/range.rb
1426
1586
  # - json_create(object)
1427
1587
  # -->
1428
- # Deserializes JSON string by constructing new Range object with arguments `a`
1429
- # serialized by `to_json`.
1588
+ # See #as_json.
1430
1589
  #
1431
1590
  def self.json_create: [A] (Hash[String, String | [ A, A, bool ]] object) -> Range[A]
1432
1591
 
@@ -1434,8 +1593,22 @@ class Range[out Elem]
1434
1593
  # rdoc-file=ext/json/lib/json/add/range.rb
1435
1594
  # - as_json(*)
1436
1595
  # -->
1437
- # Returns a hash, that will be turned into a JSON object and represent this
1438
- # object.
1596
+ # Methods `Range#as_json` and `Range.json_create` may be used to serialize and
1597
+ # deserialize a Range object; see [Marshal](rdoc-ref:Marshal).
1598
+ #
1599
+ # Method `Range#as_json` serializes `self`, returning a 2-element hash
1600
+ # representing `self`:
1601
+ #
1602
+ # require 'json/add/range'
1603
+ # x = (1..4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, false]}
1604
+ # y = (1...4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, true]}
1605
+ # z = ('a'..'d').as_json # => {"json_class"=>"Range", "a"=>["a", "d", false]}
1606
+ #
1607
+ # Method `JSON.create` deserializes such a hash, returning a Range object:
1608
+ #
1609
+ # Range.json_create(x) # => 1..4
1610
+ # Range.json_create(y) # => 1...4
1611
+ # Range.json_create(z) # => "a".."d"
1439
1612
  #
1440
1613
  def as_json: (*untyped) -> Hash[String, String | [ Elem, Elem, bool ]]
1441
1614
 
@@ -1443,9 +1616,18 @@ class Range[out Elem]
1443
1616
  # rdoc-file=ext/json/lib/json/add/range.rb
1444
1617
  # - to_json(*args)
1445
1618
  # -->
1446
- # Stores class name (Range) with JSON array of arguments `a` which include
1447
- # `first` (integer), `last` (integer), and `exclude_end?` (boolean) as JSON
1448
- # string.
1619
+ # Returns a JSON string representing `self`:
1620
+ #
1621
+ # require 'json/add/range'
1622
+ # puts (1..4).to_json
1623
+ # puts (1...4).to_json
1624
+ # puts ('a'..'d').to_json
1625
+ #
1626
+ # Output:
1627
+ #
1628
+ # {"json_class":"Range","a":[1,4,false]}
1629
+ # {"json_class":"Range","a":[1,4,true]}
1630
+ # {"json_class":"Range","a":["a","d",false]}
1449
1631
  #
1450
1632
  def to_json: (?JSON::State state) -> String
1451
1633
  end
@@ -1456,8 +1638,7 @@ class Rational
1456
1638
  # rdoc-file=ext/json/lib/json/add/rational.rb
1457
1639
  # - json_create(object)
1458
1640
  # -->
1459
- # Deserializes JSON string by converting numerator value `n`, denominator value
1460
- # `d`, to a Rational object.
1641
+ # See #as_json.
1461
1642
  #
1462
1643
  def self.json_create: (Hash[String, String | Integer] object) -> instance
1463
1644
 
@@ -1465,8 +1646,20 @@ class Rational
1465
1646
  # rdoc-file=ext/json/lib/json/add/rational.rb
1466
1647
  # - as_json(*)
1467
1648
  # -->
1468
- # Returns a hash, that will be turned into a JSON object and represent this
1469
- # object.
1649
+ # Methods `Rational#as_json` and `Rational.json_create` may be used to serialize
1650
+ # and deserialize a Rational object; see [Marshal](rdoc-ref:Marshal).
1651
+ #
1652
+ # Method `Rational#as_json` serializes `self`, returning a 2-element hash
1653
+ # representing `self`:
1654
+ #
1655
+ # require 'json/add/rational'
1656
+ # x = Rational(2, 3).as_json
1657
+ # # => {"json_class"=>"Rational", "n"=>2, "d"=>3}
1658
+ #
1659
+ # Method `JSON.create` deserializes such a hash, returning a Rational object:
1660
+ #
1661
+ # Rational.json_create(x)
1662
+ # # => (2/3)
1470
1663
  #
1471
1664
  def as_json: (*untyped) -> Hash[String, String | Integer]
1472
1665
 
@@ -1474,8 +1667,14 @@ class Rational
1474
1667
  # rdoc-file=ext/json/lib/json/add/rational.rb
1475
1668
  # - to_json(*args)
1476
1669
  # -->
1477
- # Stores class name (Rational) along with numerator value `n` and denominator
1478
- # value `d` as JSON string
1670
+ # Returns a JSON string representing `self`:
1671
+ #
1672
+ # require 'json/add/rational'
1673
+ # puts Rational(2, 3).to_json
1674
+ #
1675
+ # Output:
1676
+ #
1677
+ # {"json_class":"Rational","n":2,"d":3}
1479
1678
  #
1480
1679
  def to_json: (?JSON::State state) -> String
1481
1680
  end
@@ -1486,8 +1685,7 @@ class Regexp
1486
1685
  # rdoc-file=ext/json/lib/json/add/regexp.rb
1487
1686
  # - json_create(object)
1488
1687
  # -->
1489
- # Deserializes JSON string by constructing new Regexp object with source `s`
1490
- # (Regexp or String) and options `o` serialized by `to_json`
1688
+ # See #as_json.
1491
1689
  #
1492
1690
  def self.json_create: (Hash[String, String | Integer] object) -> instance
1493
1691
 
@@ -1495,8 +1693,19 @@ class Regexp
1495
1693
  # rdoc-file=ext/json/lib/json/add/regexp.rb
1496
1694
  # - as_json(*)
1497
1695
  # -->
1498
- # Returns a hash, that will be turned into a JSON object and represent this
1499
- # object.
1696
+ # Methods `Regexp#as_json` and `Regexp.json_create` may be used to serialize and
1697
+ # deserialize a Regexp object; see [Marshal](rdoc-ref:Marshal).
1698
+ #
1699
+ # Method `Regexp#as_json` serializes `self`, returning a 2-element hash
1700
+ # representing `self`:
1701
+ #
1702
+ # require 'json/add/regexp'
1703
+ # x = /foo/.as_json
1704
+ # # => {"json_class"=>"Regexp", "o"=>0, "s"=>"foo"}
1705
+ #
1706
+ # Method `JSON.create` deserializes such a hash, returning a Regexp object:
1707
+ #
1708
+ # Regexp.json_create(x) # => /foo/
1500
1709
  #
1501
1710
  def as_json: (*untyped) -> Hash[String, String | Integer]
1502
1711
 
@@ -1504,8 +1713,14 @@ class Regexp
1504
1713
  # rdoc-file=ext/json/lib/json/add/regexp.rb
1505
1714
  # - to_json(*args)
1506
1715
  # -->
1507
- # Stores class name (Regexp) with options `o` and source `s` (Regexp or String)
1508
- # as JSON string
1716
+ # Returns a JSON string representing `self`:
1717
+ #
1718
+ # require 'json/add/regexp'
1719
+ # puts /foo/.to_json
1720
+ #
1721
+ # Output:
1722
+ #
1723
+ # {"json_class":"Regexp","o":0,"s":"foo"}
1509
1724
  #
1510
1725
  def to_json: (?JSON::State state) -> String
1511
1726
  end
@@ -1516,9 +1731,7 @@ class Set[unchecked out A]
1516
1731
  # rdoc-file=ext/json/lib/json/add/set.rb
1517
1732
  # - json_create(object)
1518
1733
  # -->
1519
- # Import a JSON Marshalled object.
1520
- #
1521
- # method used for JSON marshalling support.
1734
+ # See #as_json.
1522
1735
  #
1523
1736
  def self.json_create: [A] (Hash[String, String | Array[A]] object) -> Set[A]
1524
1737
 
@@ -1526,9 +1739,19 @@ class Set[unchecked out A]
1526
1739
  # rdoc-file=ext/json/lib/json/add/set.rb
1527
1740
  # - as_json(*)
1528
1741
  # -->
1529
- # Marshal the object to JSON.
1742
+ # Methods `Set#as_json` and `Set.json_create` may be used to serialize and
1743
+ # deserialize a Set object; see [Marshal](rdoc-ref:Marshal).
1744
+ #
1745
+ # Method `Set#as_json` serializes `self`, returning a 2-element hash
1746
+ # representing `self`:
1530
1747
  #
1531
- # method used for JSON marshalling support.
1748
+ # require 'json/add/set'
1749
+ # x = Set.new(%w/foo bar baz/).as_json
1750
+ # # => {"json_class"=>"Set", "a"=>["foo", "bar", "baz"]}
1751
+ #
1752
+ # Method `JSON.create` deserializes such a hash, returning a Set object:
1753
+ #
1754
+ # Set.json_create(x) # => #<Set: {"foo", "bar", "baz"}>
1532
1755
  #
1533
1756
  def as_json: (*untyped) -> Hash[String, String | Array[A]]
1534
1757
 
@@ -1536,7 +1759,14 @@ class Set[unchecked out A]
1536
1759
  # rdoc-file=ext/json/lib/json/add/set.rb
1537
1760
  # - to_json(*args)
1538
1761
  # -->
1539
- # return the JSON value
1762
+ # Returns a JSON string representing `self`:
1763
+ #
1764
+ # require 'json/add/set'
1765
+ # puts Set.new(%w/foo bar baz/).to_json
1766
+ #
1767
+ # Output:
1768
+ #
1769
+ # {"json_class":"Set","a":["foo","bar","baz"]}
1540
1770
  #
1541
1771
  def to_json: (?JSON::State state) -> String
1542
1772
  end
@@ -1547,8 +1777,7 @@ class Struct[Elem]
1547
1777
  # rdoc-file=ext/json/lib/json/add/struct.rb
1548
1778
  # - json_create(object)
1549
1779
  # -->
1550
- # Deserializes JSON string by constructing new Struct object with values `v`
1551
- # serialized by `to_json`.
1780
+ # See #as_json.
1552
1781
  #
1553
1782
  def self.json_create: [Elem] (Hash[String, String | Array[Elem]] object) -> Struct[Elem]
1554
1783
 
@@ -1556,8 +1785,21 @@ class Struct[Elem]
1556
1785
  # rdoc-file=ext/json/lib/json/add/struct.rb
1557
1786
  # - as_json(*)
1558
1787
  # -->
1559
- # Returns a hash, that will be turned into a JSON object and represent this
1560
- # object.
1788
+ # Methods `Struct#as_json` and `Struct.json_create` may be used to serialize and
1789
+ # deserialize a Struct object; see [Marshal](rdoc-ref:Marshal).
1790
+ #
1791
+ # Method `Struct#as_json` serializes `self`, returning a 2-element hash
1792
+ # representing `self`:
1793
+ #
1794
+ # require 'json/add/struct'
1795
+ # Customer = Struct.new('Customer', :name, :address, :zip)
1796
+ # x = Struct::Customer.new.as_json
1797
+ # # => {"json_class"=>"Struct::Customer", "v"=>[nil, nil, nil]}
1798
+ #
1799
+ # Method `JSON.create` deserializes such a hash, returning a Struct object:
1800
+ #
1801
+ # Struct::Customer.json_create(x)
1802
+ # # => #<struct Struct::Customer name=nil, address=nil, zip=nil>
1561
1803
  #
1562
1804
  def as_json: (*untyped) -> Hash[String, String | Array[Elem]]
1563
1805
 
@@ -1565,8 +1807,15 @@ class Struct[Elem]
1565
1807
  # rdoc-file=ext/json/lib/json/add/struct.rb
1566
1808
  # - to_json(*args)
1567
1809
  # -->
1568
- # Stores class name (Struct) with Struct values `v` as a JSON string. Only named
1569
- # structs are supported.
1810
+ # Returns a JSON string representing `self`:
1811
+ #
1812
+ # require 'json/add/struct'
1813
+ # Customer = Struct.new('Customer', :name, :address, :zip)
1814
+ # puts Struct::Customer.new.to_json
1815
+ #
1816
+ # Output:
1817
+ #
1818
+ # {"json_class":"Struct","t":{'name':'Rowdy',"age":null}}
1570
1819
  #
1571
1820
  def to_json: (?JSON::State state) -> String
1572
1821
  end
@@ -1577,8 +1826,7 @@ class Symbol
1577
1826
  # rdoc-file=ext/json/lib/json/add/symbol.rb
1578
1827
  # - json_create(o)
1579
1828
  # -->
1580
- # Deserializes JSON string by converting the `string` value stored in the object
1581
- # to a Symbol
1829
+ # See #as_json.
1582
1830
  #
1583
1831
  def self.json_create: (Hash[String, String] object) -> instance
1584
1832
 
@@ -1586,8 +1834,19 @@ class Symbol
1586
1834
  # rdoc-file=ext/json/lib/json/add/symbol.rb
1587
1835
  # - as_json(*)
1588
1836
  # -->
1589
- # Returns a hash, that will be turned into a JSON object and represent this
1590
- # object.
1837
+ # Methods `Symbol#as_json` and `Symbol.json_create` may be used to serialize and
1838
+ # deserialize a Symbol object; see [Marshal](rdoc-ref:Marshal).
1839
+ #
1840
+ # Method `Symbol#as_json` serializes `self`, returning a 2-element hash
1841
+ # representing `self`:
1842
+ #
1843
+ # require 'json/add/symbol'
1844
+ # x = :foo.as_json
1845
+ # # => {"json_class"=>"Symbol", "s"=>"foo"}
1846
+ #
1847
+ # Method `JSON.create` deserializes such a hash, returning a Symbol object:
1848
+ #
1849
+ # Symbol.json_create(x) # => :foo
1591
1850
  #
1592
1851
  def as_json: (*untyped) -> Hash[String, String]
1593
1852
 
@@ -1595,8 +1854,14 @@ class Symbol
1595
1854
  # rdoc-file=ext/json/lib/json/add/symbol.rb
1596
1855
  # - to_json(*a)
1597
1856
  # -->
1598
- # Stores class name (Symbol) with String representation of Symbol as a JSON
1599
- # string.
1857
+ # Returns a JSON string representing `self`:
1858
+ #
1859
+ # require 'json/add/symbol'
1860
+ # puts :foo.to_json
1861
+ #
1862
+ # Output:
1863
+ #
1864
+ # # {"json_class":"Symbol","s":"foo"}
1600
1865
  #
1601
1866
  def to_json: (?JSON::State state) -> String
1602
1867
  end
@@ -1607,7 +1872,7 @@ class Time
1607
1872
  # rdoc-file=ext/json/lib/json/add/time.rb
1608
1873
  # - json_create(object)
1609
1874
  # -->
1610
- # Deserializes JSON string by converting time since epoch to Time
1875
+ # See #as_json.
1611
1876
  #
1612
1877
  def self.json_create: (Hash[String, String | Integer] object) -> instance
1613
1878
 
@@ -1615,8 +1880,20 @@ class Time
1615
1880
  # rdoc-file=ext/json/lib/json/add/time.rb
1616
1881
  # - as_json(*)
1617
1882
  # -->
1618
- # Returns a hash, that will be turned into a JSON object and represent this
1619
- # object.
1883
+ # Methods `Time#as_json` and `Time.json_create` may be used to serialize and
1884
+ # deserialize a Time object; see [Marshal](rdoc-ref:Marshal).
1885
+ #
1886
+ # Method `Time#as_json` serializes `self`, returning a 2-element hash
1887
+ # representing `self`:
1888
+ #
1889
+ # require 'json/add/time'
1890
+ # x = Time.now.as_json
1891
+ # # => {"json_class"=>"Time", "s"=>1700931656, "n"=>472846644}
1892
+ #
1893
+ # Method `JSON.create` deserializes such a hash, returning a Time object:
1894
+ #
1895
+ # Time.json_create(x)
1896
+ # # => 2023-11-25 11:00:56.472846644 -0600
1620
1897
  #
1621
1898
  def as_json: (*untyped) -> Hash[String, String | Integer]
1622
1899
 
@@ -1624,8 +1901,14 @@ class Time
1624
1901
  # rdoc-file=ext/json/lib/json/add/time.rb
1625
1902
  # - to_json(*args)
1626
1903
  # -->
1627
- # Stores class name (Time) with number of seconds since epoch and number of
1628
- # microseconds for Time as JSON string
1904
+ # Returns a JSON string representing `self`:
1905
+ #
1906
+ # require 'json/add/time'
1907
+ # puts Time.now.to_json
1908
+ #
1909
+ # Output:
1910
+ #
1911
+ # {"json_class":"Time","s":1700931678,"n":980650786}
1629
1912
  #
1630
1913
  def to_json: (?JSON::State state) -> String
1631
1914
  end