rbs 4.0.0.dev.4 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +18 -11
  5. data/.github/workflows/comments.yml +5 -3
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/ruby.yml +27 -34
  8. data/.github/workflows/rust.yml +95 -0
  9. data/.github/workflows/typecheck.yml +2 -2
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/CHANGELOG.md +323 -0
  13. data/README.md +1 -1
  14. data/Rakefile +43 -33
  15. data/Steepfile +1 -0
  16. data/config.yml +426 -24
  17. data/core/array.rbs +307 -227
  18. data/core/basic_object.rbs +9 -8
  19. data/core/binding.rbs +0 -2
  20. data/core/builtin.rbs +2 -2
  21. data/core/class.rbs +6 -5
  22. data/core/comparable.rbs +55 -34
  23. data/core/complex.rbs +104 -78
  24. data/core/dir.rbs +61 -49
  25. data/core/encoding.rbs +12 -15
  26. data/core/enumerable.rbs +179 -87
  27. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  28. data/core/enumerator.rbs +65 -2
  29. data/core/errno.rbs +11 -2
  30. data/core/errors.rbs +58 -29
  31. data/core/exception.rbs +13 -13
  32. data/core/fiber.rbs +74 -54
  33. data/core/file.rbs +280 -177
  34. data/core/file_test.rbs +3 -3
  35. data/core/float.rbs +257 -92
  36. data/core/gc.rbs +425 -281
  37. data/core/hash.rbs +1045 -739
  38. data/core/integer.rbs +135 -137
  39. data/core/io/buffer.rbs +53 -42
  40. data/core/io/wait.rbs +13 -35
  41. data/core/io.rbs +192 -144
  42. data/core/kernel.rbs +216 -155
  43. data/core/marshal.rbs +4 -4
  44. data/core/match_data.rbs +15 -13
  45. data/core/math.rbs +107 -66
  46. data/core/method.rbs +69 -33
  47. data/core/module.rbs +244 -106
  48. data/core/nil_class.rbs +7 -6
  49. data/core/numeric.rbs +74 -63
  50. data/core/object.rbs +9 -11
  51. data/core/object_space.rbs +30 -23
  52. data/core/pathname.rbs +1322 -0
  53. data/core/proc.rbs +95 -58
  54. data/core/process.rbs +222 -202
  55. data/core/ractor.rbs +371 -515
  56. data/core/random.rbs +21 -3
  57. data/core/range.rbs +159 -57
  58. data/core/rational.rbs +60 -89
  59. data/core/rbs/unnamed/argf.rbs +60 -53
  60. data/core/rbs/unnamed/env_class.rbs +19 -14
  61. data/core/rbs/unnamed/main_class.rbs +123 -0
  62. data/core/rbs/unnamed/random.rbs +11 -118
  63. data/core/regexp.rbs +258 -214
  64. data/core/ruby.rbs +53 -0
  65. data/core/ruby_vm.rbs +38 -34
  66. data/core/rubygems/config_file.rbs +5 -5
  67. data/core/rubygems/errors.rbs +4 -71
  68. data/core/rubygems/requirement.rbs +5 -5
  69. data/core/rubygems/rubygems.rbs +16 -82
  70. data/core/rubygems/version.rbs +2 -3
  71. data/core/set.rbs +490 -360
  72. data/core/signal.rbs +26 -16
  73. data/core/string.rbs +3234 -1285
  74. data/core/struct.rbs +27 -26
  75. data/core/symbol.rbs +41 -34
  76. data/core/thread.rbs +135 -67
  77. data/core/time.rbs +81 -50
  78. data/core/trace_point.rbs +41 -35
  79. data/core/true_class.rbs +2 -2
  80. data/core/unbound_method.rbs +24 -16
  81. data/core/warning.rbs +7 -7
  82. data/docs/aliases.md +79 -0
  83. data/docs/collection.md +3 -3
  84. data/docs/config.md +171 -0
  85. data/docs/encoding.md +56 -0
  86. data/docs/gem.md +0 -1
  87. data/docs/inline.md +576 -0
  88. data/docs/sigs.md +3 -3
  89. data/docs/syntax.md +46 -16
  90. data/docs/type_fingerprint.md +21 -0
  91. data/exe/rbs +1 -1
  92. data/ext/rbs_extension/ast_translation.c +544 -116
  93. data/ext/rbs_extension/ast_translation.h +3 -0
  94. data/ext/rbs_extension/class_constants.c +16 -2
  95. data/ext/rbs_extension/class_constants.h +8 -0
  96. data/ext/rbs_extension/extconf.rb +5 -1
  97. data/ext/rbs_extension/legacy_location.c +33 -56
  98. data/ext/rbs_extension/legacy_location.h +37 -0
  99. data/ext/rbs_extension/main.c +44 -35
  100. data/include/rbs/ast.h +448 -173
  101. data/include/rbs/defines.h +27 -0
  102. data/include/rbs/lexer.h +30 -11
  103. data/include/rbs/location.h +25 -44
  104. data/include/rbs/parser.h +6 -6
  105. data/include/rbs/string.h +0 -2
  106. data/include/rbs/util/rbs_allocator.h +34 -13
  107. data/include/rbs/util/rbs_assert.h +12 -1
  108. data/include/rbs/util/rbs_constant_pool.h +0 -3
  109. data/include/rbs/util/rbs_encoding.h +2 -0
  110. data/include/rbs/util/rbs_unescape.h +2 -1
  111. data/include/rbs.h +8 -0
  112. data/lib/rbs/ast/annotation.rb +1 -1
  113. data/lib/rbs/ast/comment.rb +1 -1
  114. data/lib/rbs/ast/declarations.rb +10 -10
  115. data/lib/rbs/ast/members.rb +14 -14
  116. data/lib/rbs/ast/ruby/annotations.rb +293 -3
  117. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  118. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  119. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  120. data/lib/rbs/ast/ruby/members.rb +532 -22
  121. data/lib/rbs/ast/type_param.rb +24 -4
  122. data/lib/rbs/buffer.rb +20 -15
  123. data/lib/rbs/cli/diff.rb +16 -15
  124. data/lib/rbs/cli/validate.rb +38 -106
  125. data/lib/rbs/cli.rb +52 -19
  126. data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
  127. data/lib/rbs/collection/sources/git.rb +1 -0
  128. data/lib/rbs/definition.rb +1 -1
  129. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  130. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  131. data/lib/rbs/definition_builder.rb +147 -25
  132. data/lib/rbs/diff.rb +7 -1
  133. data/lib/rbs/environment.rb +227 -74
  134. data/lib/rbs/environment_loader.rb +0 -6
  135. data/lib/rbs/errors.rb +27 -18
  136. data/lib/rbs/inline_parser.rb +342 -6
  137. data/lib/rbs/location_aux.rb +1 -1
  138. data/lib/rbs/locator.rb +5 -1
  139. data/lib/rbs/method_type.rb +5 -3
  140. data/lib/rbs/parser_aux.rb +20 -7
  141. data/lib/rbs/prototype/helpers.rb +57 -0
  142. data/lib/rbs/prototype/rb.rb +3 -28
  143. data/lib/rbs/prototype/rbi.rb +3 -20
  144. data/lib/rbs/prototype/runtime.rb +8 -0
  145. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  146. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  147. data/lib/rbs/subtractor.rb +3 -1
  148. data/lib/rbs/test/type_check.rb +19 -2
  149. data/lib/rbs/type_name.rb +1 -1
  150. data/lib/rbs/types.rb +88 -78
  151. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  152. data/lib/rbs/validator.rb +2 -2
  153. data/lib/rbs/version.rb +1 -1
  154. data/lib/rbs.rb +1 -2
  155. data/lib/rdoc/discover.rb +1 -1
  156. data/lib/rdoc_plugin/parser.rb +1 -1
  157. data/rbs.gemspec +4 -3
  158. data/rust/.gitignore +1 -0
  159. data/rust/Cargo.lock +378 -0
  160. data/rust/Cargo.toml +7 -0
  161. data/rust/ruby-rbs/Cargo.toml +22 -0
  162. data/rust/ruby-rbs/build.rs +764 -0
  163. data/rust/ruby-rbs/examples/locations.rs +60 -0
  164. data/rust/ruby-rbs/src/lib.rs +1 -0
  165. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  166. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  167. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  168. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  169. data/rust/ruby-rbs-sys/build.rs +204 -0
  170. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  171. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  172. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  173. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  174. data/schema/typeParam.json +17 -1
  175. data/sig/ast/ruby/annotations.rbs +315 -4
  176. data/sig/ast/ruby/comment_block.rbs +8 -0
  177. data/sig/ast/ruby/declarations.rbs +102 -4
  178. data/sig/ast/ruby/members.rbs +108 -2
  179. data/sig/cli/diff.rbs +5 -11
  180. data/sig/cli/validate.rbs +12 -8
  181. data/sig/cli.rbs +18 -18
  182. data/sig/definition.rbs +6 -1
  183. data/sig/definition_builder.rbs +2 -0
  184. data/sig/environment.rbs +70 -12
  185. data/sig/errors.rbs +13 -14
  186. data/sig/inline_parser.rbs +39 -2
  187. data/sig/locator.rbs +0 -2
  188. data/sig/manifest.yaml +0 -1
  189. data/sig/method_builder.rbs +3 -1
  190. data/sig/parser.rbs +31 -13
  191. data/sig/prototype/helpers.rbs +2 -0
  192. data/sig/resolver/type_name_resolver.rbs +35 -7
  193. data/sig/source.rbs +3 -3
  194. data/sig/type_param.rbs +13 -8
  195. data/sig/types.rbs +6 -7
  196. data/sig/unit_test/spy.rbs +0 -8
  197. data/sig/unit_test/type_assertions.rbs +11 -0
  198. data/src/ast.c +410 -153
  199. data/src/lexer.c +1392 -1313
  200. data/src/lexer.re +3 -0
  201. data/src/lexstate.c +58 -37
  202. data/src/location.c +8 -48
  203. data/src/parser.c +977 -516
  204. data/src/string.c +0 -48
  205. data/src/util/rbs_allocator.c +89 -71
  206. data/src/util/rbs_assert.c +1 -1
  207. data/src/util/rbs_buffer.c +2 -2
  208. data/src/util/rbs_constant_pool.c +10 -14
  209. data/src/util/rbs_encoding.c +4 -8
  210. data/src/util/rbs_unescape.c +56 -20
  211. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  212. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  213. data/stdlib/cgi/0/core.rbs +9 -393
  214. data/stdlib/cgi/0/manifest.yaml +1 -0
  215. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  216. data/stdlib/coverage/0/coverage.rbs +7 -4
  217. data/stdlib/date/0/date.rbs +92 -79
  218. data/stdlib/date/0/date_time.rbs +25 -24
  219. data/stdlib/delegate/0/delegator.rbs +10 -7
  220. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  221. data/stdlib/digest/0/digest.rbs +110 -0
  222. data/stdlib/erb/0/erb.rbs +748 -347
  223. data/stdlib/etc/0/etc.rbs +55 -50
  224. data/stdlib/fileutils/0/fileutils.rbs +158 -139
  225. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  226. data/stdlib/io-console/0/io-console.rbs +2 -2
  227. data/stdlib/json/0/json.rbs +217 -136
  228. data/stdlib/monitor/0/monitor.rbs +3 -3
  229. data/stdlib/net-http/0/net-http.rbs +162 -134
  230. data/stdlib/objspace/0/objspace.rbs +17 -34
  231. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  232. data/stdlib/open3/0/open3.rbs +469 -10
  233. data/stdlib/openssl/0/openssl.rbs +475 -357
  234. data/stdlib/optparse/0/optparse.rbs +26 -17
  235. data/stdlib/pathname/0/pathname.rbs +11 -1381
  236. data/stdlib/pp/0/pp.rbs +9 -8
  237. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  238. data/stdlib/pstore/0/pstore.rbs +35 -30
  239. data/stdlib/psych/0/psych.rbs +65 -12
  240. data/stdlib/psych/0/store.rbs +2 -4
  241. data/stdlib/pty/0/pty.rbs +9 -6
  242. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  243. data/stdlib/rdoc/0/code_object.rbs +2 -1
  244. data/stdlib/rdoc/0/parser.rbs +1 -1
  245. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  246. data/stdlib/rdoc/0/store.rbs +1 -1
  247. data/stdlib/resolv/0/resolv.rbs +25 -68
  248. data/stdlib/ripper/0/ripper.rbs +22 -19
  249. data/stdlib/securerandom/0/manifest.yaml +2 -0
  250. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  251. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  252. data/stdlib/singleton/0/singleton.rbs +3 -0
  253. data/stdlib/socket/0/addrinfo.rbs +7 -7
  254. data/stdlib/socket/0/basic_socket.rbs +3 -3
  255. data/stdlib/socket/0/ip_socket.rbs +10 -8
  256. data/stdlib/socket/0/socket.rbs +23 -10
  257. data/stdlib/socket/0/tcp_server.rbs +1 -1
  258. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  259. data/stdlib/socket/0/udp_socket.rbs +1 -1
  260. data/stdlib/socket/0/unix_server.rbs +1 -1
  261. data/stdlib/stringio/0/stringio.rbs +1177 -85
  262. data/stdlib/strscan/0/string_scanner.rbs +27 -25
  263. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  264. data/stdlib/time/0/time.rbs +8 -6
  265. data/stdlib/timeout/0/timeout.rbs +63 -7
  266. data/stdlib/tsort/0/cyclic.rbs +3 -0
  267. data/stdlib/tsort/0/tsort.rbs +7 -6
  268. data/stdlib/uri/0/common.rbs +42 -20
  269. data/stdlib/uri/0/file.rbs +3 -3
  270. data/stdlib/uri/0/generic.rbs +26 -18
  271. data/stdlib/uri/0/http.rbs +2 -2
  272. data/stdlib/uri/0/ldap.rbs +2 -2
  273. data/stdlib/uri/0/mailto.rbs +3 -3
  274. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  275. data/stdlib/zlib/0/deflate.rbs +4 -3
  276. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  277. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  278. data/stdlib/zlib/0/inflate.rbs +1 -1
  279. data/stdlib/zlib/0/need_dict.rbs +1 -1
  280. data/stdlib/zlib/0/zstream.rbs +1 -0
  281. metadata +50 -6
@@ -1,5 +1,5 @@
1
1
  interface _ToJson
2
- def to_json: (?JSON::State state) -> String
2
+ def to_json: (?JSON::State? state) -> String
3
3
  end
4
4
 
5
5
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
@@ -79,8 +79,8 @@ end
79
79
  # JSON is a lightweight data-interchange format.
80
80
  #
81
81
  # A JSON value is one of the following:
82
- # * Double-quoted text: `"foo"`.
83
- # * Number: `1`, `1.0`, `2.0e2`.
82
+ # * Double-quoted text: <code>"foo"</code>.
83
+ # * Number: `1`, <code>1.0</code>, <code>2.0e2</code>.
84
84
  # * Boolean: `true`, `false`.
85
85
  # * Null: `null`.
86
86
  # * Array: an ordered list of values, enclosed by square brackets:
@@ -105,8 +105,8 @@ end
105
105
  # ### Parsing JSON
106
106
  #
107
107
  # You can parse a String containing JSON data using either of two methods:
108
- # * `JSON.parse(source, opts)`
109
- # * `JSON.parse!(source, opts)`
108
+ # * <code>JSON.parse(source, opts)</code>
109
+ # * <code>JSON.parse!(source, opts)</code>
110
110
  #
111
111
  # where
112
112
  # * `source` is a Ruby object.
@@ -199,6 +199,24 @@ end
199
199
  #
200
200
  # ---
201
201
  #
202
+ # Option `allow_duplicate_key` specifies whether duplicate keys in objects
203
+ # should be ignored or cause an error to be raised:
204
+ #
205
+ # When not specified:
206
+ # # The last value is used and a deprecation warning emitted.
207
+ # JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
208
+ # # warning: detected duplicate keys in JSON object.
209
+ # # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
210
+ #
211
+ # When set to ``true``
212
+ # # The last value is used.
213
+ # JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
214
+ #
215
+ # When set to ``false``, the future default:
216
+ # JSON.parse('{"a": 1, "a":2}') => duplicate key at line 1 column 1 (JSON::ParserError)
217
+ #
218
+ # ---
219
+ #
202
220
  # Option `allow_nan` (boolean) specifies whether to allow NaN, Infinity, and
203
221
  # MinusInfinity in `source`; defaults to `false`.
204
222
  #
@@ -215,8 +233,22 @@ end
215
233
  # ruby = JSON.parse(source, {allow_nan: true})
216
234
  # ruby # => [NaN, Infinity, -Infinity]
217
235
  #
236
+ # ---
237
+ #
238
+ # Option `allow_trailing_comma` (boolean) specifies whether to allow trailing
239
+ # commas in objects and arrays; defaults to `false`.
240
+ #
241
+ # With the default, `false`:
242
+ # JSON.parse('[1,]') # unexpected character: ']' at line 1 column 4 (JSON::ParserError)
243
+ #
244
+ # When enabled:
245
+ # JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
246
+ #
218
247
  # ###### Output Options
219
248
  #
249
+ # Option `freeze` (boolean) specifies whether the returned objects will be
250
+ # frozen; defaults to `false`.
251
+ #
220
252
  # Option `symbolize_names` (boolean) specifies whether returned Hash keys should
221
253
  # be Symbols; defaults to `false` (use Strings).
222
254
  #
@@ -260,12 +292,12 @@ end
260
292
  # ---
261
293
  #
262
294
  # Option `create_additions` (boolean) specifies whether to use JSON additions in
263
- # parsing. See [\JSON Additions](#module-JSON-label-JSON+Additions).
295
+ # parsing. See [JSON Additions](#module-JSON-label-JSON+Additions).
264
296
  #
265
297
  # ### Generating JSON
266
298
  #
267
299
  # To generate a Ruby String containing JSON data, use method
268
- # `JSON.generate(source, opts)`, where
300
+ # <code>JSON.generate(source, opts)</code>, where
269
301
  # * `source` is a Ruby object.
270
302
  # * `opts` is a Hash object containing options that control both input allowed
271
303
  # and output formatting.
@@ -329,7 +361,7 @@ end
329
361
  # ###### Input Options
330
362
  #
331
363
  # Option `allow_nan` (boolean) specifies whether `NaN`, `Infinity`, and
332
- # `-Infinity` may be generated; defaults to `false`.
364
+ # <code>-Infinity</code> may be generated; defaults to `false`.
333
365
  #
334
366
  # With the default, `false`:
335
367
  # # Raises JSON::GeneratorError (920: NaN not allowed in JSON):
@@ -345,6 +377,25 @@ end
345
377
  #
346
378
  # ---
347
379
  #
380
+ # Option `allow_duplicate_key` (boolean) specifies whether hashes with duplicate
381
+ # keys should be allowed or produce an error. defaults to emit a deprecation
382
+ # warning.
383
+ #
384
+ # With the default, (not set):
385
+ # Warning[:deprecated] = true
386
+ # JSON.generate({ foo: 1, "foo" => 2 })
387
+ # # warning: detected duplicate key "foo" in {foo: 1, "foo" => 2}.
388
+ # # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
389
+ # # => '{"foo":1,"foo":2}'
390
+ #
391
+ # With `false`
392
+ # JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: false)
393
+ # # detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
394
+ #
395
+ # In version 3.0, `false` will become the default.
396
+ #
397
+ # ---
398
+ #
348
399
  # Option `max_nesting` (Integer) specifies the maximum nesting depth in `obj`;
349
400
  # defaults to `100`.
350
401
  #
@@ -358,9 +409,9 @@ end
358
409
  #
359
410
  # ###### Escaping Options
360
411
  #
361
- # Options `script_safe` (boolean) specifies wether `'\u2028'`, `'\u2029'` and
362
- # `'/'` should be escaped as to make the JSON object safe to interpolate in
363
- # script tags.
412
+ # Options `script_safe` (boolean) specifies wether <code>'\u2028'</code>,
413
+ # <code>'\u2029'</code> and <code>'/'</code> should be escaped as to make the
414
+ # JSON object safe to interpolate in script tags.
364
415
  #
365
416
  # Options `ascii_only` (boolean) specifies wether all characters outside the
366
417
  # ASCII range should be escaped.
@@ -374,19 +425,21 @@ end
374
425
  # format, using whitespace. See also JSON.pretty_generate.
375
426
  #
376
427
  # * Option `array_nl` (String) specifies a string (usually a newline) to be
377
- # inserted after each JSON array; defaults to the empty String, `''`.
428
+ # inserted after each JSON array; defaults to the empty String,
429
+ # <code>''</code>.
378
430
  # * Option `object_nl` (String) specifies a string (usually a newline) to be
379
- # inserted after each JSON object; defaults to the empty String, `''`.
431
+ # inserted after each JSON object; defaults to the empty String,
432
+ # <code>''</code>.
380
433
  # * Option `indent` (String) specifies the string (usually spaces) to be used
381
- # for indentation; defaults to the empty String, `''`; defaults to the empty
382
- # String, `''`; has no effect unless options `array_nl` or `object_nl`
383
- # specify newlines.
434
+ # for indentation; defaults to the empty String, <code>''</code>; defaults
435
+ # to the empty String, <code>''</code>; has no effect unless options
436
+ # `array_nl` or `object_nl` specify newlines.
384
437
  # * Option `space` (String) specifies a string (usually a space) to be
385
438
  # inserted after the colon in each JSON object's pair; defaults to the empty
386
- # String, `''`.
439
+ # String, <code>''</code>.
387
440
  # * Option `space_before` (String) specifies a string (usually a space) to be
388
441
  # inserted before the colon in each JSON object's pair; defaults to the
389
- # empty String, `''`.
442
+ # empty String, <code>''</code>.
390
443
  #
391
444
  # In this example, `obj` is used first to generate the shortest JSON data (no
392
445
  # whitespace), then again with all formatting options specified:
@@ -420,6 +473,9 @@ end
420
473
  #
421
474
  # ## JSON Additions
422
475
  #
476
+ # Note that JSON Additions must only be used with trusted data, and is
477
+ # deprecated.
478
+ #
423
479
  # When you "round trip" a non-String object from Ruby to JSON and back, you have
424
480
  # a new String, instead of the object you began with:
425
481
  # ruby0 = Range.new(0, 2)
@@ -465,26 +521,26 @@ end
465
521
  # With addition: 0..2 (Range)
466
522
  #
467
523
  # The JSON module includes additions for certain classes. You can also craft
468
- # custom additions. See [Custom \JSON
524
+ # custom additions. See [Custom JSON
469
525
  # Additions](#module-JSON-label-Custom+JSON+Additions).
470
526
  #
471
527
  # ### Built-in Additions
472
528
  #
473
529
  # The JSON module includes additions for certain classes. To use an addition,
474
530
  # `require` its source:
475
- # * BigDecimal: `require 'json/add/bigdecimal'`
476
- # * Complex: `require 'json/add/complex'`
477
- # * Date: `require 'json/add/date'`
478
- # * DateTime: `require 'json/add/date_time'`
479
- # * Exception: `require 'json/add/exception'`
480
- # * OpenStruct: `require 'json/add/ostruct'`
481
- # * Range: `require 'json/add/range'`
482
- # * Rational: `require 'json/add/rational'`
483
- # * Regexp: `require 'json/add/regexp'`
484
- # * Set: `require 'json/add/set'`
485
- # * Struct: `require 'json/add/struct'`
486
- # * Symbol: `require 'json/add/symbol'`
487
- # * Time: `require 'json/add/time'`
531
+ # * BigDecimal: <code>require 'json/add/bigdecimal'</code>
532
+ # * Complex: <code>require 'json/add/complex'</code>
533
+ # * Date: <code>require 'json/add/date'</code>
534
+ # * DateTime: <code>require 'json/add/date_time'</code>
535
+ # * Exception: <code>require 'json/add/exception'</code>
536
+ # * OpenStruct: <code>require 'json/add/ostruct'</code>
537
+ # * Range: <code>require 'json/add/range'</code>
538
+ # * Rational: <code>require 'json/add/rational'</code>
539
+ # * Regexp: <code>require 'json/add/regexp'</code>
540
+ # * Set: <code>require 'json/add/set'</code>
541
+ # * Struct: <code>require 'json/add/struct'</code>
542
+ # * Symbol: <code>require 'json/add/symbol'</code>
543
+ # * Time: <code>require 'json/add/time'</code>
488
544
  #
489
545
  # To reduce punctuation clutter, the examples below show the generated JSON via
490
546
  # `puts`, rather than the usual `inspect`,
@@ -708,8 +764,6 @@ module JSON
708
764
  #
709
765
  def self.create_id=: (_ToS create_id) -> _ToS
710
766
 
711
- def self.deep_const_get: (interned path) -> untyped
712
-
713
767
  # <!--
714
768
  # rdoc-file=ext/json/lib/json/common.rb
715
769
  # - JSON.dump(obj, io = nil, limit = nil)
@@ -786,7 +840,7 @@ module JSON
786
840
  # -->
787
841
  # Returns a String containing the generated JSON data.
788
842
  #
789
- # See also JSON.fast_generate, JSON.pretty_generate.
843
+ # See also JSON.pretty_generate.
790
844
  #
791
845
  # Argument `obj` is the Ruby object to be converted to JSON.
792
846
  #
@@ -805,7 +859,7 @@ module JSON
805
859
  # json = JSON.generate(obj)
806
860
  # json # => '{"foo":0,"bar":"s","baz":"bat"}'
807
861
  #
808
- # For examples of generating from other Ruby objects, see [Generating \JSON from
862
+ # For examples of generating from other Ruby objects, see [Generating JSON from
809
863
  # Other Objects](#module-JSON-label-Generating+JSON+from+Other+Objects).
810
864
  #
811
865
  # ---
@@ -828,6 +882,7 @@ module JSON
828
882
 
829
883
  # <!--
830
884
  # rdoc-file=ext/json/lib/json/common.rb
885
+ # - JSON.load(source, options = {}) -> object
831
886
  # - JSON.load(source, proc = nil, options = {}) -> object
832
887
  # -->
833
888
  # Returns the Ruby objects created by parsing the given `source`.
@@ -842,15 +897,17 @@ module JSON
842
897
  # in JSON version 3.0, `load` will have `create_additions` disabled by default.
843
898
  #
844
899
  # * Argument `source` must be, or be convertible to, a String:
845
- # * If `source` responds to instance method `to_str`, `source.to_str`
846
- # becomes the source.
847
- # * If `source` responds to instance method `to_io`, `source.to_io.read`
848
- # becomes the source.
849
- # * If `source` responds to instance method `read`, `source.read` becomes
850
- # the source.
851
- # * If both of the following are true, source becomes the String `'null'`:
900
+ # * If `source` responds to instance method `to_str`,
901
+ # <code>source.to_str</code> becomes the source.
902
+ # * If `source` responds to instance method `to_io`,
903
+ # <code>source.to_io.read</code> becomes the source.
904
+ # * If `source` responds to instance method `read`,
905
+ # <code>source.read</code> becomes the source.
906
+ # * If both of the following are true, source becomes the String
907
+ # <code>'null'</code>:
852
908
  # * Option `allow_blank` specifies a truthy value.
853
- # * The source, as defined above, is `nil` or the empty String `''`.
909
+ # * The source, as defined above, is `nil` or the empty String
910
+ # <code>''</code>.
854
911
  # * Otherwise, `source` remains the source.
855
912
  # * Argument `proc`, if given, must be a Proc that accepts one argument. It
856
913
  # will be called recursively with each result (depth-first order). See
@@ -862,7 +919,7 @@ module JSON
862
919
  # ---
863
920
  #
864
921
  # When no `proc` is given, modifies `source` as above and returns the result of
865
- # `parse(source, opts)`; see #parse.
922
+ # <code>parse(source, opts)</code>; see #parse.
866
923
  #
867
924
  # Source for following examples:
868
925
  # source = <<~JSON
@@ -897,8 +954,8 @@ module JSON
897
954
  #
898
955
  # When `proc` is given:
899
956
  # * Modifies `source` as above.
900
- # * Gets the `result` from calling `parse(source, opts)`.
901
- # * Recursively calls `proc(result)`.
957
+ # * Gets the `result` from calling <code>parse(source, opts)</code>.
958
+ # * Recursively calls <code>proc(result)</code>.
902
959
  # * Returns the final result.
903
960
  #
904
961
  # Example:
@@ -940,6 +997,7 @@ module JSON
940
997
  # when Array
941
998
  # obj.map! {|v| deserialize_obj v }
942
999
  # end
1000
+ # obj
943
1001
  # })
944
1002
  # pp ruby
945
1003
  #
@@ -1029,7 +1087,7 @@ module JSON
1029
1087
  # ruby.class # => Hash
1030
1088
  #
1031
1089
  # For examples of parsing for all JSON data types, see [Parsing
1032
- # \JSON](#module-JSON-label-Parsing+JSON).
1090
+ # JSON](#module-JSON-label-Parsing+JSON).
1033
1091
  #
1034
1092
  # Parses nested JSON objects:
1035
1093
  # source = <<~JSON
@@ -1172,7 +1230,7 @@ module Kernel
1172
1230
 
1173
1231
  # <!--
1174
1232
  # rdoc-file=ext/json/lib/json/common.rb
1175
- # - JSON(object, *args)
1233
+ # - JSON(object, opts = nil)
1176
1234
  # -->
1177
1235
  # If *object* is string-like, parse the string and return the parsed result as a
1178
1236
  # Ruby data structure. Otherwise, generate a JSON text from the Ruby data
@@ -1191,28 +1249,28 @@ class Object
1191
1249
  # it to a JSON string, and returns the result. This is a fallback, if no
1192
1250
  # special method #to_json was defined for some object.
1193
1251
  #
1194
- def to_json: (?JSON::State state) -> String
1252
+ def to_json: (?JSON::State? state) -> String
1195
1253
  end
1196
1254
 
1197
1255
  %a{annotate:rdoc:skip}
1198
1256
  class NilClass
1199
1257
  # Returns a JSON string for nil: 'null'.
1200
1258
  #
1201
- def to_json: (?JSON::State state) -> String
1259
+ def to_json: (?JSON::State? state) -> String
1202
1260
  end
1203
1261
 
1204
1262
  %a{annotate:rdoc:skip}
1205
1263
  class TrueClass
1206
1264
  # Returns a JSON string for true: 'true'.
1207
1265
  #
1208
- def to_json: (?JSON::State state) -> String
1266
+ def to_json: (?JSON::State? state) -> String
1209
1267
  end
1210
1268
 
1211
1269
  %a{annotate:rdoc:skip}
1212
1270
  class FalseClass
1213
1271
  # Returns a JSON string for false: 'false'.
1214
1272
  #
1215
- def to_json: (?JSON::State state) -> String
1273
+ def to_json: (?JSON::State? state) -> String
1216
1274
  end
1217
1275
 
1218
1276
  %a{annotate:rdoc:skip}
@@ -1221,21 +1279,21 @@ class String
1221
1279
  # returns a JSON string encoded with UTF16 big endian characters as
1222
1280
  # \u????.
1223
1281
  #
1224
- def to_json: (?JSON::State state) -> String
1282
+ def to_json: (?JSON::State? state) -> String
1225
1283
  end
1226
1284
 
1227
1285
  %a{annotate:rdoc:skip}
1228
1286
  class Integer
1229
1287
  # Returns a JSON string representation for this Integer number.
1230
1288
  #
1231
- def to_json: (?JSON::State state) -> String
1289
+ def to_json: (?JSON::State? state) -> String
1232
1290
  end
1233
1291
 
1234
1292
  %a{annotate:rdoc:skip}
1235
1293
  class Float
1236
1294
  # Returns a JSON string representation for this Float number.
1237
1295
  #
1238
- def to_json: (?JSON::State state) -> String
1296
+ def to_json: (?JSON::State? state) -> String
1239
1297
  end
1240
1298
 
1241
1299
  %a{annotate:rdoc:skip}
@@ -1245,7 +1303,7 @@ class Hash[unchecked out K, unchecked out V]
1245
1303
  # _state_ is a JSON::State object, that can also be used to configure the
1246
1304
  # produced JSON string output further.
1247
1305
  #
1248
- def to_json: (?JSON::State state) -> String
1306
+ def to_json: (?JSON::State? state) -> String
1249
1307
  end
1250
1308
 
1251
1309
  %a{annotate:rdoc:skip}
@@ -1255,7 +1313,7 @@ class Array[unchecked out Elem]
1255
1313
  # _state_ is a JSON::State object, that can also be used to configure the
1256
1314
  # produced JSON string output further.
1257
1315
  #
1258
- def to_json: (?JSON::State state) -> String
1316
+ def to_json: (?JSON::State? state) -> String
1259
1317
  end
1260
1318
 
1261
1319
  %a{annotate:rdoc:skip}
@@ -1272,19 +1330,20 @@ class BigDecimal
1272
1330
  # rdoc-file=ext/json/lib/json/add/bigdecimal.rb
1273
1331
  # - as_json(*)
1274
1332
  # -->
1275
- # Methods `BigDecimal#as_json` and `BigDecimal.json_create` may be used to
1276
- # serialize and deserialize a BigDecimal object; see
1277
- # [Marshal](rdoc-ref:Marshal).
1333
+ # Methods <code>BigDecimal#as_json</code> and
1334
+ # <code>BigDecimal.json_create</code> may be used to serialize and deserialize a
1335
+ # BigDecimal object; see [Marshal](rdoc-ref:Marshal).
1278
1336
  #
1279
- # Method `BigDecimal#as_json` serializes `self`, returning a 2-element hash
1280
- # representing `self`:
1337
+ # Method <code>BigDecimal#as_json</code> serializes `self`, returning a
1338
+ # 2-element hash representing `self`:
1281
1339
  #
1282
1340
  # require 'json/add/bigdecimal'
1283
1341
  # x = BigDecimal(2).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
1284
1342
  # y = BigDecimal(2.0, 4).as_json # => {"json_class"=>"BigDecimal", "b"=>"36:0.2e1"}
1285
1343
  # z = BigDecimal(Complex(2, 0)).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
1286
1344
  #
1287
- # Method `JSON.create` deserializes such a hash, returning a BigDecimal object:
1345
+ # Method <code>JSON.create</code> deserializes such a hash, returning a
1346
+ # BigDecimal object:
1288
1347
  #
1289
1348
  # BigDecimal.json_create(x) # => 0.2e1
1290
1349
  # BigDecimal.json_create(y) # => 0.2e1
@@ -1309,7 +1368,7 @@ class BigDecimal
1309
1368
  # {"json_class":"BigDecimal","b":"36:0.2e1"}
1310
1369
  # {"json_class":"BigDecimal","b":"27:0.2e1"}
1311
1370
  #
1312
- def to_json: (?JSON::State state) -> String
1371
+ def to_json: (?JSON::State? state) -> String
1313
1372
  end
1314
1373
 
1315
1374
  %a{annotate:rdoc:skip}
@@ -1326,17 +1385,19 @@ class Complex
1326
1385
  # rdoc-file=ext/json/lib/json/add/complex.rb
1327
1386
  # - as_json(*)
1328
1387
  # -->
1329
- # Methods `Complex#as_json` and `Complex.json_create` may be used to serialize
1330
- # and deserialize a Complex object; see [Marshal](rdoc-ref:Marshal).
1388
+ # Methods <code>Complex#as_json</code> and <code>Complex.json_create</code> may
1389
+ # be used to serialize and deserialize a Complex object; see
1390
+ # [Marshal](rdoc-ref:Marshal).
1331
1391
  #
1332
- # Method `Complex#as_json` serializes `self`, returning a 2-element hash
1333
- # representing `self`:
1392
+ # Method <code>Complex#as_json</code> serializes `self`, returning a 2-element
1393
+ # hash representing `self`:
1334
1394
  #
1335
1395
  # require 'json/add/complex'
1336
1396
  # x = Complex(2).as_json # => {"json_class"=>"Complex", "r"=>2, "i"=>0}
1337
1397
  # y = Complex(2.0, 4).as_json # => {"json_class"=>"Complex", "r"=>2.0, "i"=>4}
1338
1398
  #
1339
- # Method `JSON.create` deserializes such a hash, returning a Complex object:
1399
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Complex
1400
+ # object:
1340
1401
  #
1341
1402
  # Complex.json_create(x) # => (2+0i)
1342
1403
  # Complex.json_create(y) # => (2.0+4i)
@@ -1358,7 +1419,7 @@ class Complex
1358
1419
  # {"json_class":"Complex","r":2,"i":0}
1359
1420
  # {"json_class":"Complex","r":2.0,"i":4}
1360
1421
  #
1361
- def to_json: (?JSON::State state) -> String
1422
+ def to_json: (?JSON::State? state) -> String
1362
1423
  end
1363
1424
 
1364
1425
  %a{annotate:rdoc:skip}
@@ -1375,17 +1436,19 @@ class Date
1375
1436
  # rdoc-file=ext/json/lib/json/add/date.rb
1376
1437
  # - as_json(*)
1377
1438
  # -->
1378
- # Methods `Date#as_json` and `Date.json_create` may be used to serialize and
1379
- # deserialize a Date object; see [Marshal](rdoc-ref:Marshal).
1439
+ # Methods <code>Date#as_json</code> and <code>Date.json_create</code> may be
1440
+ # used to serialize and deserialize a Date object; see
1441
+ # [Marshal](rdoc-ref:Marshal).
1380
1442
  #
1381
- # Method `Date#as_json` serializes `self`, returning a 2-element hash
1443
+ # Method <code>Date#as_json</code> serializes `self`, returning a 2-element hash
1382
1444
  # representing `self`:
1383
1445
  #
1384
1446
  # require 'json/add/date'
1385
1447
  # x = Date.today.as_json
1386
1448
  # # => {"json_class"=>"Date", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
1387
1449
  #
1388
- # Method `JSON.create` deserializes such a hash, returning a Date object:
1450
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Date
1451
+ # object:
1389
1452
  #
1390
1453
  # Date.json_create(x)
1391
1454
  # # => #<Date: 2023-11-21 ((2460270j,0s,0n),+0s,2299161j)>
@@ -1405,7 +1468,7 @@ class Date
1405
1468
  #
1406
1469
  # {"json_class":"Date","y":2023,"m":11,"d":21,"sg":2299161.0}
1407
1470
  #
1408
- def to_json: (?JSON::State state) -> String
1471
+ def to_json: (?JSON::State? state) -> String
1409
1472
  end
1410
1473
 
1411
1474
  %a{annotate:rdoc:skip}
@@ -1422,17 +1485,19 @@ class DateTime
1422
1485
  # rdoc-file=ext/json/lib/json/add/date_time.rb
1423
1486
  # - as_json(*)
1424
1487
  # -->
1425
- # Methods `DateTime#as_json` and `DateTime.json_create` may be used to serialize
1426
- # and deserialize a DateTime object; see [Marshal](rdoc-ref:Marshal).
1488
+ # Methods <code>DateTime#as_json</code> and <code>DateTime.json_create</code>
1489
+ # may be used to serialize and deserialize a DateTime object; see
1490
+ # [Marshal](rdoc-ref:Marshal).
1427
1491
  #
1428
- # Method `DateTime#as_json` serializes `self`, returning a 2-element hash
1429
- # representing `self`:
1492
+ # Method <code>DateTime#as_json</code> serializes `self`, returning a 2-element
1493
+ # hash representing `self`:
1430
1494
  #
1431
1495
  # require 'json/add/datetime'
1432
1496
  # x = DateTime.now.as_json
1433
1497
  # # => {"json_class"=>"DateTime", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
1434
1498
  #
1435
- # Method `JSON.create` deserializes such a hash, returning a DateTime object:
1499
+ # Method <code>JSON.create</code> deserializes such a hash, returning a DateTime
1500
+ # object:
1436
1501
  #
1437
1502
  # DateTime.json_create(x) # BUG? Raises Date::Error "invalid date"
1438
1503
  #
@@ -1451,7 +1516,7 @@ class DateTime
1451
1516
  #
1452
1517
  # {"json_class":"DateTime","y":2023,"m":11,"d":21,"sg":2299161.0}
1453
1518
  #
1454
- def to_json: (?JSON::State state) -> String
1519
+ def to_json: (?JSON::State? state) -> String
1455
1520
  end
1456
1521
 
1457
1522
  %a{annotate:rdoc:skip}
@@ -1468,16 +1533,18 @@ class Exception
1468
1533
  # rdoc-file=ext/json/lib/json/add/exception.rb
1469
1534
  # - as_json(*)
1470
1535
  # -->
1471
- # Methods `Exception#as_json` and `Exception.json_create` may be used to
1472
- # serialize and deserialize a Exception object; see [Marshal](rdoc-ref:Marshal).
1536
+ # Methods <code>Exception#as_json</code> and <code>Exception.json_create</code>
1537
+ # may be used to serialize and deserialize a Exception object; see
1538
+ # [Marshal](rdoc-ref:Marshal).
1473
1539
  #
1474
- # Method `Exception#as_json` serializes `self`, returning a 2-element hash
1475
- # representing `self`:
1540
+ # Method <code>Exception#as_json</code> serializes `self`, returning a 2-element
1541
+ # hash representing `self`:
1476
1542
  #
1477
1543
  # require 'json/add/exception'
1478
1544
  # x = Exception.new('Foo').as_json # => {"json_class"=>"Exception", "m"=>"Foo", "b"=>nil}
1479
1545
  #
1480
- # Method `JSON.create` deserializes such a hash, returning a Exception object:
1546
+ # Method <code>JSON.create</code> deserializes such a hash, returning a
1547
+ # Exception object:
1481
1548
  #
1482
1549
  # Exception.json_create(x) # => #<Exception: Foo>
1483
1550
  #
@@ -1496,7 +1563,7 @@ class Exception
1496
1563
  #
1497
1564
  # {"json_class":"Exception","m":"Foo","b":null}
1498
1565
  #
1499
- def to_json: (?JSON::State state) -> String
1566
+ def to_json: (?JSON::State? state) -> String
1500
1567
  end
1501
1568
 
1502
1569
  %a{annotate:rdoc:skip}
@@ -1513,18 +1580,19 @@ class OpenStruct
1513
1580
  # rdoc-file=ext/json/lib/json/add/ostruct.rb
1514
1581
  # - as_json(*)
1515
1582
  # -->
1516
- # Methods `OpenStruct#as_json` and `OpenStruct.json_create` may be used to
1517
- # serialize and deserialize a OpenStruct object; see
1518
- # [Marshal](rdoc-ref:Marshal).
1583
+ # Methods <code>OpenStruct#as_json</code> and
1584
+ # <code>OpenStruct.json_create</code> may be used to serialize and deserialize a
1585
+ # OpenStruct object; see [Marshal](rdoc-ref:Marshal).
1519
1586
  #
1520
- # Method `OpenStruct#as_json` serializes `self`, returning a 2-element hash
1521
- # representing `self`:
1587
+ # Method <code>OpenStruct#as_json</code> serializes `self`, returning a
1588
+ # 2-element hash representing `self`:
1522
1589
  #
1523
1590
  # require 'json/add/ostruct'
1524
1591
  # x = OpenStruct.new('name' => 'Rowdy', :age => nil).as_json
1525
1592
  # # => {"json_class"=>"OpenStruct", "t"=>{:name=>'Rowdy', :age=>nil}}
1526
1593
  #
1527
- # Method `JSON.create` deserializes such a hash, returning a OpenStruct object:
1594
+ # Method <code>JSON.create</code> deserializes such a hash, returning a
1595
+ # OpenStruct object:
1528
1596
  #
1529
1597
  # OpenStruct.json_create(x)
1530
1598
  # # => #<OpenStruct name='Rowdy', age=nil>
@@ -1544,7 +1612,7 @@ class OpenStruct
1544
1612
  #
1545
1613
  # {"json_class":"OpenStruct","t":{'name':'Rowdy',"age":null}}
1546
1614
  #
1547
- def to_json: (?JSON::State state) -> String
1615
+ def to_json: (?JSON::State? state) -> String
1548
1616
  end
1549
1617
 
1550
1618
  %a{annotate:rdoc:skip}
@@ -1561,18 +1629,20 @@ class Range[out Elem]
1561
1629
  # rdoc-file=ext/json/lib/json/add/range.rb
1562
1630
  # - as_json(*)
1563
1631
  # -->
1564
- # Methods `Range#as_json` and `Range.json_create` may be used to serialize and
1565
- # deserialize a Range object; see [Marshal](rdoc-ref:Marshal).
1632
+ # Methods <code>Range#as_json</code> and <code>Range.json_create</code> may be
1633
+ # used to serialize and deserialize a Range object; see
1634
+ # [Marshal](rdoc-ref:Marshal).
1566
1635
  #
1567
- # Method `Range#as_json` serializes `self`, returning a 2-element hash
1568
- # representing `self`:
1636
+ # Method <code>Range#as_json</code> serializes `self`, returning a 2-element
1637
+ # hash representing `self`:
1569
1638
  #
1570
1639
  # require 'json/add/range'
1571
1640
  # x = (1..4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, false]}
1572
1641
  # y = (1...4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, true]}
1573
1642
  # z = ('a'..'d').as_json # => {"json_class"=>"Range", "a"=>["a", "d", false]}
1574
1643
  #
1575
- # Method `JSON.create` deserializes such a hash, returning a Range object:
1644
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Range
1645
+ # object:
1576
1646
  #
1577
1647
  # Range.json_create(x) # => 1..4
1578
1648
  # Range.json_create(y) # => 1...4
@@ -1597,7 +1667,7 @@ class Range[out Elem]
1597
1667
  # {"json_class":"Range","a":[1,4,true]}
1598
1668
  # {"json_class":"Range","a":["a","d",false]}
1599
1669
  #
1600
- def to_json: (?JSON::State state) -> String
1670
+ def to_json: (?JSON::State? state) -> String
1601
1671
  end
1602
1672
 
1603
1673
  %a{annotate:rdoc:skip}
@@ -1614,17 +1684,19 @@ class Rational
1614
1684
  # rdoc-file=ext/json/lib/json/add/rational.rb
1615
1685
  # - as_json(*)
1616
1686
  # -->
1617
- # Methods `Rational#as_json` and `Rational.json_create` may be used to serialize
1618
- # and deserialize a Rational object; see [Marshal](rdoc-ref:Marshal).
1687
+ # Methods <code>Rational#as_json</code> and <code>Rational.json_create</code>
1688
+ # may be used to serialize and deserialize a Rational object; see
1689
+ # [Marshal](rdoc-ref:Marshal).
1619
1690
  #
1620
- # Method `Rational#as_json` serializes `self`, returning a 2-element hash
1621
- # representing `self`:
1691
+ # Method <code>Rational#as_json</code> serializes `self`, returning a 2-element
1692
+ # hash representing `self`:
1622
1693
  #
1623
1694
  # require 'json/add/rational'
1624
1695
  # x = Rational(2, 3).as_json
1625
1696
  # # => {"json_class"=>"Rational", "n"=>2, "d"=>3}
1626
1697
  #
1627
- # Method `JSON.create` deserializes such a hash, returning a Rational object:
1698
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Rational
1699
+ # object:
1628
1700
  #
1629
1701
  # Rational.json_create(x)
1630
1702
  # # => (2/3)
@@ -1644,7 +1716,7 @@ class Rational
1644
1716
  #
1645
1717
  # {"json_class":"Rational","n":2,"d":3}
1646
1718
  #
1647
- def to_json: (?JSON::State state) -> String
1719
+ def to_json: (?JSON::State? state) -> String
1648
1720
  end
1649
1721
 
1650
1722
  %a{annotate:rdoc:skip}
@@ -1661,17 +1733,19 @@ class Regexp
1661
1733
  # rdoc-file=ext/json/lib/json/add/regexp.rb
1662
1734
  # - as_json(*)
1663
1735
  # -->
1664
- # Methods `Regexp#as_json` and `Regexp.json_create` may be used to serialize and
1665
- # deserialize a Regexp object; see [Marshal](rdoc-ref:Marshal).
1736
+ # Methods <code>Regexp#as_json</code> and <code>Regexp.json_create</code> may be
1737
+ # used to serialize and deserialize a Regexp object; see
1738
+ # [Marshal](rdoc-ref:Marshal).
1666
1739
  #
1667
- # Method `Regexp#as_json` serializes `self`, returning a 2-element hash
1668
- # representing `self`:
1740
+ # Method <code>Regexp#as_json</code> serializes `self`, returning a 2-element
1741
+ # hash representing `self`:
1669
1742
  #
1670
1743
  # require 'json/add/regexp'
1671
1744
  # x = /foo/.as_json
1672
1745
  # # => {"json_class"=>"Regexp", "o"=>0, "s"=>"foo"}
1673
1746
  #
1674
- # Method `JSON.create` deserializes such a hash, returning a Regexp object:
1747
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Regexp
1748
+ # object:
1675
1749
  #
1676
1750
  # Regexp.json_create(x) # => /foo/
1677
1751
  #
@@ -1690,7 +1764,7 @@ class Regexp
1690
1764
  #
1691
1765
  # {"json_class":"Regexp","o":0,"s":"foo"}
1692
1766
  #
1693
- def to_json: (?JSON::State state) -> String
1767
+ def to_json: (?JSON::State? state) -> String
1694
1768
  end
1695
1769
 
1696
1770
  %a{annotate:rdoc:skip}
@@ -1707,17 +1781,18 @@ class Set[unchecked out A]
1707
1781
  # rdoc-file=ext/json/lib/json/add/set.rb
1708
1782
  # - as_json(*)
1709
1783
  # -->
1710
- # Methods `Set#as_json` and `Set.json_create` may be used to serialize and
1711
- # deserialize a Set object; see [Marshal](rdoc-ref:Marshal).
1784
+ # Methods <code>Set#as_json</code> and <code>Set.json_create</code> may be used
1785
+ # to serialize and deserialize a Set object; see [Marshal](rdoc-ref:Marshal).
1712
1786
  #
1713
- # Method `Set#as_json` serializes `self`, returning a 2-element hash
1787
+ # Method <code>Set#as_json</code> serializes `self`, returning a 2-element hash
1714
1788
  # representing `self`:
1715
1789
  #
1716
1790
  # require 'json/add/set'
1717
1791
  # x = Set.new(%w/foo bar baz/).as_json
1718
1792
  # # => {"json_class"=>"Set", "a"=>["foo", "bar", "baz"]}
1719
1793
  #
1720
- # Method `JSON.create` deserializes such a hash, returning a Set object:
1794
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Set
1795
+ # object:
1721
1796
  #
1722
1797
  # Set.json_create(x) # => #<Set: {"foo", "bar", "baz"}>
1723
1798
  #
@@ -1736,7 +1811,7 @@ class Set[unchecked out A]
1736
1811
  #
1737
1812
  # {"json_class":"Set","a":["foo","bar","baz"]}
1738
1813
  #
1739
- def to_json: (?JSON::State state) -> String
1814
+ def to_json: (?JSON::State? state) -> String
1740
1815
  end
1741
1816
 
1742
1817
  %a{annotate:rdoc:skip}
@@ -1753,18 +1828,20 @@ class Struct[Elem]
1753
1828
  # rdoc-file=ext/json/lib/json/add/struct.rb
1754
1829
  # - as_json(*)
1755
1830
  # -->
1756
- # Methods `Struct#as_json` and `Struct.json_create` may be used to serialize and
1757
- # deserialize a Struct object; see [Marshal](rdoc-ref:Marshal).
1831
+ # Methods <code>Struct#as_json</code> and <code>Struct.json_create</code> may be
1832
+ # used to serialize and deserialize a Struct object; see
1833
+ # [Marshal](rdoc-ref:Marshal).
1758
1834
  #
1759
- # Method `Struct#as_json` serializes `self`, returning a 2-element hash
1760
- # representing `self`:
1835
+ # Method <code>Struct#as_json</code> serializes `self`, returning a 2-element
1836
+ # hash representing `self`:
1761
1837
  #
1762
1838
  # require 'json/add/struct'
1763
1839
  # Customer = Struct.new('Customer', :name, :address, :zip)
1764
1840
  # x = Struct::Customer.new.as_json
1765
1841
  # # => {"json_class"=>"Struct::Customer", "v"=>[nil, nil, nil]}
1766
1842
  #
1767
- # Method `JSON.create` deserializes such a hash, returning a Struct object:
1843
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Struct
1844
+ # object:
1768
1845
  #
1769
1846
  # Struct::Customer.json_create(x)
1770
1847
  # # => #<struct Struct::Customer name=nil, address=nil, zip=nil>
@@ -1785,7 +1862,7 @@ class Struct[Elem]
1785
1862
  #
1786
1863
  # {"json_class":"Struct","t":{'name':'Rowdy',"age":null}}
1787
1864
  #
1788
- def to_json: (?JSON::State state) -> String
1865
+ def to_json: (?JSON::State? state) -> String
1789
1866
  end
1790
1867
 
1791
1868
  %a{annotate:rdoc:skip}
@@ -1802,17 +1879,19 @@ class Symbol
1802
1879
  # rdoc-file=ext/json/lib/json/add/symbol.rb
1803
1880
  # - as_json(*)
1804
1881
  # -->
1805
- # Methods `Symbol#as_json` and `Symbol.json_create` may be used to serialize and
1806
- # deserialize a Symbol object; see [Marshal](rdoc-ref:Marshal).
1882
+ # Methods <code>Symbol#as_json</code> and <code>Symbol.json_create</code> may be
1883
+ # used to serialize and deserialize a Symbol object; see
1884
+ # [Marshal](rdoc-ref:Marshal).
1807
1885
  #
1808
- # Method `Symbol#as_json` serializes `self`, returning a 2-element hash
1809
- # representing `self`:
1886
+ # Method <code>Symbol#as_json</code> serializes `self`, returning a 2-element
1887
+ # hash representing `self`:
1810
1888
  #
1811
1889
  # require 'json/add/symbol'
1812
1890
  # x = :foo.as_json
1813
1891
  # # => {"json_class"=>"Symbol", "s"=>"foo"}
1814
1892
  #
1815
- # Method `JSON.create` deserializes such a hash, returning a Symbol object:
1893
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Symbol
1894
+ # object:
1816
1895
  #
1817
1896
  # Symbol.json_create(x) # => :foo
1818
1897
  #
@@ -1820,7 +1899,7 @@ class Symbol
1820
1899
 
1821
1900
  # <!--
1822
1901
  # rdoc-file=ext/json/lib/json/add/symbol.rb
1823
- # - to_json(*a)
1902
+ # - to_json(state = nil, *a)
1824
1903
  # -->
1825
1904
  # Returns a JSON string representing `self`:
1826
1905
  #
@@ -1831,7 +1910,7 @@ class Symbol
1831
1910
  #
1832
1911
  # # {"json_class":"Symbol","s":"foo"}
1833
1912
  #
1834
- def to_json: (?JSON::State state) -> String
1913
+ def to_json: (?JSON::State? state) -> String
1835
1914
  end
1836
1915
 
1837
1916
  %a{annotate:rdoc:skip}
@@ -1848,17 +1927,19 @@ class Time
1848
1927
  # rdoc-file=ext/json/lib/json/add/time.rb
1849
1928
  # - as_json(*)
1850
1929
  # -->
1851
- # Methods `Time#as_json` and `Time.json_create` may be used to serialize and
1852
- # deserialize a Time object; see [Marshal](rdoc-ref:Marshal).
1930
+ # Methods <code>Time#as_json</code> and <code>Time.json_create</code> may be
1931
+ # used to serialize and deserialize a Time object; see
1932
+ # [Marshal](rdoc-ref:Marshal).
1853
1933
  #
1854
- # Method `Time#as_json` serializes `self`, returning a 2-element hash
1934
+ # Method <code>Time#as_json</code> serializes `self`, returning a 2-element hash
1855
1935
  # representing `self`:
1856
1936
  #
1857
1937
  # require 'json/add/time'
1858
1938
  # x = Time.now.as_json
1859
1939
  # # => {"json_class"=>"Time", "s"=>1700931656, "n"=>472846644}
1860
1940
  #
1861
- # Method `JSON.create` deserializes such a hash, returning a Time object:
1941
+ # Method <code>JSON.create</code> deserializes such a hash, returning a Time
1942
+ # object:
1862
1943
  #
1863
1944
  # Time.json_create(x)
1864
1945
  # # => 2023-11-25 11:00:56.472846644 -0600
@@ -1878,5 +1959,5 @@ class Time
1878
1959
  #
1879
1960
  # {"json_class":"Time","s":1700931678,"n":980650786}
1880
1961
  #
1881
- def to_json: (?JSON::State state) -> String
1962
+ def to_json: (?JSON::State? state) -> String
1882
1963
  end