rbs 4.1.0.pre.2-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (574) hide show
  1. checksums.yaml +7 -0
  2. data/.clang-format +75 -0
  3. data/.clangd +2 -0
  4. data/.github/dependabot.yml +24 -0
  5. data/.github/workflows/bundle-update.yml +63 -0
  6. data/.github/workflows/c-check.yml +61 -0
  7. data/.github/workflows/comments.yml +37 -0
  8. data/.github/workflows/dependabot.yml +30 -0
  9. data/.github/workflows/jruby.yml +67 -0
  10. data/.github/workflows/milestone.yml +83 -0
  11. data/.github/workflows/ruby.yml +158 -0
  12. data/.github/workflows/rust.yml +184 -0
  13. data/.github/workflows/truffleruby.yml +54 -0
  14. data/.github/workflows/typecheck.yml +39 -0
  15. data/.github/workflows/wasm.yml +53 -0
  16. data/.github/workflows/windows.yml +49 -0
  17. data/.gitignore +38 -0
  18. data/.rubocop.yml +72 -0
  19. data/BSDL +22 -0
  20. data/CHANGELOG.md +2292 -0
  21. data/COPYING +56 -0
  22. data/README.md +240 -0
  23. data/Rakefile +869 -0
  24. data/Steepfile +53 -0
  25. data/config.yml +913 -0
  26. data/core/array.rbs +4142 -0
  27. data/core/basic_object.rbs +376 -0
  28. data/core/binding.rbs +148 -0
  29. data/core/builtin.rbs +278 -0
  30. data/core/class.rbs +223 -0
  31. data/core/comparable.rbs +192 -0
  32. data/core/complex.rbs +812 -0
  33. data/core/constants.rbs +96 -0
  34. data/core/data.rbs +415 -0
  35. data/core/dir.rbs +993 -0
  36. data/core/encoding.rbs +1368 -0
  37. data/core/enumerable.rbs +2506 -0
  38. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  39. data/core/enumerator/product.rbs +92 -0
  40. data/core/enumerator.rbs +705 -0
  41. data/core/env.rbs +6 -0
  42. data/core/errno.rbs +682 -0
  43. data/core/errors.rbs +789 -0
  44. data/core/exception.rbs +485 -0
  45. data/core/false_class.rbs +82 -0
  46. data/core/fiber.rbs +570 -0
  47. data/core/fiber_error.rbs +11 -0
  48. data/core/file.rbs +2045 -0
  49. data/core/file_constants.rbs +463 -0
  50. data/core/file_stat.rbs +534 -0
  51. data/core/file_test.rbs +331 -0
  52. data/core/float.rbs +1316 -0
  53. data/core/gc.rbs +788 -0
  54. data/core/global_variables.rbs +184 -0
  55. data/core/hash.rbs +2183 -0
  56. data/core/integer.rbs +1374 -0
  57. data/core/io/buffer.rbs +995 -0
  58. data/core/io/wait.rbs +48 -0
  59. data/core/io.rbs +3472 -0
  60. data/core/kernel.rbs +3172 -0
  61. data/core/marshal.rbs +207 -0
  62. data/core/match_data.rbs +637 -0
  63. data/core/math.rbs +770 -0
  64. data/core/method.rbs +422 -0
  65. data/core/module.rbs +1856 -0
  66. data/core/nil_class.rbs +210 -0
  67. data/core/numeric.rbs +832 -0
  68. data/core/object.rbs +108 -0
  69. data/core/object_space/weak_key_map.rbs +166 -0
  70. data/core/object_space.rbs +197 -0
  71. data/core/pathname.rbs +1322 -0
  72. data/core/proc.rbs +905 -0
  73. data/core/process.rbs +2316 -0
  74. data/core/ractor.rbs +924 -0
  75. data/core/random.rbs +255 -0
  76. data/core/range.rbs +1209 -0
  77. data/core/rational.rbs +502 -0
  78. data/core/rb_config.rbs +88 -0
  79. data/core/rbs/ops.rbs +154 -0
  80. data/core/rbs/unnamed/argf.rbs +1236 -0
  81. data/core/rbs/unnamed/env_class.rbs +1214 -0
  82. data/core/rbs/unnamed/main_class.rbs +123 -0
  83. data/core/rbs/unnamed/random.rbs +186 -0
  84. data/core/refinement.rbs +59 -0
  85. data/core/regexp.rbs +1974 -0
  86. data/core/ruby.rbs +53 -0
  87. data/core/ruby_vm.rbs +809 -0
  88. data/core/rubygems/basic_specification.rbs +6 -0
  89. data/core/rubygems/config_file.rbs +38 -0
  90. data/core/rubygems/dependency_installer.rbs +6 -0
  91. data/core/rubygems/errors.rbs +109 -0
  92. data/core/rubygems/installer.rbs +15 -0
  93. data/core/rubygems/path_support.rbs +6 -0
  94. data/core/rubygems/platform.rbs +7 -0
  95. data/core/rubygems/request_set.rbs +49 -0
  96. data/core/rubygems/requirement.rbs +148 -0
  97. data/core/rubygems/rubygems.rbs +1105 -0
  98. data/core/rubygems/source_list.rbs +15 -0
  99. data/core/rubygems/specification.rbs +23 -0
  100. data/core/rubygems/stream_ui.rbs +5 -0
  101. data/core/rubygems/uninstaller.rbs +10 -0
  102. data/core/rubygems/version.rbs +293 -0
  103. data/core/set.rbs +751 -0
  104. data/core/signal.rbs +110 -0
  105. data/core/string.rbs +5532 -0
  106. data/core/struct.rbs +668 -0
  107. data/core/symbol.rbs +482 -0
  108. data/core/thread.rbs +1826 -0
  109. data/core/thread_group.rbs +79 -0
  110. data/core/time.rbs +1793 -0
  111. data/core/trace_point.rbs +483 -0
  112. data/core/true_class.rbs +98 -0
  113. data/core/unbound_method.rbs +337 -0
  114. data/core/warning.rbs +87 -0
  115. data/docs/CONTRIBUTING.md +107 -0
  116. data/docs/aliases.md +79 -0
  117. data/docs/architecture.md +110 -0
  118. data/docs/collection.md +192 -0
  119. data/docs/config.md +171 -0
  120. data/docs/data_and_struct.md +86 -0
  121. data/docs/encoding.md +56 -0
  122. data/docs/gem.md +56 -0
  123. data/docs/inline.md +634 -0
  124. data/docs/rbs_by_example.md +309 -0
  125. data/docs/repo.md +125 -0
  126. data/docs/rust.md +96 -0
  127. data/docs/sigs.md +167 -0
  128. data/docs/stdlib.md +147 -0
  129. data/docs/syntax.md +940 -0
  130. data/docs/tools.md +17 -0
  131. data/docs/type_fingerprint.md +21 -0
  132. data/docs/wasm_serialization.md +80 -0
  133. data/exe/rbs +7 -0
  134. data/ext/rbs_extension/ast_translation.c +1855 -0
  135. data/ext/rbs_extension/ast_translation.h +41 -0
  136. data/ext/rbs_extension/class_constants.c +187 -0
  137. data/ext/rbs_extension/class_constants.h +104 -0
  138. data/ext/rbs_extension/compat.h +10 -0
  139. data/ext/rbs_extension/extconf.rb +40 -0
  140. data/ext/rbs_extension/legacy_location.c +294 -0
  141. data/ext/rbs_extension/legacy_location.h +82 -0
  142. data/ext/rbs_extension/main.c +613 -0
  143. data/ext/rbs_extension/rbs_extension.h +16 -0
  144. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  145. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  146. data/goodcheck.yml +91 -0
  147. data/include/rbs/ast.h +1047 -0
  148. data/include/rbs/defines.h +99 -0
  149. data/include/rbs/lexer.h +207 -0
  150. data/include/rbs/location.h +40 -0
  151. data/include/rbs/parser.h +153 -0
  152. data/include/rbs/serialize.h +39 -0
  153. data/include/rbs/string.h +47 -0
  154. data/include/rbs/util/rbs_allocator.h +59 -0
  155. data/include/rbs/util/rbs_assert.h +20 -0
  156. data/include/rbs/util/rbs_buffer.h +83 -0
  157. data/include/rbs/util/rbs_constant_pool.h +155 -0
  158. data/include/rbs/util/rbs_encoding.h +282 -0
  159. data/include/rbs/util/rbs_unescape.h +24 -0
  160. data/include/rbs.h +14 -0
  161. data/lib/rbs/ancestor_graph.rb +92 -0
  162. data/lib/rbs/annotate/annotations.rb +199 -0
  163. data/lib/rbs/annotate/formatter.rb +82 -0
  164. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  165. data/lib/rbs/annotate/rdoc_source.rb +131 -0
  166. data/lib/rbs/annotate.rb +8 -0
  167. data/lib/rbs/ast/annotation.rb +29 -0
  168. data/lib/rbs/ast/comment.rb +29 -0
  169. data/lib/rbs/ast/declarations.rb +472 -0
  170. data/lib/rbs/ast/directives.rb +49 -0
  171. data/lib/rbs/ast/members.rb +451 -0
  172. data/lib/rbs/ast/ruby/annotations.rb +451 -0
  173. data/lib/rbs/ast/ruby/comment_block.rb +247 -0
  174. data/lib/rbs/ast/ruby/declarations.rb +291 -0
  175. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  176. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  177. data/lib/rbs/ast/ruby/members.rb +762 -0
  178. data/lib/rbs/ast/type_param.rb +235 -0
  179. data/lib/rbs/ast/visitor.rb +137 -0
  180. data/lib/rbs/buffer.rb +189 -0
  181. data/lib/rbs/builtin_names.rb +58 -0
  182. data/lib/rbs/cli/colored_io.rb +48 -0
  183. data/lib/rbs/cli/diff.rb +84 -0
  184. data/lib/rbs/cli/validate.rb +294 -0
  185. data/lib/rbs/cli.rb +1253 -0
  186. data/lib/rbs/collection/cleaner.rb +38 -0
  187. data/lib/rbs/collection/config/lockfile.rb +92 -0
  188. data/lib/rbs/collection/config/lockfile_generator.rb +269 -0
  189. data/lib/rbs/collection/config.rb +81 -0
  190. data/lib/rbs/collection/installer.rb +32 -0
  191. data/lib/rbs/collection/sources/base.rb +14 -0
  192. data/lib/rbs/collection/sources/git.rb +265 -0
  193. data/lib/rbs/collection/sources/local.rb +81 -0
  194. data/lib/rbs/collection/sources/rubygems.rb +48 -0
  195. data/lib/rbs/collection/sources/stdlib.rb +50 -0
  196. data/lib/rbs/collection/sources.rb +38 -0
  197. data/lib/rbs/collection.rb +16 -0
  198. data/lib/rbs/constant.rb +28 -0
  199. data/lib/rbs/definition.rb +415 -0
  200. data/lib/rbs/definition_builder/ancestor_builder.rb +678 -0
  201. data/lib/rbs/definition_builder/method_builder.rb +295 -0
  202. data/lib/rbs/definition_builder.rb +1054 -0
  203. data/lib/rbs/diff.rb +131 -0
  204. data/lib/rbs/environment/class_entry.rb +69 -0
  205. data/lib/rbs/environment/module_entry.rb +66 -0
  206. data/lib/rbs/environment/use_map.rb +77 -0
  207. data/lib/rbs/environment.rb +1028 -0
  208. data/lib/rbs/environment_loader.rb +167 -0
  209. data/lib/rbs/environment_walker.rb +155 -0
  210. data/lib/rbs/errors.rb +634 -0
  211. data/lib/rbs/factory.rb +18 -0
  212. data/lib/rbs/file_finder.rb +28 -0
  213. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  214. data/lib/rbs/inline_parser.rb +568 -0
  215. data/lib/rbs/location_aux.rb +170 -0
  216. data/lib/rbs/locator.rb +247 -0
  217. data/lib/rbs/method_type.rb +145 -0
  218. data/lib/rbs/namespace.rb +154 -0
  219. data/lib/rbs/parser/lex_result.rb +15 -0
  220. data/lib/rbs/parser/token.rb +23 -0
  221. data/lib/rbs/parser_aux.rb +142 -0
  222. data/lib/rbs/prototype/helpers.rb +197 -0
  223. data/lib/rbs/prototype/node_usage.rb +99 -0
  224. data/lib/rbs/prototype/rb.rb +816 -0
  225. data/lib/rbs/prototype/rbi.rb +625 -0
  226. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  227. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  228. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  229. data/lib/rbs/prototype/runtime.rb +680 -0
  230. data/lib/rbs/repository.rb +127 -0
  231. data/lib/rbs/resolver/constant_resolver.rb +219 -0
  232. data/lib/rbs/resolver/type_name_resolver.rb +167 -0
  233. data/lib/rbs/rewriter.rb +70 -0
  234. data/lib/rbs/sorter.rb +198 -0
  235. data/lib/rbs/source.rb +99 -0
  236. data/lib/rbs/substitution.rb +83 -0
  237. data/lib/rbs/subtractor.rb +204 -0
  238. data/lib/rbs/test/errors.rb +80 -0
  239. data/lib/rbs/test/guaranteed.rb +30 -0
  240. data/lib/rbs/test/hook.rb +212 -0
  241. data/lib/rbs/test/observer.rb +19 -0
  242. data/lib/rbs/test/setup.rb +84 -0
  243. data/lib/rbs/test/setup_helper.rb +50 -0
  244. data/lib/rbs/test/tester.rb +167 -0
  245. data/lib/rbs/test/type_check.rb +457 -0
  246. data/lib/rbs/test.rb +112 -0
  247. data/lib/rbs/type_alias_dependency.rb +100 -0
  248. data/lib/rbs/type_alias_regularity.rb +126 -0
  249. data/lib/rbs/type_name.rb +122 -0
  250. data/lib/rbs/types.rb +1604 -0
  251. data/lib/rbs/unit_test/convertibles.rb +177 -0
  252. data/lib/rbs/unit_test/spy.rb +138 -0
  253. data/lib/rbs/unit_test/type_assertions.rb +383 -0
  254. data/lib/rbs/unit_test/with_aliases.rb +145 -0
  255. data/lib/rbs/unit_test.rb +6 -0
  256. data/lib/rbs/validator.rb +186 -0
  257. data/lib/rbs/variance_calculator.rb +189 -0
  258. data/lib/rbs/vendorer.rb +71 -0
  259. data/lib/rbs/version.rb +5 -0
  260. data/lib/rbs/wasm/deserializer.rb +213 -0
  261. data/lib/rbs/wasm/jars/asm-analysis.jar +0 -0
  262. data/lib/rbs/wasm/jars/asm-commons.jar +0 -0
  263. data/lib/rbs/wasm/jars/asm-tree.jar +0 -0
  264. data/lib/rbs/wasm/jars/asm-util.jar +0 -0
  265. data/lib/rbs/wasm/jars/asm.jar +0 -0
  266. data/lib/rbs/wasm/jars/compiler.jar +0 -0
  267. data/lib/rbs/wasm/jars/log.jar +0 -0
  268. data/lib/rbs/wasm/jars/runtime.jar +0 -0
  269. data/lib/rbs/wasm/jars/wasi.jar +0 -0
  270. data/lib/rbs/wasm/jars/wasm.jar +0 -0
  271. data/lib/rbs/wasm/location.rb +61 -0
  272. data/lib/rbs/wasm/parser.rb +137 -0
  273. data/lib/rbs/wasm/rbs_parser.wasm +0 -0
  274. data/lib/rbs/wasm/runtime.rb +217 -0
  275. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  276. data/lib/rbs/writer.rb +424 -0
  277. data/lib/rbs.rb +117 -0
  278. data/lib/rdoc/discover.rb +20 -0
  279. data/lib/rdoc_plugin/parser.rb +163 -0
  280. data/rbs.gemspec +68 -0
  281. data/schema/annotation.json +14 -0
  282. data/schema/comment.json +26 -0
  283. data/schema/decls.json +326 -0
  284. data/schema/function.json +87 -0
  285. data/schema/location.json +56 -0
  286. data/schema/members.json +266 -0
  287. data/schema/methodType.json +50 -0
  288. data/schema/typeParam.json +52 -0
  289. data/schema/types.json +317 -0
  290. data/sig/ancestor_builder.rbs +163 -0
  291. data/sig/ancestor_graph.rbs +60 -0
  292. data/sig/annotate/annotations.rbs +102 -0
  293. data/sig/annotate/formatter.rbs +24 -0
  294. data/sig/annotate/rdoc_annotater.rbs +85 -0
  295. data/sig/annotate/rdoc_source.rbs +32 -0
  296. data/sig/annotation.rbs +27 -0
  297. data/sig/ast/ruby/annotations.rbs +470 -0
  298. data/sig/ast/ruby/comment_block.rbs +127 -0
  299. data/sig/ast/ruby/declarations.rbs +158 -0
  300. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  301. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  302. data/sig/ast/ruby/members.rbs +198 -0
  303. data/sig/buffer.rbs +108 -0
  304. data/sig/builtin_names.rbs +44 -0
  305. data/sig/cli/colored_io.rbs +15 -0
  306. data/sig/cli/diff.rbs +15 -0
  307. data/sig/cli/validate.rbs +47 -0
  308. data/sig/cli.rbs +89 -0
  309. data/sig/collection/cleaner.rbs +13 -0
  310. data/sig/collection/config/lockfile.rbs +74 -0
  311. data/sig/collection/config/lockfile_generator.rbs +68 -0
  312. data/sig/collection/config.rbs +46 -0
  313. data/sig/collection/installer.rbs +17 -0
  314. data/sig/collection/sources.rbs +214 -0
  315. data/sig/collection.rbs +4 -0
  316. data/sig/comment.rbs +26 -0
  317. data/sig/constant.rbs +21 -0
  318. data/sig/declarations.rbs +274 -0
  319. data/sig/definition.rbs +232 -0
  320. data/sig/definition_builder.rbs +181 -0
  321. data/sig/diff.rbs +28 -0
  322. data/sig/directives.rbs +77 -0
  323. data/sig/environment/class_entry.rbs +50 -0
  324. data/sig/environment/module_entry.rbs +50 -0
  325. data/sig/environment.rbs +286 -0
  326. data/sig/environment_loader.rbs +111 -0
  327. data/sig/environment_walker.rbs +65 -0
  328. data/sig/errors.rbs +408 -0
  329. data/sig/factory.rbs +5 -0
  330. data/sig/file_finder.rbs +28 -0
  331. data/sig/inline_parser/comment_association.rbs +71 -0
  332. data/sig/inline_parser.rbs +126 -0
  333. data/sig/location.rbs +135 -0
  334. data/sig/locator.rbs +56 -0
  335. data/sig/manifest.yaml +5 -0
  336. data/sig/members.rbs +258 -0
  337. data/sig/method_builder.rbs +89 -0
  338. data/sig/method_types.rbs +58 -0
  339. data/sig/namespace.rbs +161 -0
  340. data/sig/parser.rbs +164 -0
  341. data/sig/prototype/helpers.rbs +29 -0
  342. data/sig/prototype/node_usage.rbs +20 -0
  343. data/sig/prototype/rb.rbs +96 -0
  344. data/sig/prototype/rbi.rbs +75 -0
  345. data/sig/prototype/runtime.rbs +182 -0
  346. data/sig/rbs.rbs +21 -0
  347. data/sig/rdoc/rbs.rbs +67 -0
  348. data/sig/repository.rbs +85 -0
  349. data/sig/resolver/constant_resolver.rbs +92 -0
  350. data/sig/resolver/context.rbs +34 -0
  351. data/sig/resolver/type_name_resolver.rbs +61 -0
  352. data/sig/rewriter.rbs +45 -0
  353. data/sig/shims/bundler.rbs +38 -0
  354. data/sig/shims/enumerable.rbs +5 -0
  355. data/sig/shims/rubygems.rbs +19 -0
  356. data/sig/sorter.rbs +41 -0
  357. data/sig/source.rbs +48 -0
  358. data/sig/substitution.rbs +48 -0
  359. data/sig/subtractor.rbs +37 -0
  360. data/sig/test/errors.rbs +52 -0
  361. data/sig/test/guranteed.rbs +9 -0
  362. data/sig/test/type_check.rbs +19 -0
  363. data/sig/test.rbs +82 -0
  364. data/sig/type_alias_dependency.rbs +53 -0
  365. data/sig/type_alias_regularity.rbs +98 -0
  366. data/sig/type_param.rbs +115 -0
  367. data/sig/typename.rbs +89 -0
  368. data/sig/types.rbs +578 -0
  369. data/sig/unit_test/convertibles.rbs +154 -0
  370. data/sig/unit_test/spy.rbs +22 -0
  371. data/sig/unit_test/type_assertions.rbs +211 -0
  372. data/sig/unit_test/with_aliases.rbs +136 -0
  373. data/sig/use_map.rbs +35 -0
  374. data/sig/util.rbs +9 -0
  375. data/sig/validator.rbs +63 -0
  376. data/sig/variance_calculator.rbs +87 -0
  377. data/sig/vendorer.rbs +51 -0
  378. data/sig/version.rbs +3 -0
  379. data/sig/visitor.rbs +47 -0
  380. data/sig/wasm/deserializer.rbs +66 -0
  381. data/sig/wasm/serialization_schema.rbs +13 -0
  382. data/sig/writer.rbs +127 -0
  383. data/src/ast.c +1628 -0
  384. data/src/lexer.c +3217 -0
  385. data/src/lexer.re +155 -0
  386. data/src/lexstate.c +217 -0
  387. data/src/location.c +31 -0
  388. data/src/parser.c +4255 -0
  389. data/src/serialize.c +958 -0
  390. data/src/string.c +41 -0
  391. data/src/util/rbs_allocator.c +162 -0
  392. data/src/util/rbs_assert.c +19 -0
  393. data/src/util/rbs_buffer.c +54 -0
  394. data/src/util/rbs_constant_pool.c +268 -0
  395. data/src/util/rbs_encoding.c +21308 -0
  396. data/src/util/rbs_unescape.c +167 -0
  397. data/stdlib/abbrev/0/abbrev.rbs +66 -0
  398. data/stdlib/abbrev/0/array.rbs +26 -0
  399. data/stdlib/base64/0/base64.rbs +355 -0
  400. data/stdlib/benchmark/0/benchmark.rbs +452 -0
  401. data/stdlib/bigdecimal/0/big_decimal.rbs +1647 -0
  402. data/stdlib/bigdecimal-math/0/big_math.rbs +280 -0
  403. data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
  404. data/stdlib/cgi/0/core.rbs +911 -0
  405. data/stdlib/cgi/0/manifest.yaml +4 -0
  406. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  407. data/stdlib/coverage/0/coverage.rbs +266 -0
  408. data/stdlib/csv/0/csv.rbs +3776 -0
  409. data/stdlib/csv/0/manifest.yaml +3 -0
  410. data/stdlib/date/0/date.rbs +1598 -0
  411. data/stdlib/date/0/date_time.rbs +617 -0
  412. data/stdlib/date/0/time.rbs +26 -0
  413. data/stdlib/dbm/0/dbm.rbs +421 -0
  414. data/stdlib/delegate/0/delegator.rbs +187 -0
  415. data/stdlib/delegate/0/kernel.rbs +47 -0
  416. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  417. data/stdlib/did_you_mean/0/did_you_mean.rbs +344 -0
  418. data/stdlib/digest/0/digest.rbs +687 -0
  419. data/stdlib/erb/0/erb.rbs +933 -0
  420. data/stdlib/etc/0/etc.rbs +884 -0
  421. data/stdlib/fileutils/0/fileutils.rbs +1753 -0
  422. data/stdlib/find/0/find.rbs +49 -0
  423. data/stdlib/forwardable/0/forwardable.rbs +271 -0
  424. data/stdlib/io-console/0/io-console.rbs +414 -0
  425. data/stdlib/ipaddr/0/ipaddr.rbs +436 -0
  426. data/stdlib/json/0/json.rbs +1963 -0
  427. data/stdlib/kconv/0/kconv.rbs +166 -0
  428. data/stdlib/logger/0/formatter.rbs +45 -0
  429. data/stdlib/logger/0/log_device.rbs +100 -0
  430. data/stdlib/logger/0/logger.rbs +796 -0
  431. data/stdlib/logger/0/manifest.yaml +2 -0
  432. data/stdlib/logger/0/period.rbs +17 -0
  433. data/stdlib/logger/0/severity.rbs +34 -0
  434. data/stdlib/minitest/0/kernel.rbs +42 -0
  435. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
  436. data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
  437. data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
  438. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
  439. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  440. data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
  441. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  442. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  443. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  444. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  445. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  446. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  447. data/stdlib/minitest/0/minitest/mock.rbs +64 -0
  448. data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
  449. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
  450. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  451. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  452. data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
  453. data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
  454. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  455. data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
  456. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  457. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  458. data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
  459. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  460. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  461. data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
  462. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  463. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
  464. data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
  465. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  466. data/stdlib/minitest/0/minitest/test.rbs +69 -0
  467. data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
  468. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  469. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  470. data/stdlib/minitest/0/minitest/unit.rbs +4 -0
  471. data/stdlib/minitest/0/minitest.rbs +115 -0
  472. data/stdlib/monitor/0/monitor.rbs +363 -0
  473. data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
  474. data/stdlib/net-http/0/manifest.yaml +3 -0
  475. data/stdlib/net-http/0/net-http.rbs +5580 -0
  476. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  477. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  478. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  479. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  480. data/stdlib/nkf/0/nkf.rbs +402 -0
  481. data/stdlib/objspace/0/objspace.rbs +470 -0
  482. data/stdlib/observable/0/observable.rbs +217 -0
  483. data/stdlib/open-uri/0/manifest.yaml +4 -0
  484. data/stdlib/open-uri/0/open-uri.rbs +433 -0
  485. data/stdlib/open3/0/open3.rbs +606 -0
  486. data/stdlib/openssl/0/manifest.yaml +3 -0
  487. data/stdlib/openssl/0/openssl.rbs +12231 -0
  488. data/stdlib/optparse/0/optparse.rbs +1734 -0
  489. data/stdlib/pathname/0/pathname.rbs +36 -0
  490. data/stdlib/pp/0/manifest.yaml +2 -0
  491. data/stdlib/pp/0/pp.rbs +301 -0
  492. data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
  493. data/stdlib/pstore/0/pstore.rbs +608 -0
  494. data/stdlib/psych/0/core_ext.rbs +12 -0
  495. data/stdlib/psych/0/dbm.rbs +237 -0
  496. data/stdlib/psych/0/manifest.yaml +3 -0
  497. data/stdlib/psych/0/psych.rbs +455 -0
  498. data/stdlib/psych/0/store.rbs +57 -0
  499. data/stdlib/pty/0/pty.rbs +240 -0
  500. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  501. data/stdlib/rdoc/0/code_object.rbs +52 -0
  502. data/stdlib/rdoc/0/comment.rbs +61 -0
  503. data/stdlib/rdoc/0/context.rbs +153 -0
  504. data/stdlib/rdoc/0/markup.rbs +117 -0
  505. data/stdlib/rdoc/0/options.rbs +76 -0
  506. data/stdlib/rdoc/0/parser.rbs +56 -0
  507. data/stdlib/rdoc/0/rdoc.rbs +393 -0
  508. data/stdlib/rdoc/0/ri.rbs +17 -0
  509. data/stdlib/rdoc/0/store.rbs +48 -0
  510. data/stdlib/rdoc/0/top_level.rbs +97 -0
  511. data/stdlib/resolv/0/manifest.yaml +3 -0
  512. data/stdlib/resolv/0/resolv.rbs +1787 -0
  513. data/stdlib/ripper/0/ripper.rbs +1654 -0
  514. data/stdlib/securerandom/0/manifest.yaml +2 -0
  515. data/stdlib/securerandom/0/securerandom.rbs +49 -0
  516. data/stdlib/shellwords/0/shellwords.rbs +229 -0
  517. data/stdlib/singleton/0/singleton.rbs +134 -0
  518. data/stdlib/socket/0/addrinfo.rbs +666 -0
  519. data/stdlib/socket/0/basic_socket.rbs +590 -0
  520. data/stdlib/socket/0/constants.rbs +2295 -0
  521. data/stdlib/socket/0/ip_socket.rbs +94 -0
  522. data/stdlib/socket/0/socket.rbs +4170 -0
  523. data/stdlib/socket/0/socket_error.rbs +5 -0
  524. data/stdlib/socket/0/tcp_server.rbs +192 -0
  525. data/stdlib/socket/0/tcp_socket.rbs +87 -0
  526. data/stdlib/socket/0/udp_socket.rbs +133 -0
  527. data/stdlib/socket/0/unix_server.rbs +169 -0
  528. data/stdlib/socket/0/unix_socket.rbs +172 -0
  529. data/stdlib/stringio/0/stringio.rbs +1681 -0
  530. data/stdlib/strscan/0/string_scanner.rbs +1648 -0
  531. data/stdlib/tempfile/0/tempfile.rbs +483 -0
  532. data/stdlib/time/0/time.rbs +434 -0
  533. data/stdlib/timeout/0/timeout.rbs +137 -0
  534. data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
  535. data/stdlib/tsort/0/cyclic.rbs +8 -0
  536. data/stdlib/tsort/0/interfaces.rbs +20 -0
  537. data/stdlib/tsort/0/tsort.rbs +410 -0
  538. data/stdlib/uri/0/common.rbs +621 -0
  539. data/stdlib/uri/0/file.rbs +118 -0
  540. data/stdlib/uri/0/ftp.rbs +13 -0
  541. data/stdlib/uri/0/generic.rbs +1116 -0
  542. data/stdlib/uri/0/http.rbs +104 -0
  543. data/stdlib/uri/0/https.rbs +14 -0
  544. data/stdlib/uri/0/ldap.rbs +230 -0
  545. data/stdlib/uri/0/ldaps.rbs +14 -0
  546. data/stdlib/uri/0/mailto.rbs +92 -0
  547. data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
  548. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  549. data/stdlib/uri/0/ws.rbs +13 -0
  550. data/stdlib/uri/0/wss.rbs +9 -0
  551. data/stdlib/yaml/0/manifest.yaml +2 -0
  552. data/stdlib/yaml/0/yaml.rbs +1 -0
  553. data/stdlib/zlib/0/buf_error.rbs +10 -0
  554. data/stdlib/zlib/0/data_error.rbs +10 -0
  555. data/stdlib/zlib/0/deflate.rbs +211 -0
  556. data/stdlib/zlib/0/error.rbs +20 -0
  557. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  558. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  559. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  560. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  561. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  562. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  563. data/stdlib/zlib/0/gzip_writer.rbs +168 -0
  564. data/stdlib/zlib/0/inflate.rbs +180 -0
  565. data/stdlib/zlib/0/mem_error.rbs +10 -0
  566. data/stdlib/zlib/0/need_dict.rbs +13 -0
  567. data/stdlib/zlib/0/stream_end.rbs +11 -0
  568. data/stdlib/zlib/0/stream_error.rbs +11 -0
  569. data/stdlib/zlib/0/version_error.rbs +11 -0
  570. data/stdlib/zlib/0/zlib.rbs +449 -0
  571. data/stdlib/zlib/0/zstream.rbs +201 -0
  572. data/wasm/README.md +59 -0
  573. data/wasm/rbs_wasm.c +411 -0
  574. metadata +660 -0
@@ -0,0 +1,1681 @@
1
+ # <!-- rdoc-file=ext/stringio/stringio.c -->
2
+ # Class StringIO supports accessing a string as a stream,
3
+ # similar in some ways to [class
4
+ # IO](https://docs.ruby-lang.org/en/master/IO.html).
5
+ # You can create a StringIO instance using:
6
+ # * StringIO.new: returns a new StringIO object containing the given string.
7
+ # * StringIO.open: passes a new StringIO object to the given block.
8
+ # Like an IO stream, a StringIO stream has certain properties:
9
+ # * <strong>Read/write mode</strong>: whether the stream may be read, written,
10
+ # appended to, etc.;
11
+ # see [Read/Write Mode](rdoc-ref:StringIO@Read-2FWrite+Mode).
12
+ # * **Data mode**: text-only or binary;
13
+ # see [Data Mode](rdoc-ref:StringIO@Data+Mode).
14
+ # * **Encodings**: internal and external encodings;
15
+ # see [Encodings](rdoc-ref:StringIO@Encodings).
16
+ # * **Position**: where in the stream the next read or write is to occur;
17
+ # see [Position](rdoc-ref:StringIO@Position).
18
+ # * **Line number**: a special, line-oriented, "position" (different from the
19
+ # position mentioned above);
20
+ # see [Line Number](rdoc-ref:StringIO@Line+Number).
21
+ # * <strong>Open/closed</strong>: whether the stream is open or closed, for
22
+ # reading or writing.
23
+ # see [Open/Closed Streams](rdoc-ref:StringIO@Open-2FClosed+Streams).
24
+ # * **BOM**: byte mark order;
25
+ # see [Byte Order Mark](rdoc-ref:StringIO@BOM+-28Byte+Order+Mark-29).
26
+ # ## About the Examples
27
+ # Examples on this page assume that StringIO has been required:
28
+ # require 'stringio'
29
+ #
30
+ # And that this constant has been defined:
31
+ # TEXT = <<EOT
32
+ # First line
33
+ # Second line
34
+ #
35
+ # Fourth line
36
+ # Fifth line
37
+ # EOT
38
+ #
39
+ # ## Stream Properties
40
+ # ### Read/Write Mode
41
+ # #### Summary
42
+ # Mode |Initial Clear?| Read | Write
43
+ # ------------------------------|--------------|--------|--------
44
+ # <code>'r'</code>: read-only | No |Anywhere| Error
45
+ # <code>'w'</code>: write-only | Yes | Error |Anywhere
46
+ # <code>'a'</code>: append-only | No | Error |End only
47
+ # <code>'r+'</code>: read/write | No |Anywhere|Anywhere
48
+ # <code>'w+'</code>: read-write | Yes |Anywhere|Anywhere
49
+ # <code>'a+'</code>: read/append| No |Anywhere|End only
50
+ # Each section below describes a read/write mode.
51
+ # Any of the modes may be given as a string or as file constants;
52
+ # example:
53
+ # strio = StringIO.new('foo', 'a')
54
+ # strio = StringIO.new('foo', File::WRONLY | File::APPEND)
55
+ #
56
+ # #### <code>'r'</code>: Read-Only
57
+ # Mode specified as one of:
58
+ # * String: <code>'r'</code>.
59
+ # * Constant: <code>File::RDONLY</code>.
60
+ # Initial state:
61
+ # strio = StringIO.new('foobarbaz', 'r')
62
+ # strio.pos # => 0 # Beginning-of-stream.
63
+ # strio.string # => "foobarbaz" # Not cleared.
64
+ #
65
+ # May be read anywhere:
66
+ # strio.gets(3) # => "foo"
67
+ # strio.gets(3) # => "bar"
68
+ # strio.pos = 9
69
+ # strio.gets(3) # => nil
70
+ #
71
+ # May not be written:
72
+ # strio.write('foo') # Raises IOError: not opened for writing
73
+ #
74
+ # #### <code>'w'</code>: Write-Only
75
+ # Mode specified as one of:
76
+ # * String: <code>'w'</code>.
77
+ # * Constant: <code>File::WRONLY</code>.
78
+ # Initial state:
79
+ # strio = StringIO.new('foo', 'w')
80
+ # strio.pos # => 0 # Beginning of stream.
81
+ # strio.string # => "" # Initially cleared.
82
+ #
83
+ # May be written anywhere (even past end-of-stream):
84
+ # strio.write('foobar')
85
+ # strio.string # => "foobar"
86
+ # strio.rewind
87
+ # strio.write('FOO')
88
+ # strio.string # => "FOObar"
89
+ # strio.pos = 3
90
+ # strio.write('BAR')
91
+ # strio.string # => "FOOBAR"
92
+ # strio.pos = 9
93
+ # strio.write('baz')
94
+ # strio.string # => "FOOBAR\u0000\u0000\u0000baz" # Null-padded.
95
+ #
96
+ # May not be read:
97
+ # strio.read # Raises IOError: not opened for reading
98
+ #
99
+ # #### <code>'a'</code>: Append-Only
100
+ # Mode specified as one of:
101
+ # * String: <code>'a'</code>.
102
+ # * Constant: <code>File::WRONLY | File::APPEND</code>.
103
+ # Initial state:
104
+ # strio = StringIO.new('foo', 'a')
105
+ # strio.pos # => 0 # Beginning-of-stream.
106
+ # strio.string # => "foo" # Not cleared.
107
+ #
108
+ # May be written only at the end; position does not affect writing:
109
+ # strio.write('bar')
110
+ # strio.string # => "foobar"
111
+ # strio.write('baz')
112
+ # strio.string # => "foobarbaz"
113
+ # strio.pos = 400
114
+ # strio.write('bat')
115
+ # strio.string # => "foobarbazbat"
116
+ #
117
+ # May not be read:
118
+ # strio.gets # Raises IOError: not opened for reading
119
+ #
120
+ # #### <code>'r+'</code>: Read/Write
121
+ # Mode specified as one of:
122
+ # * String: <code>'r+'</code>.
123
+ # * Constant: <code>File::RDRW</code>.
124
+ # Initial state:
125
+ # strio = StringIO.new('foobar', 'r+')
126
+ # strio.pos # => 0 # Beginning-of-stream.
127
+ # strio.string # => "foobar" # Not cleared.
128
+ #
129
+ # May be written anywhere (even past end-of-stream):
130
+ # strio.write('FOO')
131
+ # strio.string # => "FOObar"
132
+ # strio.write('BAR')
133
+ # strio.string # => "FOOBAR"
134
+ # strio.write('BAZ')
135
+ # strio.string # => "FOOBARBAZ"
136
+ # strio.pos = 12
137
+ # strio.write('BAT')
138
+ # strio.string # => "FOOBARBAZ\u0000\u0000\u0000BAT" # Null padded.
139
+ #
140
+ # May be read anywhere:
141
+ # strio.pos = 0
142
+ # strio.gets(3) # => "FOO"
143
+ # strio.pos = 6
144
+ # strio.gets(3) # => "BAZ"
145
+ # strio.pos = 400
146
+ # strio.gets(3) # => nil
147
+ #
148
+ # #### <code>'w+'</code>: Read/Write (Initially Clear)
149
+ # Mode specified as one of:
150
+ # * String: <code>'w+'</code>.
151
+ # * Constant: <code>File::RDWR | File::TRUNC</code>.
152
+ # Initial state:
153
+ # strio = StringIO.new('foo', 'w+')
154
+ # strio.pos # => 0 # Beginning-of-stream.
155
+ # strio.string # => "" # Truncated.
156
+ #
157
+ # May be written anywhere (even past end-of-stream):
158
+ # strio.write('foobar')
159
+ # strio.string # => "foobar"
160
+ # strio.rewind
161
+ # strio.write('FOO')
162
+ # strio.string # => "FOObar"
163
+ # strio.write('BAR')
164
+ # strio.string # => "FOOBAR"
165
+ # strio.write('BAZ')
166
+ # strio.string # => "FOOBARBAZ"
167
+ # strio.pos = 12
168
+ # strio.write('BAT')
169
+ # strio.string # => "FOOBARBAZ\u0000\u0000\u0000BAT" # Null-padded.
170
+ #
171
+ # May be read anywhere:
172
+ # strio.rewind
173
+ # strio.gets(3) # => "FOO"
174
+ # strio.gets(3) # => "BAR"
175
+ # strio.pos = 12
176
+ # strio.gets(3) # => "BAT"
177
+ # strio.pos = 400
178
+ # strio.gets(3) # => nil
179
+ #
180
+ # #### <code>'a+'</code>: Read/Append
181
+ # Mode specified as one of:
182
+ # * String: <code>'a+'</code>.
183
+ # * Constant: <code>File::RDWR | File::APPEND</code>.
184
+ # Initial state:
185
+ # strio = StringIO.new('foo', 'a+')
186
+ # strio.pos # => 0 # Beginning-of-stream.
187
+ # strio.string # => "foo" # Not cleared.
188
+ #
189
+ # May be written only at the end; #rewind; position does not affect writing:
190
+ # strio.write('bar')
191
+ # strio.string # => "foobar"
192
+ # strio.write('baz')
193
+ # strio.string # => "foobarbaz"
194
+ # strio.pos = 400
195
+ # strio.write('bat')
196
+ # strio.string # => "foobarbazbat"
197
+ #
198
+ # May be read anywhere:
199
+ # strio.rewind
200
+ # strio.gets(3) # => "foo"
201
+ # strio.gets(3) # => "bar"
202
+ # strio.pos = 9
203
+ # strio.gets(3) # => "bat"
204
+ # strio.pos = 400
205
+ # strio.gets(3) # => nil
206
+ #
207
+ # ### Data Mode
208
+ # To specify whether the stream is to be treated as text or as binary data,
209
+ # either of the following may be suffixed to any of the string read/write modes
210
+ # above:
211
+ # * <code>'t'</code>: Text;
212
+ # initializes the encoding as Encoding::UTF_8.
213
+ # * <code>'b'</code>: Binary;
214
+ # initializes the encoding as Encoding::ASCII_8BIT.
215
+ # If neither is given, the stream defaults to text data.
216
+ # Examples:
217
+ # strio = StringIO.new('foo', 'rt')
218
+ # strio.external_encoding # => #<Encoding:UTF-8>
219
+ # data = "\u9990\u9991\u9992\u9993\u9994"
220
+ # strio = StringIO.new(data, 'rb')
221
+ # strio.external_encoding # => #<Encoding:BINARY (ASCII-8BIT)>
222
+ #
223
+ # When the data mode is specified, the read/write mode may not be omitted:
224
+ # StringIO.new(data, 'b') # Raises ArgumentError: invalid access mode b
225
+ #
226
+ # A text stream may be changed to binary by calling instance method #binmode;
227
+ # a binary stream may not be changed to text.
228
+ # ### Encodings
229
+ # A stream has an encoding; see
230
+ # [Encodings](https://docs.ruby-lang.org/en/master/language/encodings_rdoc.html)
231
+ # .
232
+ # The initial encoding for a new or re-opened stream depends on its [data
233
+ # mode](rdoc-ref:StringIO@Data+Mode):
234
+ # * Text: <code>Encoding::UTF_8</code>.
235
+ # * Binary: <code>Encoding::ASCII_8BIT</code>.
236
+ # These instance methods are relevant:
237
+ # * #external_encoding: returns the current encoding of the stream as an
238
+ # `Encoding` object.
239
+ # * #internal_encoding: returns +nil+; a stream does not have an internal
240
+ # encoding.
241
+ # * #set_encoding: sets the encoding for the stream.
242
+ # * #set_encoding_by_bom: sets the encoding for the stream to the stream's BOM
243
+ # (byte order mark).
244
+ # Examples:
245
+ # strio = StringIO.new('foo', 'rt') # Text mode.
246
+ # strio.external_encoding # => #<Encoding:UTF-8>
247
+ # data = "\u9990\u9991\u9992\u9993\u9994"
248
+ # strio = StringIO.new(data, 'rb') # Binary mode.
249
+ # strio.external_encoding # => #<Encoding:BINARY (ASCII-8BIT)>
250
+ # strio = StringIO.new('foo')
251
+ # strio.external_encoding # => #<Encoding:UTF-8>
252
+ # strio.set_encoding('US-ASCII')
253
+ # strio.external_encoding # => #<Encoding:US-ASCII>
254
+ #
255
+ # ### Position
256
+ # A stream has a *position*, and integer offset (in bytes) into the stream.
257
+ # The initial position of a stream is zero.
258
+ # #### Getting and Setting the Position
259
+ # Each of these methods initializes (to zero) the position of a new or re-opened
260
+ # stream:
261
+ # * ::new: returns a new stream.
262
+ # * ::open: passes a new stream to the block.
263
+ # * #reopen: re-initializes the stream.
264
+ # Each of these methods queries, gets, or sets the position, without otherwise
265
+ # changing the stream:
266
+ # * #eof?: returns whether the position is at end-of-stream.
267
+ # * #pos: returns the position.
268
+ # * #pos=: sets the position.
269
+ # * #rewind: sets the position to zero.
270
+ # * #seek: sets the position.
271
+ # Examples:
272
+ # strio = StringIO.new('foobar')
273
+ # strio.pos # => 0
274
+ # strio.pos = 3
275
+ # strio.pos # => 3
276
+ # strio.eof? # => false
277
+ # strio.rewind
278
+ # strio.pos # => 0
279
+ # strio.seek(0, IO::SEEK_END)
280
+ # strio.pos # => 6
281
+ # strio.eof? # => true
282
+ #
283
+ # #### Position Before and After Reading
284
+ # Except for #pread, a stream reading method (see [Basic
285
+ # Reading](rdoc-ref:StringIO@Basic+Reading))
286
+ # begins reading at the current position.
287
+ # Except for #pread, a read method advances the position past the read
288
+ # substring.
289
+ # Examples:
290
+ # strio = StringIO.new(TEXT)
291
+ # strio.string # => "First line\nSecond line\n\nFourth line\nFifth line\n"
292
+ # strio.pos # => 0
293
+ # strio.getc # => "F"
294
+ # strio.pos # => 1
295
+ # strio.gets # => "irst line\n"
296
+ # strio.pos # => 11
297
+ # strio.pos = 24
298
+ # strio.gets # => "Fourth line\n"
299
+ # strio.pos # => 36
300
+ #
301
+ # strio = StringIO.new('тест') # Four 2-byte characters.
302
+ # strio.pos = 0 # At first byte of first character.
303
+ # strio.read # => "тест"
304
+ # strio.pos = 1 # At second byte of first character.
305
+ # strio.read # => "\x82ест"
306
+ # strio.pos = 2 # At first of second character.
307
+ # strio.read # => "ест"
308
+ #
309
+ # strio = StringIO.new(TEXT)
310
+ # strio.pos = 15
311
+ # a = []
312
+ # strio.each_line {|line| a.push(line) }
313
+ # a # => ["nd line\n", "\n", "Fourth line\n", "Fifth line\n"]
314
+ # strio.pos # => 47 ## End-of-stream.
315
+ #
316
+ # #### Position Before and After Writing
317
+ # Each of these methods begins writing at the current position,
318
+ # and advances the position to the end of the written substring:
319
+ # * #putc: writes the given character.
320
+ # * #write: writes the given objects as strings.
321
+ # * [Kernel#puts](https://docs.ruby-lang.org/en/master/Kernel.html#method-i-pu
322
+ # ts): writes given objects as strings, each followed by newline.
323
+ # Examples:
324
+ # strio = StringIO.new('foo')
325
+ # strio.pos # => 0
326
+ # strio.putc('b')
327
+ # strio.string # => "boo"
328
+ # strio.pos # => 1
329
+ # strio.write('r')
330
+ # strio.string # => "bro"
331
+ # strio.pos # => 2
332
+ # strio.puts('ew')
333
+ # strio.string # => "brew\n"
334
+ # strio.pos # => 5
335
+ # strio.pos = 8
336
+ # strio.write('foo')
337
+ # strio.string # => "brew\n\u0000\u0000\u0000foo"
338
+ # strio.pos # => 11
339
+ #
340
+ # Each of these methods writes *before* the current position, and decrements the
341
+ # position
342
+ # so that the written data is next to be read:
343
+ # * #ungetbyte: unshifts the given byte.
344
+ # * #ungetc: unshifts the given character.
345
+ # Examples:
346
+ # strio = StringIO.new('foo')
347
+ # strio.pos = 2
348
+ # strio.ungetc('x')
349
+ # strio.pos # => 1
350
+ # strio.string # => "fxo"
351
+ # strio.ungetc('x')
352
+ # strio.pos # => 0
353
+ # strio.string # => "xxo"
354
+ #
355
+ # This method does not affect the position:
356
+ # * #truncate: truncates the stream's string to the given size.
357
+ # Examples:
358
+ # strio = StringIO.new('foobar')
359
+ # strio.pos # => 0
360
+ # strio.truncate(3)
361
+ # strio.string # => "foo"
362
+ # strio.pos # => 0
363
+ # strio.pos = 500
364
+ # strio.truncate(0)
365
+ # strio.string # => ""
366
+ # strio.pos # => 500
367
+ #
368
+ # ### Line Number
369
+ # A stream has a line number, which initially is zero:
370
+ # * Method #lineno returns the line number.
371
+ # * Method #lineno= sets the line number.
372
+ # The line number can be affected by reading (but never by writing);
373
+ # in general, the line number is incremented each time the record separator
374
+ # (default: <code>"\n"</code>) is read.
375
+ # Examples:
376
+ # strio = StringIO.new(TEXT)
377
+ # strio.string # => "First line\nSecond line\n\nFourth line\nFifth line\n"
378
+ # strio.lineno # => 0
379
+ # strio.gets # => "First line\n"
380
+ # strio.lineno # => 1
381
+ # strio.getc # => "S"
382
+ # strio.lineno # => 1
383
+ # strio.gets # => "econd line\n"
384
+ # strio.lineno # => 2
385
+ # strio.gets # => "\n"
386
+ # strio.lineno # => 3
387
+ # strio.gets # => "Fourth line\n"
388
+ # strio.lineno # => 4
389
+ #
390
+ # Setting the position does not affect the line number:
391
+ # strio.pos = 0
392
+ # strio.lineno # => 4
393
+ # strio.gets # => "First line\n"
394
+ # strio.pos # => 11
395
+ # strio.lineno # => 5
396
+ #
397
+ # And setting the line number does not affect the position:
398
+ # strio.lineno = 10
399
+ # strio.pos # => 11
400
+ # strio.gets # => "Second line\n"
401
+ # strio.lineno # => 11
402
+ # strio.pos # => 23
403
+ #
404
+ # ### Open/Closed Streams
405
+ # A new stream is open for either reading or writing, and may be open for both;
406
+ # see [Read/Write Mode](rdoc-ref:StringIO@Read-2FWrite+Mode).
407
+ # Each of these methods initializes the read/write mode for a new or re-opened
408
+ # stream:
409
+ # * ::new: returns a new stream.
410
+ # * ::open: passes a new stream to the block.
411
+ # * #reopen: re-initializes the stream.
412
+ # Other relevant methods:
413
+ # * #close: closes the stream for both reading and writing.
414
+ # * #close_read: closes the stream for reading.
415
+ # * #close_write: closes the stream for writing.
416
+ # * #closed?: returns whether the stream is closed for both reading and
417
+ # writing.
418
+ # * #closed_read?: returns whether the stream is closed for reading.
419
+ # * #closed_write?: returns whether the stream is closed for writing.
420
+ # ### BOM (Byte Order Mark)
421
+ # The string provided for ::new, ::open, or #reopen
422
+ # may contain an optional [BOM](https://en.wikipedia.org/wiki/Byte_order_mark)
423
+ # (byte order mark) at the beginning of the string;
424
+ # the BOM can affect the stream's encoding.
425
+ # The BOM (if provided):
426
+ # * Is stored as part of the stream's string.
427
+ # * Does *not* immediately affect the encoding.
428
+ # * Is *initially* considered part of the stream.
429
+ # utf8_bom = "\xEF\xBB\xBF"
430
+ # string = utf8_bom + 'foo'
431
+ # string.bytes # => [239, 187, 191, 102, 111, 111]
432
+ # strio.string.bytes.take(3) # => [239, 187, 191] # The BOM.
433
+ # strio = StringIO.new(string, 'rb')
434
+ # strio.string.bytes # => [239, 187, 191, 102, 111, 111] # BOM is part of the stored string.
435
+ # strio.external_encoding # => #<Encoding:BINARY (ASCII-8BIT)> # Default for a binary stream.
436
+ # strio.gets # => "\xEF\xBB\xBFfoo" # BOM is part of the stream.
437
+ #
438
+ # You can call instance method #set_encoding_by_bom to "activate" the stored
439
+ # BOM;
440
+ # after doing so the BOM:
441
+ # * Is *still* stored as part of the stream's string.
442
+ # * *Determines* (and may have changed) the stream's encoding.
443
+ # * Is *no longer* considered part of the stream.
444
+ # strio.set_encoding_by_bom
445
+ # strio.string.bytes # => [239, 187, 191, 102, 111, 111] # BOM is still part of the stored string.
446
+ # strio.external_encoding # => #<Encoding:UTF-8> # The new encoding.
447
+ # strio.rewind # => 0
448
+ # strio.gets # => "foo" # BOM is not part of the stream.
449
+ #
450
+ # ## Basic Stream IO
451
+ # ### Basic Reading
452
+ # You can read from the stream using these instance methods:
453
+ # * #getbyte: reads and returns the next byte.
454
+ # * #getc: reads and returns the next character.
455
+ # * #gets: reads and returns all or part of the next line.
456
+ # * #read: reads and returns all or part of the remaining data in the stream.
457
+ # * #readlines: reads the remaining data the stream and returns an array of
458
+ # its lines.
459
+ # * [Kernel#readline](https://docs.ruby-lang.org/en/master/Kernel.html#method-
460
+ # i-readline): like #gets, but raises an exception if at end-of-stream.
461
+ # You can iterate over the stream using these instance methods:
462
+ # * #each_byte: reads each remaining byte, passing it to the block.
463
+ # * #each_char: reads each remaining character, passing it to the block.
464
+ # * #each_codepoint: reads each remaining codepoint, passing it to the block.
465
+ # * #each_line: reads all or part of each remaining line, passing the read
466
+ # string to the block
467
+ # This instance method is useful in a multi-threaded application:
468
+ # * #pread: reads and returns all or part of the stream.
469
+ # ### Basic Writing
470
+ # You can write to the stream, advancing the position, using these instance
471
+ # methods:
472
+ # * #putc: writes a given character.
473
+ # * #write: writes the given objects as strings.
474
+ # * [Kernel#puts](https://docs.ruby-lang.org/en/master/Kernel.html#method-i-pu
475
+ # ts) writes given objects as strings, each followed by newline.
476
+ # You can "unshift" to the stream using these instance methods;
477
+ # each writes *before* the current position, and decrements the position
478
+ # so that the written data is next to be read.
479
+ # * #ungetbyte: unshifts the given byte.
480
+ # * #ungetc: unshifts the given character.
481
+ # One more writing method:
482
+ # * #truncate: truncates the stream's string to the given size.
483
+ # ## Line IO
484
+ # Reading:
485
+ # * #gets: reads and returns the next line.
486
+ # * [Kernel#readline](https://docs.ruby-lang.org/en/master/Kernel.html#method-
487
+ # i-readline): like #gets, but raises an exception if at end-of-stream.
488
+ # * #readlines: reads the remaining data the stream and returns an array of
489
+ # its lines.
490
+ # * #each_line: reads each remaining line, passing it to the block
491
+ # Writing:
492
+ # * [Kernel#puts](https://docs.ruby-lang.org/en/master/Kernel.html#method-i-pu
493
+ # ts): writes given objects, each followed by newline.
494
+ # ## Character IO
495
+ # Reading:
496
+ # * #each_char: reads each remaining character, passing it to the block.
497
+ # * #getc: reads and returns the next character.
498
+ # Writing:
499
+ # * #putc: writes the given character.
500
+ # * #ungetc.: unshifts the given character.
501
+ # ## Byte IO
502
+ # Reading:
503
+ # * #each_byte: reads each remaining byte, passing it to the block.
504
+ # * #getbyte: reads and returns the next byte.
505
+ # Writing:
506
+ # * #ungetbyte: unshifts the given byte.
507
+ # ## Codepoint IO
508
+ # Reading:
509
+ # * #each_codepoint: reads each remaining codepoint, passing it to the block.
510
+ #
511
+ class StringIO
512
+ # <!--
513
+ # rdoc-file=ext/stringio/stringio.c
514
+ # - StringIO.new(string = '', mode = 'r+') -> new_stringio
515
+ # -->
516
+ # Returns a new StringIO instance formed from `string` and `mode`; the instance
517
+ # should be closed when no longer needed:
518
+ #
519
+ # strio = StringIO.new
520
+ # strio.string # => ""
521
+ # strio.closed_read? # => false
522
+ # strio.closed_write? # => false
523
+ # strio.close
524
+ #
525
+ # If `string` is frozen, the default `mode` is <code>'r'</code>:
526
+ #
527
+ # strio = StringIO.new('foo'.freeze)
528
+ # strio.string # => "foo"
529
+ # strio.closed_read? # => false
530
+ # strio.closed_write? # => true
531
+ # strio.close
532
+ #
533
+ # Argument `mode` must be a valid [Access Mode](rdoc-ref:File@Access+Modes),
534
+ # which may be a string or an integer constant:
535
+ #
536
+ # StringIO.new('foo', 'w+')
537
+ # StringIO.new('foo', File::RDONLY)
538
+ #
539
+ # Related: StringIO.open (passes the StringIO object to the block; closes the
540
+ # object automatically on block exit).
541
+ #
542
+ def initialize: (?String string, ?String? mode) -> void
543
+
544
+ # <!--
545
+ # rdoc-file=ext/stringio/stringio.c
546
+ # - StringIO.open(string = '', mode = 'r+') -> new_stringio
547
+ # - StringIO.open(string = '', mode = 'r+') {|strio| ... } -> object
548
+ # -->
549
+ # Creates new StringIO instance by calling <code>StringIO.new(string,
550
+ # mode)</code>.
551
+ #
552
+ # With no block given, returns the new instance:
553
+ #
554
+ # strio = StringIO.open # => #<StringIO>
555
+ #
556
+ # With a block given, calls the block with the new instance and returns the
557
+ # block's value; closes the instance on block exit:
558
+ #
559
+ # StringIO.open('foo') {|strio| strio.string.upcase } # => "FOO"
560
+ #
561
+ # Related: StringIO.new.
562
+ #
563
+ def self.open: (?String string, ?String? mode) -> StringIO
564
+ | [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U
565
+
566
+ def <<: (untyped arg0) -> self
567
+
568
+ # <!--
569
+ # rdoc-file=ext/stringio/stringio.c
570
+ # - binmode -> self
571
+ # -->
572
+ # Sets the data mode in `self` to binary mode; see [Data
573
+ # Mode](rdoc-ref:StringIO@Data+Mode).
574
+ #
575
+ def binmode: () -> self
576
+
577
+ # <!--
578
+ # rdoc-file=ext/stringio/stringio.c
579
+ # - close -> nil
580
+ # -->
581
+ # Closes `self` for both reading and writing; returns `nil`:
582
+ #
583
+ # strio = StringIO.new
584
+ # strio.closed? # => false
585
+ # strio.close # => nil
586
+ # strio.closed? # => true
587
+ # strio.read # Raises IOError: not opened for reading
588
+ # strio.write # Raises IOError: not opened for writing
589
+ #
590
+ # Related: StringIO#close_read, StringIO#close_write, StringIO.closed?.
591
+ #
592
+ def close: () -> nil
593
+
594
+ # <!--
595
+ # rdoc-file=ext/stringio/stringio.c
596
+ # - close_read -> nil
597
+ # -->
598
+ # Closes `self` for reading; closed-write setting remains unchanged; returns
599
+ # `nil`:
600
+ #
601
+ # strio = StringIO.new
602
+ # strio.closed_read? # => false
603
+ # strio.close_read # => nil
604
+ # strio.closed_read? # => true
605
+ # strio.closed_write? # => false
606
+ # strio.read # Raises IOError: not opened for reading
607
+ #
608
+ # Related: StringIO#close, StringIO#close_write.
609
+ #
610
+ def close_read: () -> nil
611
+
612
+ # <!--
613
+ # rdoc-file=ext/stringio/stringio.c
614
+ # - close_write -> nil
615
+ # -->
616
+ # Closes `self` for writing; closed-read setting remains unchanged; returns
617
+ # `nil`:
618
+ #
619
+ # strio = StringIO.new
620
+ # strio.closed_write? # => false
621
+ # strio.close_write # => nil
622
+ # strio.closed_write? # => true
623
+ # strio.closed_read? # => false
624
+ # strio.write('foo') # Raises IOError: not opened for writing
625
+ #
626
+ # Related: StringIO#close, StringIO#close_read, StringIO#closed_write?.
627
+ #
628
+ def close_write: () -> nil
629
+
630
+ # <!--
631
+ # rdoc-file=ext/stringio/stringio.c
632
+ # - closed? -> true or false
633
+ # -->
634
+ # Returns whether `self` is closed for both reading and writing:
635
+ #
636
+ # strio = StringIO.new
637
+ # strio.closed? # => false # Open for reading and writing.
638
+ # strio.close_read
639
+ # strio.closed? # => false # Still open for writing.
640
+ # strio.close_write
641
+ # strio.closed? # => true # Now closed for both.
642
+ #
643
+ # Related: StringIO.closed_read?, StringIO.closed_write?.
644
+ #
645
+ def closed?: () -> bool
646
+
647
+ # <!--
648
+ # rdoc-file=ext/stringio/stringio.c
649
+ # - closed_read? -> true or false
650
+ # -->
651
+ # Returns whether `self` is closed for reading:
652
+ #
653
+ # strio = StringIO.new
654
+ # strio.closed_read? # => false
655
+ # strio.close_read
656
+ # strio.closed_read? # => true
657
+ #
658
+ # Related: StringIO#closed?, StringIO#closed_write?, StringIO#close_read.
659
+ #
660
+ def closed_read?: () -> bool
661
+
662
+ # <!--
663
+ # rdoc-file=ext/stringio/stringio.c
664
+ # - closed_write? -> true or false
665
+ # -->
666
+ # Returns whether `self` is closed for writing:
667
+ #
668
+ # strio = StringIO.new
669
+ # strio.closed_write? # => false
670
+ # strio.close_write
671
+ # strio.closed_write? # => true
672
+ #
673
+ # Related: StringIO#close_write, StringIO#closed?, StringIO#closed_read?.
674
+ #
675
+ def closed_write?: () -> bool
676
+
677
+ # <!--
678
+ # rdoc-file=ext/stringio/stringio.c
679
+ # - each_line(sep = $/, chomp: false) {|line| ... } -> self
680
+ # - each_line(limit, chomp: false) {|line| ... } -> self
681
+ # - each_line(sep, limit, chomp: false) {|line| ... } -> self
682
+ # -->
683
+ # With a block given calls the block with each remaining line (see "Position"
684
+ # below) in the stream;
685
+ # returns `self`.
686
+ # Leaves stream position at end-of-stream.
687
+ # **No Arguments**
688
+ # With no arguments given,
689
+ # reads lines using the default record separator
690
+ # (global variable <code>$/</code>, whose initial value is <code>"\n"</code>).
691
+ # strio = StringIO.new(TEXT)
692
+ # strio.each_line {|line| p line }
693
+ # strio.eof? # => true
694
+ #
695
+ # Output:
696
+ # "First line\n"
697
+ # "Second line\n"
698
+ # "\n"
699
+ # "Fourth line\n"
700
+ # "Fifth line\n"
701
+ #
702
+ # <strong>Argument `sep`</strong>
703
+ # With only string argument `sep` given,
704
+ # reads lines using that string as the record separator:
705
+ # strio = StringIO.new(TEXT)
706
+ # strio.each_line(' ') {|line| p line }
707
+ #
708
+ # Output:
709
+ # "First "
710
+ # "line\nSecond "
711
+ # "line\n\nFourth "
712
+ # "line\nFifth "
713
+ # "line\n"
714
+ #
715
+ # <strong>Argument `limit`</strong>
716
+ # With only integer argument `limit` given,
717
+ # reads lines using the default record separator;
718
+ # also limits the size (in characters) of each line to the given limit:
719
+ # strio = StringIO.new(TEXT)
720
+ # strio.each_line(10) {|line| p line }
721
+ #
722
+ # Output:
723
+ # "First line"
724
+ # "\n"
725
+ # "Second lin"
726
+ # "e\n"
727
+ # "\n"
728
+ # "Fourth lin"
729
+ # "e\n"
730
+ # "Fifth line"
731
+ # "\n"
732
+ #
733
+ # <strong>Arguments `sep` and `limit`</strong>
734
+ # With arguments `sep` and `limit` both given,
735
+ # honors both:
736
+ # strio = StringIO.new(TEXT)
737
+ # strio.each_line(' ', 10) {|line| p line }
738
+ #
739
+ # Output:
740
+ # "First "
741
+ # "line\nSecon"
742
+ # "d "
743
+ # "line\n\nFour"
744
+ # "th "
745
+ # "line\nFifth"
746
+ # " "
747
+ # "line\n"
748
+ #
749
+ # **Position**
750
+ # As stated above, method `each` *remaining* line in the stream.
751
+ # In the examples above each `strio` object starts with its position at
752
+ # beginning-of-stream;
753
+ # but in other cases the position may be anywhere (see StringIO#pos):
754
+ # strio = StringIO.new(TEXT)
755
+ # strio.pos = 30 # Set stream position to character 30.
756
+ # strio.each_line {|line| p line }
757
+ #
758
+ # Output:
759
+ # " line\n"
760
+ # "Fifth line\n"
761
+ #
762
+ # In all the examples above, the stream position is at the beginning of a
763
+ # character;
764
+ # in other cases, that need not be so:
765
+ # s = 'こんにちは' # Five 3-byte characters.
766
+ # strio = StringIO.new(s)
767
+ # strio.pos = 3 # At beginning of second character.
768
+ # strio.each_line {|line| p line }
769
+ # strio.pos = 4 # At second byte of second character.
770
+ # strio.each_line {|line| p line }
771
+ # strio.pos = 5 # At third byte of second character.
772
+ # strio.each_line {|line| p line }
773
+ #
774
+ # Output:
775
+ # "んにちは"
776
+ # "\x82\x93にちは"
777
+ # "\x93にちは"
778
+ #
779
+ # **Special Record Separators**
780
+ # Like some methods in class `IO`, StringIO.each honors two special record
781
+ # separators;
782
+ # see [Special Line
783
+ # Separators](https://docs.ruby-lang.org/en/master/IO.html#class-IO-label-Specia
784
+ # l+Line+Separator+Values).
785
+ # strio = StringIO.new(TEXT)
786
+ # strio.each_line('') {|line| p line } # Read as paragraphs (separated by blank lines).
787
+ #
788
+ # Output:
789
+ # "First line\nSecond line\n\n"
790
+ # "Fourth line\nFifth line\n"
791
+ #
792
+ # strio = StringIO.new(TEXT)
793
+ # strio.each_line(nil) {|line| p line } # "Slurp"; read it all.
794
+ #
795
+ # Output:
796
+ # "First line\nSecond line\n\nFourth line\nFifth line\n"
797
+ #
798
+ # <strong>Keyword Argument `chomp`</strong>
799
+ # With keyword argument `chomp` given as `true` (the default is `false`),
800
+ # removes trailing newline (if any) from each line:
801
+ # strio = StringIO.new(TEXT)
802
+ # strio.each_line(chomp: true) {|line| p line }
803
+ #
804
+ # Output:
805
+ # "First line"
806
+ # "Second line"
807
+ # ""
808
+ # "Fourth line"
809
+ # "Fifth line"
810
+ #
811
+ # With no block given, returns a new
812
+ # [Enumerator](https://docs.ruby-lang.org/en/master/Enumerator.html).
813
+ # Related: StringIO.each_byte, StringIO.each_char, StringIO.each_codepoint.
814
+ #
815
+ def each: (?String sep, ?Integer limit, ?chomp: boolish) { (String) -> untyped } -> self
816
+ | (?String sep, ?Integer limit, ?chomp: boolish) -> ::Enumerator[String, self]
817
+
818
+ # <!--
819
+ # rdoc-file=ext/stringio/stringio.c
820
+ # - each_byte {|byte| ... } -> self
821
+ # -->
822
+ # With a block given, calls the block with each remaining byte in the stream;
823
+ # positions the stream at end-of-file; returns `self`:
824
+ #
825
+ # bytes = []
826
+ # strio = StringIO.new('hello') # Five 1-byte characters.
827
+ # strio.each_byte {|byte| bytes.push(byte) }
828
+ # strio.eof? # => true
829
+ # bytes # => [104, 101, 108, 108, 111]
830
+ # bytes = []
831
+ # strio = StringIO.new('тест') # Four 2-byte characters.
832
+ # strio.each_byte {|byte| bytes.push(byte) }
833
+ # bytes # => [209, 130, 208, 181, 209, 129, 209, 130]
834
+ # bytes = []
835
+ # strio = StringIO.new('こんにちは') # Five 3-byte characters.
836
+ # strio.each_byte {|byte| bytes.push(byte) }
837
+ # bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
838
+ #
839
+ # The position in the stream matters:
840
+ #
841
+ # bytes = []
842
+ # strio = StringIO.new('こんにちは')
843
+ # strio.getc # => "こ"
844
+ # strio.pos # => 3 # 3-byte character was read.
845
+ # strio.each_byte {|byte| bytes.push(byte) }
846
+ # bytes # => [227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
847
+ #
848
+ # If at end-of-file, does not call the block:
849
+ #
850
+ # strio.eof? # => true
851
+ # strio.each_byte {|byte| fail 'Boo!' }
852
+ # strio.eof? # => true
853
+ #
854
+ # With no block given, returns a new [Enumerator](rdoc-ref:Enumerator).
855
+ #
856
+ # Related: StringIO#each_char, StringIO#each_codepoint, StringIO#each_line.
857
+ #
858
+ def each_byte: () { (Integer arg0) -> untyped } -> self
859
+ | () -> ::Enumerator[Integer, self]
860
+
861
+ # <!--
862
+ # rdoc-file=ext/stringio/stringio.c
863
+ # - each_char {|char| ... } -> self
864
+ # -->
865
+ # With a block given, calls the block with each remaining character in the
866
+ # stream; positions the stream at end-of-file; returns `self`:
867
+ #
868
+ # chars = []
869
+ # strio = StringIO.new('hello')
870
+ # strio.each_char {|char| chars.push(char) }
871
+ # strio.eof? # => true
872
+ # chars # => ["h", "e", "l", "l", "o"]
873
+ # chars = []
874
+ # strio = StringIO.new('тест')
875
+ # strio.each_char {|char| chars.push(char) }
876
+ # chars # => ["т", "е", "с", "т"]
877
+ # chars = []
878
+ # strio = StringIO.new('こんにちは')
879
+ # strio.each_char {|char| chars.push(char) }
880
+ # chars # => ["こ", "ん", "に", "ち", "は"]
881
+ #
882
+ # Stream position matters:
883
+ #
884
+ # chars = []
885
+ # strio = StringIO.new('こんにちは')
886
+ # strio.getc # => "こ"
887
+ # strio.pos # => 3 # 3-byte character was read.
888
+ # strio.each_char {|char| chars.push(char) }
889
+ # chars # => ["ん", "に", "ち", "は"]
890
+ #
891
+ # When at end-of-stream does not call the block:
892
+ #
893
+ # strio.eof? # => true
894
+ # strio.each_char {|char| fail 'Boo!' }
895
+ # strio.eof? # => true
896
+ #
897
+ # With no block given, returns a new [Enumerator](rdoc-ref:Enumerator).
898
+ #
899
+ # Related: StringIO#each_byte, StringIO#each_codepoint, StringIO#each_line.
900
+ #
901
+ def each_char: () { (String arg0) -> untyped } -> self
902
+ | () -> ::Enumerator[String, self]
903
+
904
+ # <!--
905
+ # rdoc-file=ext/stringio/stringio.c
906
+ # - each_codepoint {|codepoint| ... } -> self
907
+ # -->
908
+ # With a block given, calls the block with each successive codepoint from self;
909
+ # sets the position to end-of-stream; returns `self`.
910
+ #
911
+ # Each codepoint is the integer value for a character; returns self:
912
+ #
913
+ # codepoints = []
914
+ # strio = StringIO.new('hello')
915
+ # strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
916
+ # strio.eof? # => true
917
+ # codepoints # => [104, 101, 108, 108, 111]
918
+ # codepoints = []
919
+ # strio = StringIO.new('тест')
920
+ # strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
921
+ # codepoints # => [1090, 1077, 1089, 1090]
922
+ # codepoints = []
923
+ # strio = StringIO.new('こんにちは')
924
+ # strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
925
+ # codepoints # => [12371, 12435, 12395, 12385, 12399]
926
+ #
927
+ # Position in the stream matters:
928
+ #
929
+ # codepoints = []
930
+ # strio = StringIO.new('こんにちは')
931
+ # strio.getc # => "こ"
932
+ # strio.pos # => 3
933
+ # strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
934
+ # codepoints # => [12435, 12395, 12385, 12399]
935
+ #
936
+ # When at end-of-stream, the block is not called:
937
+ #
938
+ # strio.eof? # => true
939
+ # strio.each_codepoint {|codepoint| fail 'Boo!' }
940
+ # strio.eof? # => true
941
+ #
942
+ # With no block given, returns a new [Enumerator](rdoc-ref:Enumerator).
943
+ #
944
+ # Related: StringIO#each_byte, StringIO#each_char, StringIO#each_line.
945
+ #
946
+ def each_codepoint: () { (Integer arg0) -> untyped } -> self
947
+ | () -> ::Enumerator[Integer, self]
948
+
949
+ # <!--
950
+ # rdoc-file=ext/stringio/stringio.c
951
+ # - eof? -> true or false
952
+ # -->
953
+ # Returns whether `self` is positioned at end-of-stream:
954
+ #
955
+ # strio = StringIO.new('foo')
956
+ # strio.pos # => 0
957
+ # strio.eof? # => false
958
+ # strio.read # => "foo"
959
+ # strio.pos # => 3
960
+ # strio.eof? # => true
961
+ # strio.close_read
962
+ # strio.eof? # Raises IOError: not opened for reading
963
+ #
964
+ # Related: StringIO#pos.
965
+ #
966
+ def eof: () -> bool
967
+
968
+ # <!--
969
+ # rdoc-file=ext/stringio/stringio.c
970
+ # - fcntl(*args)
971
+ # -->
972
+ # Raises NotImplementedError.
973
+ #
974
+ def fcntl: (*untyped) -> bot
975
+
976
+ # <!--
977
+ # rdoc-file=ext/stringio/stringio.c
978
+ # - fileno()
979
+ # -->
980
+ # Returns `nil`; for compatibility with IO.
981
+ #
982
+ def fileno: () -> nil
983
+
984
+ # <!--
985
+ # rdoc-file=ext/stringio/stringio.c
986
+ # - flush()
987
+ # -->
988
+ # Returns `self`; for compatibility with IO.
989
+ #
990
+ def flush: () -> self
991
+
992
+ # <!--
993
+ # rdoc-file=ext/stringio/stringio.c
994
+ # - fsync()
995
+ # -->
996
+ # Returns 0; for compatibility with IO.
997
+ #
998
+ def fsync: () -> Integer
999
+
1000
+ # <!--
1001
+ # rdoc-file=ext/stringio/stringio.c
1002
+ # - getbyte -> integer or nil
1003
+ # -->
1004
+ # Reads and returns the next integer byte (not character) from the stream:
1005
+ #
1006
+ # s = 'foo'
1007
+ # s.bytes # => [102, 111, 111]
1008
+ # strio = StringIO.new(s)
1009
+ # strio.getbyte # => 102
1010
+ # strio.getbyte # => 111
1011
+ # strio.getbyte # => 111
1012
+ #
1013
+ # Returns `nil` if at end-of-stream:
1014
+ #
1015
+ # strio.eof? # => true
1016
+ # strio.getbyte # => nil
1017
+ #
1018
+ # Returns a byte, not a character:
1019
+ #
1020
+ # s = 'Привет'
1021
+ # s.bytes
1022
+ # # => [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
1023
+ # strio = StringIO.new(s)
1024
+ # strio.getbyte # => 208
1025
+ # strio.getbyte # => 159
1026
+ #
1027
+ # s = 'こんにちは'
1028
+ # s.bytes
1029
+ # # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
1030
+ # strio = StringIO.new(s)
1031
+ # strio.getbyte # => 227
1032
+ # strio.getbyte # => 129
1033
+ #
1034
+ # Related: #each_byte, #ungetbyte, #getc.
1035
+ #
1036
+ def getbyte: () -> Integer?
1037
+
1038
+ # <!--
1039
+ # rdoc-file=ext/stringio/stringio.c
1040
+ # - getc -> character, byte, or nil
1041
+ # -->
1042
+ # Reads and returns the next character (or byte; see below) from the stream:
1043
+ #
1044
+ # strio = StringIO.new('foo')
1045
+ # strio.getc # => "f"
1046
+ # strio.getc # => "o"
1047
+ # strio.getc # => "o"
1048
+ #
1049
+ # Returns `nil` if at end-of-stream:
1050
+ #
1051
+ # strio.eof? # => true
1052
+ # strio.getc # => nil
1053
+ #
1054
+ # Returns characters, not bytes:
1055
+ #
1056
+ # strio = StringIO.new('Привет')
1057
+ # strio.getc # => "П"
1058
+ # strio.getc # => "р"
1059
+ #
1060
+ # strio = StringIO.new('こんにちは')
1061
+ # strio.getc # => "こ"
1062
+ # strio.getc # => "ん"
1063
+ #
1064
+ # In each of the examples above, the stream is positioned at the beginning of a
1065
+ # character; in other cases that need not be true:
1066
+ #
1067
+ # strio = StringIO.new('こんにちは') # Five 3-byte characters.
1068
+ # strio.pos = 3 # => 3 # At beginning of second character; returns character.
1069
+ # strio.getc # => "ん"
1070
+ # strio.pos = 4 # => 4 # At second byte of second character; returns byte.
1071
+ # strio.getc # => "\x82"
1072
+ # strio.pos = 5 # => 5 # At third byte of second character; returns byte.
1073
+ # strio.getc # => "\x93"
1074
+ #
1075
+ # Related: #getbyte, #putc, #ungetc.
1076
+ #
1077
+ def getc: () -> String?
1078
+
1079
+ # <!--
1080
+ # rdoc-file=ext/stringio/stringio.c
1081
+ # - gets(sep = $/, chomp: false) -> string or nil
1082
+ # - gets(limit, chomp: false) -> string or nil
1083
+ # - gets(sep, limit, chomp: false) -> string or nil
1084
+ # -->
1085
+ # Reads and returns a line from the stream; returns `nil` if at end-of-stream.
1086
+ #
1087
+ # Side effects:
1088
+ #
1089
+ # * Increments stream position by the number of bytes read.
1090
+ # * Assigns the return value to global variable <code>$_</code>.
1091
+ #
1092
+ # With no arguments given, reads a line using the default record separator
1093
+ # (global variable <code>$/</code>,* whose initial value is <code>"\n"</code>):
1094
+ #
1095
+ # strio = StringIO.new(TEXT)
1096
+ # strio.pos # => 0
1097
+ # strio.gets # => "First line\n"
1098
+ # strio.pos # => 11
1099
+ # $_ # => "First line\n"
1100
+ # strio.gets # => "Second line\n"
1101
+ # strio.read # => "\nFourth line\nFifth line\n"
1102
+ # strio.eof? # => true
1103
+ # strio.gets # => nil
1104
+ #
1105
+ # strio = StringIO.new('Привет') # Six 2-byte characters
1106
+ # strio.pos # => 0
1107
+ # strio.gets # => "Привет"
1108
+ # strio.pos # => 12
1109
+ #
1110
+ # <strong>Argument `sep`</strong>
1111
+ #
1112
+ # With only string argument `sep` given, reads a line using that string as the
1113
+ # record separator:
1114
+ #
1115
+ # strio = StringIO.new(TEXT)
1116
+ # strio.gets(' ') # => "First "
1117
+ # strio.gets(' ') # => "line\nSecond "
1118
+ # strio.gets(' ') # => "line\n\nFourth "
1119
+ #
1120
+ # <strong>Argument `limit`</strong>
1121
+ #
1122
+ # With only integer argument `limit` given, reads a line using the default
1123
+ # record separator; limits the size (in characters) of each line to the given
1124
+ # limit:
1125
+ #
1126
+ # strio = StringIO.new(TEXT)
1127
+ # strio.gets(10) # => "First line"
1128
+ # strio.gets(10) # => "\n"
1129
+ # strio.gets(10) # => "Second lin"
1130
+ # strio.gets(10) # => "e\n"
1131
+ #
1132
+ # <strong>Arguments `sep` and `limit`</strong>
1133
+ #
1134
+ # With arguments `sep` and `limit` both given, honors both:
1135
+ #
1136
+ # strio = StringIO.new(TEXT)
1137
+ # strio.gets(' ', 10) # => "First "
1138
+ # strio.gets(' ', 10) # => "line\nSecon"
1139
+ # strio.gets(' ', 10) # => "d "
1140
+ #
1141
+ # **Position**
1142
+ #
1143
+ # As stated above, method `gets` reads and returns the next line in the stream.
1144
+ #
1145
+ # In the examples above each `strio` object starts with its position at
1146
+ # beginning-of-stream; but in other cases the position may be anywhere:
1147
+ #
1148
+ # strio = StringIO.new(TEXT)
1149
+ # strio.pos = 12
1150
+ # strio.gets # => "econd line\n"
1151
+ #
1152
+ # The position need not be at a character boundary:
1153
+ #
1154
+ # strio = StringIO.new('Привет') # Six 2-byte characters.
1155
+ # strio.pos = 2 # At beginning of second character.
1156
+ # strio.gets # => "ривет"
1157
+ # strio.pos = 3 # In middle of second character.
1158
+ # strio.gets # => "\x80ивет"
1159
+ #
1160
+ # **Special Record Separators**
1161
+ #
1162
+ # Like some methods in class IO, method `gets` honors two special record
1163
+ # separators; see [Special Line
1164
+ # Separators](https://docs.ruby-lang.org/en/master/IO.html#class-IO-label-Specia
1165
+ # l+Line+Separator+Values):
1166
+ #
1167
+ # strio = StringIO.new(TEXT)
1168
+ # strio.gets('') # Read "paragraph" (up to empty line).
1169
+ # # => "First line\nSecond line\n\n"
1170
+ #
1171
+ # strio = StringIO.new(TEXT)
1172
+ # strio.gets(nil) # "Slurp": read all.
1173
+ # # => "First line\nSecond line\n\nFourth line\nFifth line\n"
1174
+ #
1175
+ # <strong>Keyword Argument `chomp`</strong>
1176
+ #
1177
+ # With keyword argument `chomp` given as `true` (the default is `false`),
1178
+ # removes the trailing newline (if any) from the returned line:
1179
+ #
1180
+ # strio = StringIO.new(TEXT)
1181
+ # strio.gets # => "First line\n"
1182
+ # strio.gets(chomp: true) # => "Second line"
1183
+ #
1184
+ # Related: #each_line, #readlines, [Kernel#puts](rdoc-ref:Kernel#puts).
1185
+ #
1186
+ def gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
1187
+
1188
+ # <!--
1189
+ # rdoc-file=ext/stringio/stringio.c
1190
+ # - internal_encoding -> nil
1191
+ # -->
1192
+ # Returns `nil`; for compatibility with IO.
1193
+ #
1194
+ def internal_encoding: () -> nil
1195
+
1196
+ # <!--
1197
+ # rdoc-file=ext/stringio/stringio.c
1198
+ # - external_encoding -> encoding or nil
1199
+ # -->
1200
+ # Returns an Encoding object that represents the encoding of the string; see
1201
+ # [Encodings](rdoc-ref:StringIO@Encodings):
1202
+ #
1203
+ # strio = StringIO.new('foo')
1204
+ # strio.external_encoding # => #<Encoding:UTF-8>
1205
+ #
1206
+ # Returns `nil` if `self` has no string and is in write mode:
1207
+ #
1208
+ # strio = StringIO.new(nil, 'w+')
1209
+ # strio.external_encoding # => nil
1210
+ #
1211
+ def external_encoding: () -> Encoding?
1212
+
1213
+ # <!--
1214
+ # rdoc-file=ext/stringio/stringio.c
1215
+ # - isatty()
1216
+ # -->
1217
+ # Returns `false`; for compatibility with IO.
1218
+ #
1219
+ def isatty: () -> bool
1220
+
1221
+ # <!--
1222
+ # rdoc-file=ext/stringio/stringio.c
1223
+ # - lineno -> current_line_number
1224
+ # -->
1225
+ # Returns the current line number in `self`; see [Line
1226
+ # Number](rdoc-ref:StringIO@Line+Number).
1227
+ #
1228
+ def lineno: () -> Integer
1229
+
1230
+ # <!--
1231
+ # rdoc-file=ext/stringio/stringio.c
1232
+ # - lineno = new_line_number -> new_line_number
1233
+ # -->
1234
+ # Sets the current line number in `self` to the given `new_line_number`; see
1235
+ # [Line Number](rdoc-ref:StringIO@Line+Number).
1236
+ #
1237
+ def lineno=: (Integer arg0) -> Integer
1238
+
1239
+ # <!--
1240
+ # rdoc-file=ext/stringio/stringio.c
1241
+ # - pid()
1242
+ # -->
1243
+ # Returns `nil`; for compatibility with IO.
1244
+ #
1245
+ def pid: () -> nil
1246
+
1247
+ # <!--
1248
+ # rdoc-file=ext/stringio/stringio.c
1249
+ # - pos -> stream_position
1250
+ # -->
1251
+ # Returns the current position (in bytes); see
1252
+ # [Position](rdoc-ref:StringIO@Position).
1253
+ #
1254
+ def pos: () -> Integer
1255
+
1256
+ # <!--
1257
+ # rdoc-file=ext/stringio/stringio.c
1258
+ # - pos = new_position -> new_position
1259
+ # -->
1260
+ # Sets the current position (in bytes); see
1261
+ # [Position](rdoc-ref:StringIO@Position).
1262
+ #
1263
+ def pos=: (Integer arg0) -> Integer
1264
+
1265
+ def print: (*untyped arg0) -> nil
1266
+
1267
+ def printf: (String format_string, *untyped arg0) -> nil
1268
+
1269
+ # <!--
1270
+ # rdoc-file=ext/stringio/stringio.c
1271
+ # - strio.putc(obj) -> obj
1272
+ # -->
1273
+ # See IO#putc.
1274
+ #
1275
+ def putc: (Numeric | String arg0) -> untyped
1276
+
1277
+ def puts: (*untyped arg0) -> nil
1278
+
1279
+ # <!--
1280
+ # rdoc-file=ext/stringio/stringio.c
1281
+ # - strio.read([length [, outbuf]]) -> string, outbuf, or nil
1282
+ # -->
1283
+ # See IO#read.
1284
+ #
1285
+ def read: (?int? length, ?string? outbuf) -> String?
1286
+
1287
+ # <!--
1288
+ # rdoc-file=ext/stringio/stringio.c
1289
+ # - pread(maxlen, offset) -> string
1290
+ # - pread(maxlen, offset, out_string) -> string
1291
+ # -->
1292
+ # See IO#pread.
1293
+ #
1294
+ def pread: (Integer maxlen, Integer offset, ?String? outbuf) -> String
1295
+
1296
+ def read_nonblock: (int len, ?string? buf, ?exception: bool) -> String?
1297
+
1298
+ def readbyte: () -> Integer
1299
+
1300
+ def readchar: () -> String
1301
+
1302
+ def readline: (?String sep, ?Integer limit, ?chomp: boolish) -> String
1303
+
1304
+ # <!--
1305
+ # rdoc-file=ext/stringio/stringio.c
1306
+ # - strio.readlines(sep=$/, chomp: false) -> array
1307
+ # - strio.readlines(limit, chomp: false) -> array
1308
+ # - strio.readlines(sep, limit, chomp: false) -> array
1309
+ # -->
1310
+ # See IO#readlines.
1311
+ #
1312
+ def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String]
1313
+
1314
+ def readpartial: (int maxlen, ?string? outbuf) -> String
1315
+
1316
+ # <!--
1317
+ # rdoc-file=ext/stringio/stringio.c
1318
+ # - reopen(other, mode = 'r+') -> self
1319
+ # -->
1320
+ # Reinitializes the stream with the given `other` (string or StringIO) and
1321
+ # `mode`; see IO.new:
1322
+ #
1323
+ # StringIO.open('foo') do |strio|
1324
+ # p strio.string
1325
+ # strio.reopen('bar')
1326
+ # p strio.string
1327
+ # other_strio = StringIO.new('baz')
1328
+ # strio.reopen(other_strio)
1329
+ # p strio.string
1330
+ # other_strio.close
1331
+ # end
1332
+ #
1333
+ # Output:
1334
+ #
1335
+ # "foo"
1336
+ # "bar"
1337
+ # "baz"
1338
+ #
1339
+ def reopen: (StringIO other) -> self
1340
+ | (String other, ?String mode_str) -> self
1341
+
1342
+ # <!--
1343
+ # rdoc-file=ext/stringio/stringio.c
1344
+ # - rewind -> 0
1345
+ # -->
1346
+ # Sets the current position and line number to zero; see
1347
+ # [Position](rdoc-ref:IO@Position) and [Line Number](rdoc-ref:IO@Line+Number).
1348
+ #
1349
+ def rewind: () -> Integer
1350
+
1351
+ # <!--
1352
+ # rdoc-file=ext/stringio/stringio.c
1353
+ # - seek(offset, whence = SEEK_SET) -> 0
1354
+ # -->
1355
+ # Sets the position to the given integer `offset` (in bytes), with respect to a
1356
+ # given constant `whence`; see [IO#seek](rdoc-ref:IO#seek).
1357
+ #
1358
+ def seek: (Integer amount, ?Integer whence) -> Integer
1359
+
1360
+ # <!--
1361
+ # rdoc-file=ext/stringio/stringio.c
1362
+ # - strio.set_encoding(ext_enc, [int_enc[, opt]]) => strio
1363
+ # -->
1364
+ # Specify the encoding of the StringIO as *ext_enc*. Use the default external
1365
+ # encoding if *ext_enc* is nil. 2nd argument *int_enc* and optional hash *opt*
1366
+ # argument are ignored; they are for API compatibility to IO.
1367
+ #
1368
+ def set_encoding: (?String | Encoding ext_or_ext_int_enc) -> self
1369
+ | (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
1370
+
1371
+ # <!--
1372
+ # rdoc-file=ext/stringio/stringio.c
1373
+ # - strio.set_encoding_by_bom => strio or nil
1374
+ # -->
1375
+ # Sets the encoding according to the BOM (Byte Order Mark) in the string.
1376
+ #
1377
+ # Returns `self` if the BOM is found, otherwise +nil.
1378
+ #
1379
+ def set_encoding_by_bom: () -> Encoding?
1380
+
1381
+ # <!--
1382
+ # rdoc-file=ext/stringio/stringio.c
1383
+ # - string -> string
1384
+ # -->
1385
+ # Returns underlying string:
1386
+ #
1387
+ # StringIO.open('foo') do |strio|
1388
+ # p strio.string
1389
+ # strio.string = 'bar'
1390
+ # p strio.string
1391
+ # end
1392
+ #
1393
+ # Output:
1394
+ #
1395
+ # "foo"
1396
+ # "bar"
1397
+ #
1398
+ # Related: StringIO#string= (assigns the underlying string).
1399
+ #
1400
+ def string: () -> String
1401
+
1402
+ # <!--
1403
+ # rdoc-file=ext/stringio/stringio.c
1404
+ # - string = other_string -> other_string
1405
+ # -->
1406
+ # Replaces the stored string with `other_string`, and sets the position to zero;
1407
+ # returns `other_string`:
1408
+ #
1409
+ # StringIO.open('foo') do |strio|
1410
+ # p strio.string
1411
+ # strio.string = 'bar'
1412
+ # p strio.string
1413
+ # end
1414
+ #
1415
+ # Output:
1416
+ #
1417
+ # "foo"
1418
+ # "bar"
1419
+ #
1420
+ # Related: StringIO#string (returns the stored string).
1421
+ #
1422
+ def string=: (String str) -> String
1423
+
1424
+ # <!--
1425
+ # rdoc-file=ext/stringio/stringio.c
1426
+ # - size -> integer
1427
+ # -->
1428
+ # Returns the number of bytes in the string in `self`:
1429
+ #
1430
+ # StringIO.new('hello').size # => 5 # Five 1-byte characters.
1431
+ # StringIO.new('тест').size # => 8 # Four 2-byte characters.
1432
+ # StringIO.new('こんにちは').size # => 15 # Five 3-byte characters.
1433
+ #
1434
+ def size: () -> Integer
1435
+
1436
+ # <!--
1437
+ # rdoc-file=ext/stringio/stringio.c
1438
+ # - sync -> true
1439
+ # -->
1440
+ # Returns `true`; implemented only for compatibility with other stream classes.
1441
+ #
1442
+ def sync: () -> bool
1443
+
1444
+ # <!--
1445
+ # rdoc-file=ext/stringio/stringio.c
1446
+ # - sync=(p1)
1447
+ # -->
1448
+ # Returns the argument unchanged. Just for compatibility to IO.
1449
+ #
1450
+ def sync=: (boolish) -> bool
1451
+
1452
+ def sysread: (Integer maxlen, ?String? outbuf) -> String
1453
+
1454
+ def syswrite: (String arg0) -> Integer
1455
+
1456
+ # <!--
1457
+ # rdoc-file=ext/stringio/stringio.c
1458
+ # - pos -> stream_position
1459
+ # -->
1460
+ # Returns the current position (in bytes); see
1461
+ # [Position](rdoc-ref:StringIO@Position).
1462
+ #
1463
+ def tell: () -> Integer
1464
+
1465
+ # <!--
1466
+ # rdoc-file=ext/stringio/stringio.c
1467
+ # - strio.truncate(integer) -> 0
1468
+ # -->
1469
+ # Truncates the buffer string to at most *integer* bytes. The stream must be
1470
+ # opened for writing.
1471
+ #
1472
+ def truncate: (Integer) -> 0
1473
+
1474
+ # <!-- rdoc-file=ext/stringio/stringio.c -->
1475
+ # Returns `false`; for compatibility with IO.
1476
+ #
1477
+ def tty?: () -> bool
1478
+
1479
+ # <!--
1480
+ # rdoc-file=ext/stringio/stringio.c
1481
+ # - ungetbyte(byte) -> nil
1482
+ # -->
1483
+ # Pushes back ("unshifts") an 8-bit byte onto the stream; see [Byte
1484
+ # IO](rdoc-ref:IO@Byte+IO).
1485
+ #
1486
+ def ungetbyte: (String | Integer arg0) -> nil
1487
+
1488
+ # <!--
1489
+ # rdoc-file=ext/stringio/stringio.c
1490
+ # - ungetc(character) -> nil
1491
+ # -->
1492
+ # Pushes back ("unshifts") a character or integer onto the stream; see
1493
+ # [Character IO](rdoc-ref:IO@Character+IO).
1494
+ #
1495
+ def ungetc: (String | Integer arg0) -> nil
1496
+
1497
+ # <!--
1498
+ # rdoc-file=ext/stringio/stringio.c
1499
+ # - strio.write(string, ...) -> integer
1500
+ # - strio.syswrite(string) -> integer
1501
+ # -->
1502
+ # Appends the given string to the underlying buffer string. The stream must be
1503
+ # opened for writing. If the argument is not a string, it will be converted to
1504
+ # a string using `to_s`. Returns the number of bytes written. See IO#write.
1505
+ #
1506
+ def write: (*_ToS) -> Integer
1507
+
1508
+ def write_nonblock: (_ToS s, ?exception: bool) -> Integer
1509
+
1510
+ # This is a deprecated alias for #each_byte.
1511
+ #
1512
+ def bytes: () { (Integer arg0) -> untyped } -> self
1513
+ | () -> ::Enumerator[Integer, self]
1514
+
1515
+ # This is a deprecated alias for #each_char.
1516
+ #
1517
+ def chars: () { (String arg0) -> untyped } -> self
1518
+ | () -> ::Enumerator[String, self]
1519
+
1520
+ # This is a deprecated alias for #each_codepoint.
1521
+ #
1522
+ def codepoints: () { (Integer arg0) -> untyped } -> self
1523
+ | () -> ::Enumerator[Integer, self]
1524
+
1525
+ # <!-- rdoc-file=ext/stringio/stringio.c -->
1526
+ # With a block given calls the block with each remaining line (see "Position"
1527
+ # below) in the stream;
1528
+ # returns `self`.
1529
+ # Leaves stream position at end-of-stream.
1530
+ # **No Arguments**
1531
+ # With no arguments given,
1532
+ # reads lines using the default record separator
1533
+ # (global variable <code>$/</code>, whose initial value is <code>"\n"</code>).
1534
+ # strio = StringIO.new(TEXT)
1535
+ # strio.each_line {|line| p line }
1536
+ # strio.eof? # => true
1537
+ #
1538
+ # Output:
1539
+ # "First line\n"
1540
+ # "Second line\n"
1541
+ # "\n"
1542
+ # "Fourth line\n"
1543
+ # "Fifth line\n"
1544
+ #
1545
+ # <strong>Argument `sep`</strong>
1546
+ # With only string argument `sep` given,
1547
+ # reads lines using that string as the record separator:
1548
+ # strio = StringIO.new(TEXT)
1549
+ # strio.each_line(' ') {|line| p line }
1550
+ #
1551
+ # Output:
1552
+ # "First "
1553
+ # "line\nSecond "
1554
+ # "line\n\nFourth "
1555
+ # "line\nFifth "
1556
+ # "line\n"
1557
+ #
1558
+ # <strong>Argument `limit`</strong>
1559
+ # With only integer argument `limit` given,
1560
+ # reads lines using the default record separator;
1561
+ # also limits the size (in characters) of each line to the given limit:
1562
+ # strio = StringIO.new(TEXT)
1563
+ # strio.each_line(10) {|line| p line }
1564
+ #
1565
+ # Output:
1566
+ # "First line"
1567
+ # "\n"
1568
+ # "Second lin"
1569
+ # "e\n"
1570
+ # "\n"
1571
+ # "Fourth lin"
1572
+ # "e\n"
1573
+ # "Fifth line"
1574
+ # "\n"
1575
+ #
1576
+ # <strong>Arguments `sep` and `limit`</strong>
1577
+ # With arguments `sep` and `limit` both given,
1578
+ # honors both:
1579
+ # strio = StringIO.new(TEXT)
1580
+ # strio.each_line(' ', 10) {|line| p line }
1581
+ #
1582
+ # Output:
1583
+ # "First "
1584
+ # "line\nSecon"
1585
+ # "d "
1586
+ # "line\n\nFour"
1587
+ # "th "
1588
+ # "line\nFifth"
1589
+ # " "
1590
+ # "line\n"
1591
+ #
1592
+ # **Position**
1593
+ # As stated above, method `each` *remaining* line in the stream.
1594
+ # In the examples above each `strio` object starts with its position at
1595
+ # beginning-of-stream;
1596
+ # but in other cases the position may be anywhere (see StringIO#pos):
1597
+ # strio = StringIO.new(TEXT)
1598
+ # strio.pos = 30 # Set stream position to character 30.
1599
+ # strio.each_line {|line| p line }
1600
+ #
1601
+ # Output:
1602
+ # " line\n"
1603
+ # "Fifth line\n"
1604
+ #
1605
+ # In all the examples above, the stream position is at the beginning of a
1606
+ # character;
1607
+ # in other cases, that need not be so:
1608
+ # s = 'こんにちは' # Five 3-byte characters.
1609
+ # strio = StringIO.new(s)
1610
+ # strio.pos = 3 # At beginning of second character.
1611
+ # strio.each_line {|line| p line }
1612
+ # strio.pos = 4 # At second byte of second character.
1613
+ # strio.each_line {|line| p line }
1614
+ # strio.pos = 5 # At third byte of second character.
1615
+ # strio.each_line {|line| p line }
1616
+ #
1617
+ # Output:
1618
+ # "んにちは"
1619
+ # "\x82\x93にちは"
1620
+ # "\x93にちは"
1621
+ #
1622
+ # **Special Record Separators**
1623
+ # Like some methods in class `IO`, StringIO.each honors two special record
1624
+ # separators;
1625
+ # see [Special Line
1626
+ # Separators](https://docs.ruby-lang.org/en/master/IO.html#class-IO-label-Specia
1627
+ # l+Line+Separator+Values).
1628
+ # strio = StringIO.new(TEXT)
1629
+ # strio.each_line('') {|line| p line } # Read as paragraphs (separated by blank lines).
1630
+ #
1631
+ # Output:
1632
+ # "First line\nSecond line\n\n"
1633
+ # "Fourth line\nFifth line\n"
1634
+ #
1635
+ # strio = StringIO.new(TEXT)
1636
+ # strio.each_line(nil) {|line| p line } # "Slurp"; read it all.
1637
+ #
1638
+ # Output:
1639
+ # "First line\nSecond line\n\nFourth line\nFifth line\n"
1640
+ #
1641
+ # <strong>Keyword Argument `chomp`</strong>
1642
+ # With keyword argument `chomp` given as `true` (the default is `false`),
1643
+ # removes trailing newline (if any) from each line:
1644
+ # strio = StringIO.new(TEXT)
1645
+ # strio.each_line(chomp: true) {|line| p line }
1646
+ #
1647
+ # Output:
1648
+ # "First line"
1649
+ # "Second line"
1650
+ # ""
1651
+ # "Fourth line"
1652
+ # "Fifth line"
1653
+ #
1654
+ # With no block given, returns a new
1655
+ # [Enumerator](https://docs.ruby-lang.org/en/master/Enumerator.html).
1656
+ # Related: StringIO.each_byte, StringIO.each_char, StringIO.each_codepoint.
1657
+ #
1658
+ def each_line: (?String sep, ?Integer limit, ?chomp: boolish) { (String) -> untyped } -> self
1659
+ | (?String sep, ?Integer limit, ?chomp: boolish) -> ::Enumerator[String, self]
1660
+
1661
+ # <!-- rdoc-file=ext/stringio/stringio.c -->
1662
+ # Returns whether `self` is positioned at end-of-stream:
1663
+ #
1664
+ # strio = StringIO.new('foo')
1665
+ # strio.pos # => 0
1666
+ # strio.eof? # => false
1667
+ # strio.read # => "foo"
1668
+ # strio.pos # => 3
1669
+ # strio.eof? # => true
1670
+ # strio.close_read
1671
+ # strio.eof? # Raises IOError: not opened for reading
1672
+ #
1673
+ # Related: StringIO#pos.
1674
+ #
1675
+ def eof?: () -> bool
1676
+
1677
+ # This is a deprecated alias for #each_line.
1678
+ #
1679
+ def lines: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
1680
+ | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
1681
+ end