rbs-relaxed 3.9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/dependabot.yml +22 -0
- data/.github/workflows/comments.yml +35 -0
- data/.github/workflows/dependabot.yml +30 -0
- data/.github/workflows/ruby.yml +82 -0
- data/.github/workflows/typecheck.yml +38 -0
- data/.github/workflows/windows.yml +43 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +68 -0
- data/BSDL +22 -0
- data/CHANGELOG.md +1868 -0
- data/COPYING +56 -0
- data/README.md +203 -0
- data/Rakefile +417 -0
- data/Steepfile +44 -0
- data/config.yml +313 -0
- data/core/array.rbs +4062 -0
- data/core/basic_object.rbs +375 -0
- data/core/binding.rbs +150 -0
- data/core/builtin.rbs +277 -0
- data/core/class.rbs +220 -0
- data/core/comparable.rbs +171 -0
- data/core/complex.rbs +786 -0
- data/core/constants.rbs +96 -0
- data/core/data.rbs +415 -0
- data/core/dir.rbs +981 -0
- data/core/encoding.rbs +1371 -0
- data/core/enumerable.rbs +2405 -0
- data/core/enumerator/product.rbs +92 -0
- data/core/enumerator.rbs +630 -0
- data/core/env.rbs +6 -0
- data/core/errno.rbs +673 -0
- data/core/errors.rbs +760 -0
- data/core/exception.rbs +485 -0
- data/core/false_class.rbs +82 -0
- data/core/fiber.rbs +550 -0
- data/core/fiber_error.rbs +11 -0
- data/core/file.rbs +2936 -0
- data/core/file_test.rbs +331 -0
- data/core/float.rbs +1151 -0
- data/core/gc.rbs +644 -0
- data/core/global_variables.rbs +184 -0
- data/core/hash.rbs +1861 -0
- data/core/integer.rbs +1413 -0
- data/core/io/buffer.rbs +984 -0
- data/core/io/wait.rbs +70 -0
- data/core/io.rbs +3406 -0
- data/core/kernel.rbs +3096 -0
- data/core/marshal.rbs +207 -0
- data/core/match_data.rbs +635 -0
- data/core/math.rbs +729 -0
- data/core/method.rbs +386 -0
- data/core/module.rbs +1704 -0
- data/core/nil_class.rbs +209 -0
- data/core/numeric.rbs +818 -0
- data/core/object.rbs +110 -0
- data/core/object_space/weak_key_map.rbs +166 -0
- data/core/object_space.rbs +190 -0
- data/core/proc.rbs +868 -0
- data/core/process.rbs +2296 -0
- data/core/ractor.rbs +1068 -0
- data/core/random.rbs +237 -0
- data/core/range.rbs +1107 -0
- data/core/rational.rbs +531 -0
- data/core/rb_config.rbs +88 -0
- data/core/rbs/unnamed/argf.rbs +1229 -0
- data/core/rbs/unnamed/env_class.rbs +1209 -0
- data/core/rbs/unnamed/random.rbs +293 -0
- data/core/refinement.rbs +59 -0
- data/core/regexp.rbs +1930 -0
- data/core/ruby_vm.rbs +765 -0
- data/core/rubygems/basic_specification.rbs +6 -0
- data/core/rubygems/config_file.rbs +38 -0
- data/core/rubygems/dependency_installer.rbs +6 -0
- data/core/rubygems/errors.rbs +176 -0
- data/core/rubygems/installer.rbs +15 -0
- data/core/rubygems/path_support.rbs +6 -0
- data/core/rubygems/platform.rbs +7 -0
- data/core/rubygems/request_set.rbs +49 -0
- data/core/rubygems/requirement.rbs +148 -0
- data/core/rubygems/rubygems.rbs +1171 -0
- data/core/rubygems/source_list.rbs +15 -0
- data/core/rubygems/specification.rbs +23 -0
- data/core/rubygems/stream_ui.rbs +5 -0
- data/core/rubygems/uninstaller.rbs +10 -0
- data/core/rubygems/version.rbs +294 -0
- data/core/set.rbs +621 -0
- data/core/signal.rbs +100 -0
- data/core/string.rbs +3583 -0
- data/core/struct.rbs +667 -0
- data/core/symbol.rbs +475 -0
- data/core/thread.rbs +1765 -0
- data/core/thread_group.rbs +79 -0
- data/core/time.rbs +1762 -0
- data/core/trace_point.rbs +477 -0
- data/core/true_class.rbs +98 -0
- data/core/unbound_method.rbs +329 -0
- data/core/warning.rbs +87 -0
- data/docs/CONTRIBUTING.md +106 -0
- data/docs/architecture.md +110 -0
- data/docs/collection.md +192 -0
- data/docs/data_and_struct.md +86 -0
- data/docs/gem.md +57 -0
- data/docs/rbs_by_example.md +309 -0
- data/docs/repo.md +125 -0
- data/docs/sigs.md +167 -0
- data/docs/stdlib.md +147 -0
- data/docs/syntax.md +910 -0
- data/docs/tools.md +17 -0
- data/exe/rbs +7 -0
- data/ext/rbs_extension/extconf.rb +15 -0
- data/ext/rbs_extension/lexer.c +2728 -0
- data/ext/rbs_extension/lexer.h +179 -0
- data/ext/rbs_extension/lexer.re +147 -0
- data/ext/rbs_extension/lexstate.c +175 -0
- data/ext/rbs_extension/location.c +325 -0
- data/ext/rbs_extension/location.h +85 -0
- data/ext/rbs_extension/main.c +33 -0
- data/ext/rbs_extension/parser.c +2973 -0
- data/ext/rbs_extension/parser.h +18 -0
- data/ext/rbs_extension/parserstate.c +397 -0
- data/ext/rbs_extension/parserstate.h +163 -0
- data/ext/rbs_extension/rbs_extension.h +31 -0
- data/ext/rbs_extension/unescape.c +32 -0
- data/goodcheck.yml +91 -0
- data/include/rbs/constants.h +82 -0
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/ancestor_graph.rb +92 -0
- data/lib/rbs/annotate/annotations.rb +199 -0
- data/lib/rbs/annotate/formatter.rb +92 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +400 -0
- data/lib/rbs/annotate/rdoc_source.rb +131 -0
- data/lib/rbs/annotate.rb +8 -0
- data/lib/rbs/ast/annotation.rb +29 -0
- data/lib/rbs/ast/comment.rb +29 -0
- data/lib/rbs/ast/declarations.rb +467 -0
- data/lib/rbs/ast/directives.rb +49 -0
- data/lib/rbs/ast/members.rb +451 -0
- data/lib/rbs/ast/type_param.rb +225 -0
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/buffer.rb +67 -0
- data/lib/rbs/builtin_names.rb +58 -0
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +83 -0
- data/lib/rbs/cli/validate.rb +357 -0
- data/lib/rbs/cli.rb +1223 -0
- data/lib/rbs/collection/cleaner.rb +38 -0
- data/lib/rbs/collection/config/lockfile.rb +92 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +218 -0
- data/lib/rbs/collection/config.rb +81 -0
- data/lib/rbs/collection/installer.rb +32 -0
- data/lib/rbs/collection/sources/base.rb +14 -0
- data/lib/rbs/collection/sources/git.rb +258 -0
- data/lib/rbs/collection/sources/local.rb +81 -0
- data/lib/rbs/collection/sources/rubygems.rb +48 -0
- data/lib/rbs/collection/sources/stdlib.rb +50 -0
- data/lib/rbs/collection/sources.rb +38 -0
- data/lib/rbs/collection.rb +16 -0
- data/lib/rbs/constant.rb +28 -0
- data/lib/rbs/definition.rb +401 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +620 -0
- data/lib/rbs/definition_builder/method_builder.rb +254 -0
- data/lib/rbs/definition_builder.rb +845 -0
- data/lib/rbs/diff.rb +125 -0
- data/lib/rbs/environment/use_map.rb +77 -0
- data/lib/rbs/environment.rb +829 -0
- data/lib/rbs/environment_loader.rb +173 -0
- data/lib/rbs/environment_walker.rb +155 -0
- data/lib/rbs/errors.rb +645 -0
- data/lib/rbs/factory.rb +18 -0
- data/lib/rbs/file_finder.rb +28 -0
- data/lib/rbs/location_aux.rb +138 -0
- data/lib/rbs/locator.rb +243 -0
- data/lib/rbs/method_type.rb +143 -0
- data/lib/rbs/namespace.rb +125 -0
- data/lib/rbs/parser/lex_result.rb +15 -0
- data/lib/rbs/parser/token.rb +23 -0
- data/lib/rbs/parser_aux.rb +114 -0
- data/lib/rbs/prototype/helpers.rb +140 -0
- data/lib/rbs/prototype/node_usage.rb +99 -0
- data/lib/rbs/prototype/rb.rb +840 -0
- data/lib/rbs/prototype/rbi.rb +641 -0
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/reflection.rb +19 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
- data/lib/rbs/prototype/runtime.rb +667 -0
- data/lib/rbs/repository.rb +127 -0
- data/lib/rbs/resolver/constant_resolver.rb +219 -0
- data/lib/rbs/resolver/type_name_resolver.rb +91 -0
- data/lib/rbs/sorter.rb +198 -0
- data/lib/rbs/substitution.rb +83 -0
- data/lib/rbs/subtractor.rb +201 -0
- data/lib/rbs/test/errors.rb +80 -0
- data/lib/rbs/test/guaranteed.rb +30 -0
- data/lib/rbs/test/hook.rb +212 -0
- data/lib/rbs/test/observer.rb +19 -0
- data/lib/rbs/test/setup.rb +84 -0
- data/lib/rbs/test/setup_helper.rb +50 -0
- data/lib/rbs/test/tester.rb +167 -0
- data/lib/rbs/test/type_check.rb +435 -0
- data/lib/rbs/test.rb +112 -0
- data/lib/rbs/type_alias_dependency.rb +100 -0
- data/lib/rbs/type_alias_regularity.rb +126 -0
- data/lib/rbs/type_name.rb +109 -0
- data/lib/rbs/types.rb +1596 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +138 -0
- data/lib/rbs/unit_test/type_assertions.rb +347 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/validator.rb +186 -0
- data/lib/rbs/variance_calculator.rb +189 -0
- data/lib/rbs/vendorer.rb +71 -0
- data/lib/rbs/version.rb +5 -0
- data/lib/rbs/writer.rb +424 -0
- data/lib/rbs.rb +94 -0
- data/lib/rdoc/discover.rb +20 -0
- data/lib/rdoc_plugin/parser.rb +163 -0
- data/rbs-relaxed.gemspec +48 -0
- data/schema/annotation.json +14 -0
- data/schema/comment.json +26 -0
- data/schema/decls.json +326 -0
- data/schema/function.json +87 -0
- data/schema/location.json +56 -0
- data/schema/members.json +266 -0
- data/schema/methodType.json +50 -0
- data/schema/typeParam.json +36 -0
- data/schema/types.json +317 -0
- data/sig/ancestor_builder.rbs +163 -0
- data/sig/ancestor_graph.rbs +60 -0
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/annotation.rbs +27 -0
- data/sig/buffer.rbs +32 -0
- data/sig/builtin_names.rbs +44 -0
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli/validate.rbs +43 -0
- data/sig/cli.rbs +87 -0
- data/sig/collection/cleaner.rbs +13 -0
- data/sig/collection/config/lockfile.rbs +74 -0
- data/sig/collection/config/lockfile_generator.rbs +66 -0
- data/sig/collection/config.rbs +46 -0
- data/sig/collection/installer.rbs +17 -0
- data/sig/collection/sources.rbs +214 -0
- data/sig/collection.rbs +4 -0
- data/sig/comment.rbs +26 -0
- data/sig/constant.rbs +21 -0
- data/sig/declarations.rbs +267 -0
- data/sig/definition.rbs +173 -0
- data/sig/definition_builder.rbs +165 -0
- data/sig/diff.rbs +28 -0
- data/sig/directives.rbs +77 -0
- data/sig/environment.rbs +279 -0
- data/sig/environment_loader.rbs +111 -0
- data/sig/environment_walker.rbs +65 -0
- data/sig/errors.rbs +405 -0
- data/sig/factory.rbs +5 -0
- data/sig/file_finder.rbs +28 -0
- data/sig/location.rbs +110 -0
- data/sig/locator.rbs +58 -0
- data/sig/manifest.yaml +7 -0
- data/sig/members.rbs +258 -0
- data/sig/method_builder.rbs +84 -0
- data/sig/method_types.rbs +58 -0
- data/sig/namespace.rbs +146 -0
- data/sig/parser.rbs +100 -0
- data/sig/prototype/helpers.rbs +27 -0
- data/sig/prototype/node_usage.rbs +20 -0
- data/sig/prototype/rb.rbs +96 -0
- data/sig/prototype/rbi.rbs +75 -0
- data/sig/prototype/runtime.rbs +182 -0
- data/sig/rbs.rbs +21 -0
- data/sig/rdoc/rbs.rbs +67 -0
- data/sig/repository.rbs +85 -0
- data/sig/resolver/constant_resolver.rbs +92 -0
- data/sig/resolver/context.rbs +34 -0
- data/sig/resolver/type_name_resolver.rbs +35 -0
- data/sig/shims/bundler.rbs +38 -0
- data/sig/shims/enumerable.rbs +5 -0
- data/sig/shims/rubygems.rbs +19 -0
- data/sig/sorter.rbs +41 -0
- data/sig/substitution.rbs +48 -0
- data/sig/subtractor.rbs +37 -0
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/type_alias_dependency.rbs +53 -0
- data/sig/type_alias_regularity.rbs +98 -0
- data/sig/type_param.rbs +110 -0
- data/sig/typename.rbs +79 -0
- data/sig/types.rbs +579 -0
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +30 -0
- data/sig/unit_test/type_assertions.rbs +196 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/sig/use_map.rbs +35 -0
- data/sig/util.rbs +9 -0
- data/sig/validator.rbs +63 -0
- data/sig/variance_calculator.rbs +87 -0
- data/sig/vendorer.rbs +51 -0
- data/sig/version.rbs +3 -0
- data/sig/visitor.rbs +47 -0
- data/sig/writer.rbs +127 -0
- data/src/constants.c +153 -0
- data/src/ruby_objs.c +795 -0
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/abbrev/0/abbrev.rbs +66 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +355 -0
- data/stdlib/benchmark/0/benchmark.rbs +452 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +1629 -0
- data/stdlib/bigdecimal-math/0/big_math.rbs +119 -0
- data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
- data/stdlib/cgi/0/core.rbs +1285 -0
- data/stdlib/cgi/0/manifest.yaml +3 -0
- data/stdlib/coverage/0/coverage.rbs +263 -0
- data/stdlib/csv/0/csv.rbs +3776 -0
- data/stdlib/csv/0/manifest.yaml +3 -0
- data/stdlib/date/0/date.rbs +1585 -0
- data/stdlib/date/0/date_time.rbs +616 -0
- data/stdlib/date/0/time.rbs +26 -0
- data/stdlib/dbm/0/dbm.rbs +421 -0
- data/stdlib/delegate/0/delegator.rbs +184 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +96 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +343 -0
- data/stdlib/digest/0/digest.rbs +577 -0
- data/stdlib/erb/0/erb.rbs +532 -0
- data/stdlib/etc/0/etc.rbs +865 -0
- data/stdlib/fileutils/0/fileutils.rbs +1734 -0
- data/stdlib/find/0/find.rbs +49 -0
- data/stdlib/forwardable/0/forwardable.rbs +268 -0
- data/stdlib/io-console/0/io-console.rbs +414 -0
- data/stdlib/ipaddr/0/ipaddr.rbs +428 -0
- data/stdlib/json/0/json.rbs +1916 -0
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/logger/0/formatter.rbs +45 -0
- data/stdlib/logger/0/log_device.rbs +100 -0
- data/stdlib/logger/0/logger.rbs +796 -0
- data/stdlib/logger/0/manifest.yaml +2 -0
- data/stdlib/logger/0/period.rbs +17 -0
- data/stdlib/logger/0/severity.rbs +34 -0
- data/stdlib/minitest/0/kernel.rbs +42 -0
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
- data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
- data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
- data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
- data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
- data/stdlib/minitest/0/minitest/guard.rbs +64 -0
- data/stdlib/minitest/0/minitest/mock.rbs +64 -0
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
- data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
- data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
- data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
- data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
- data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/result.rbs +28 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
- data/stdlib/minitest/0/minitest/skip.rbs +6 -0
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
- data/stdlib/minitest/0/minitest/spec.rbs +11 -0
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
- data/stdlib/minitest/0/minitest/test.rbs +69 -0
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
- data/stdlib/minitest/0/minitest/unit.rbs +4 -0
- data/stdlib/minitest/0/minitest.rbs +115 -0
- data/stdlib/monitor/0/monitor.rbs +363 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
- data/stdlib/net-http/0/manifest.yaml +3 -0
- data/stdlib/net-http/0/net-http.rbs +5552 -0
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/net-smtp/0/manifest.yaml +2 -0
- data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
- data/stdlib/nkf/0/nkf.rbs +402 -0
- data/stdlib/objspace/0/objspace.rbs +487 -0
- data/stdlib/observable/0/observable.rbs +217 -0
- data/stdlib/open-uri/0/manifest.yaml +4 -0
- data/stdlib/open-uri/0/open-uri.rbs +393 -0
- data/stdlib/open3/0/open3.rbs +147 -0
- data/stdlib/openssl/0/manifest.yaml +3 -0
- data/stdlib/openssl/0/openssl.rbs +12113 -0
- data/stdlib/optparse/0/optparse.rbs +1725 -0
- data/stdlib/pathname/0/pathname.rbs +1406 -0
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +300 -0
- data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
- data/stdlib/pstore/0/pstore.rbs +603 -0
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/psych/0/dbm.rbs +237 -0
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +402 -0
- data/stdlib/psych/0/store.rbs +59 -0
- data/stdlib/pty/0/pty.rbs +237 -0
- data/stdlib/rdoc/0/code_object.rbs +51 -0
- data/stdlib/rdoc/0/comment.rbs +59 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +117 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +391 -0
- data/stdlib/rdoc/0/ri.rbs +17 -0
- data/stdlib/rdoc/0/store.rbs +48 -0
- data/stdlib/rdoc/0/top_level.rbs +97 -0
- data/stdlib/resolv/0/manifest.yaml +3 -0
- data/stdlib/resolv/0/resolv.rbs +1830 -0
- data/stdlib/ripper/0/ripper.rbs +1648 -0
- data/stdlib/securerandom/0/securerandom.rbs +62 -0
- data/stdlib/shellwords/0/shellwords.rbs +229 -0
- data/stdlib/singleton/0/singleton.rbs +131 -0
- data/stdlib/socket/0/addrinfo.rbs +666 -0
- data/stdlib/socket/0/basic_socket.rbs +590 -0
- data/stdlib/socket/0/constants.rbs +2295 -0
- data/stdlib/socket/0/ip_socket.rbs +92 -0
- data/stdlib/socket/0/socket.rbs +4157 -0
- data/stdlib/socket/0/socket_error.rbs +5 -0
- data/stdlib/socket/0/tcp_server.rbs +192 -0
- data/stdlib/socket/0/tcp_socket.rbs +79 -0
- data/stdlib/socket/0/udp_socket.rbs +133 -0
- data/stdlib/socket/0/unix_server.rbs +169 -0
- data/stdlib/socket/0/unix_socket.rbs +172 -0
- data/stdlib/stringio/0/stringio.rbs +567 -0
- data/stdlib/strscan/0/string_scanner.rbs +1627 -0
- data/stdlib/tempfile/0/tempfile.rbs +479 -0
- data/stdlib/time/0/time.rbs +432 -0
- data/stdlib/timeout/0/timeout.rbs +81 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
- data/stdlib/tsort/0/cyclic.rbs +5 -0
- data/stdlib/tsort/0/interfaces.rbs +20 -0
- data/stdlib/tsort/0/tsort.rbs +409 -0
- data/stdlib/uri/0/common.rbs +582 -0
- data/stdlib/uri/0/file.rbs +118 -0
- data/stdlib/uri/0/ftp.rbs +13 -0
- data/stdlib/uri/0/generic.rbs +1108 -0
- data/stdlib/uri/0/http.rbs +104 -0
- data/stdlib/uri/0/https.rbs +14 -0
- data/stdlib/uri/0/ldap.rbs +230 -0
- data/stdlib/uri/0/ldaps.rbs +14 -0
- data/stdlib/uri/0/mailto.rbs +92 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
- data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
- data/stdlib/uri/0/ws.rbs +13 -0
- data/stdlib/uri/0/wss.rbs +9 -0
- data/stdlib/yaml/0/manifest.yaml +2 -0
- data/stdlib/yaml/0/yaml.rbs +1 -0
- data/stdlib/zlib/0/buf_error.rbs +10 -0
- data/stdlib/zlib/0/data_error.rbs +10 -0
- data/stdlib/zlib/0/deflate.rbs +210 -0
- data/stdlib/zlib/0/error.rbs +20 -0
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
- data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
- data/stdlib/zlib/0/gzip_file.rbs +156 -0
- data/stdlib/zlib/0/gzip_reader.rbs +293 -0
- data/stdlib/zlib/0/gzip_writer.rbs +166 -0
- data/stdlib/zlib/0/inflate.rbs +180 -0
- data/stdlib/zlib/0/mem_error.rbs +10 -0
- data/stdlib/zlib/0/need_dict.rbs +13 -0
- data/stdlib/zlib/0/stream_end.rbs +11 -0
- data/stdlib/zlib/0/stream_error.rbs +11 -0
- data/stdlib/zlib/0/version_error.rbs +11 -0
- data/stdlib/zlib/0/zlib.rbs +449 -0
- data/stdlib/zlib/0/zstream.rbs +200 -0
- metadata +532 -0
@@ -0,0 +1,1229 @@
|
|
1
|
+
module RBS
|
2
|
+
module Unnamed
|
3
|
+
# <!-- rdoc-file=io.c -->
|
4
|
+
# ## ARGF and `ARGV`
|
5
|
+
#
|
6
|
+
# The ARGF object works with the array at global variable `ARGV` to make
|
7
|
+
# `$stdin` and file streams available in the Ruby program:
|
8
|
+
#
|
9
|
+
# * **ARGV** may be thought of as the **argument vector** array.
|
10
|
+
#
|
11
|
+
# Initially, it contains the command-line arguments and options that are
|
12
|
+
# passed to the Ruby program; the program can modify that array as it likes.
|
13
|
+
#
|
14
|
+
# * **ARGF** may be thought of as the **argument files** object.
|
15
|
+
#
|
16
|
+
# It can access file streams and/or the `$stdin` stream, based on what it
|
17
|
+
# finds in `ARGV`. This provides a convenient way for the command line to
|
18
|
+
# specify streams for a Ruby program to read.
|
19
|
+
#
|
20
|
+
# ## Reading
|
21
|
+
#
|
22
|
+
# ARGF may read from *source* streams, which at any particular time are
|
23
|
+
# determined by the content of `ARGV`.
|
24
|
+
#
|
25
|
+
# ### Simplest Case
|
26
|
+
#
|
27
|
+
# When the *very first* ARGF read occurs with an empty `ARGV` (`[]`), the source
|
28
|
+
# is `$stdin`:
|
29
|
+
#
|
30
|
+
# * File `t.rb`:
|
31
|
+
#
|
32
|
+
# p ['ARGV', ARGV]
|
33
|
+
# p ['ARGF.read', ARGF.read]
|
34
|
+
#
|
35
|
+
# * Commands and outputs (see below for the content of files `foo.txt` and
|
36
|
+
# `bar.txt`):
|
37
|
+
#
|
38
|
+
# $ echo "Open the pod bay doors, Hal." | ruby t.rb
|
39
|
+
# ["ARGV", []]
|
40
|
+
# ["ARGF.read", "Open the pod bay doors, Hal.\n"]
|
41
|
+
#
|
42
|
+
# $ cat foo.txt bar.txt | ruby t.rb
|
43
|
+
# ["ARGV", []]
|
44
|
+
# ["ARGF.read", "Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"]
|
45
|
+
#
|
46
|
+
# ### About the Examples
|
47
|
+
#
|
48
|
+
# Many examples here assume the existence of files `foo.txt` and `bar.txt`:
|
49
|
+
#
|
50
|
+
# $ cat foo.txt
|
51
|
+
# Foo 0
|
52
|
+
# Foo 1
|
53
|
+
# $ cat bar.txt
|
54
|
+
# Bar 0
|
55
|
+
# Bar 1
|
56
|
+
# Bar 2
|
57
|
+
# Bar 3
|
58
|
+
#
|
59
|
+
# ### Sources in `ARGV`
|
60
|
+
#
|
61
|
+
# For any ARGF read *except* the [simplest case](rdoc-ref:ARGF@Simplest+Case)
|
62
|
+
# (that is, *except* for the *very first* ARGF read with an empty `ARGV`), the
|
63
|
+
# sources are found in `ARGV`.
|
64
|
+
#
|
65
|
+
# ARGF assumes that each element in array `ARGV` is a potential source, and is
|
66
|
+
# one of:
|
67
|
+
#
|
68
|
+
# * The string path to a file that may be opened as a stream.
|
69
|
+
# * The character `'-'`, meaning stream `$stdin`.
|
70
|
+
#
|
71
|
+
# Each element that is *not* one of these should be removed from `ARGV` before
|
72
|
+
# ARGF accesses that source.
|
73
|
+
#
|
74
|
+
# In the following example:
|
75
|
+
#
|
76
|
+
# * Filepaths `foo.txt` and `bar.txt` may be retained as potential sources.
|
77
|
+
# * Options `--xyzzy` and `--mojo` should be removed.
|
78
|
+
#
|
79
|
+
# Example:
|
80
|
+
#
|
81
|
+
# * File `t.rb`:
|
82
|
+
#
|
83
|
+
# # Print arguments (and options, if any) found on command line.
|
84
|
+
# p ['ARGV', ARGV]
|
85
|
+
#
|
86
|
+
# * Command and output:
|
87
|
+
#
|
88
|
+
# $ ruby t.rb --xyzzy --mojo foo.txt bar.txt
|
89
|
+
# ["ARGV", ["--xyzzy", "--mojo", "foo.txt", "bar.txt"]]
|
90
|
+
#
|
91
|
+
# ARGF's stream access considers the elements of `ARGV`, left to right:
|
92
|
+
#
|
93
|
+
# * File `t.rb`:
|
94
|
+
#
|
95
|
+
# p "ARGV: #{ARGV}"
|
96
|
+
# p "Line: #{ARGF.read}" # Read everything from all specified streams.
|
97
|
+
#
|
98
|
+
# * Command and output:
|
99
|
+
#
|
100
|
+
# $ ruby t.rb foo.txt bar.txt
|
101
|
+
# "ARGV: [\"foo.txt\", \"bar.txt\"]"
|
102
|
+
# "Read: Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"
|
103
|
+
#
|
104
|
+
# Because the value at `ARGV` is an ordinary array, you can manipulate it to
|
105
|
+
# control which sources ARGF considers:
|
106
|
+
#
|
107
|
+
# * If you remove an element from `ARGV`, ARGF will not consider the
|
108
|
+
# corresponding source.
|
109
|
+
# * If you add an element to `ARGV`, ARGF will consider the corresponding
|
110
|
+
# source.
|
111
|
+
#
|
112
|
+
# Each element in `ARGV` is removed when its corresponding source is accessed;
|
113
|
+
# when all sources have been accessed, the array is empty:
|
114
|
+
#
|
115
|
+
# * File `t.rb`:
|
116
|
+
#
|
117
|
+
# until ARGV.empty? && ARGF.eof?
|
118
|
+
# p "ARGV: #{ARGV}"
|
119
|
+
# p "Line: #{ARGF.readline}" # Read each line from each specified stream.
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
# * Command and output:
|
123
|
+
#
|
124
|
+
# $ ruby t.rb foo.txt bar.txt
|
125
|
+
# "ARGV: [\"foo.txt\", \"bar.txt\"]"
|
126
|
+
# "Line: Foo 0\n"
|
127
|
+
# "ARGV: [\"bar.txt\"]"
|
128
|
+
# "Line: Foo 1\n"
|
129
|
+
# "ARGV: [\"bar.txt\"]"
|
130
|
+
# "Line: Bar 0\n"
|
131
|
+
# "ARGV: []"
|
132
|
+
# "Line: Bar 1\n"
|
133
|
+
# "ARGV: []"
|
134
|
+
# "Line: Bar 2\n"
|
135
|
+
# "ARGV: []"
|
136
|
+
# "Line: Bar 3\n"
|
137
|
+
#
|
138
|
+
# #### Filepaths in `ARGV`
|
139
|
+
#
|
140
|
+
# The `ARGV` array may contain filepaths the specify sources for ARGF reading.
|
141
|
+
#
|
142
|
+
# This program prints what it reads from files at the paths specified on the
|
143
|
+
# command line:
|
144
|
+
#
|
145
|
+
# * File `t.rb`:
|
146
|
+
#
|
147
|
+
# p ['ARGV', ARGV]
|
148
|
+
# # Read and print all content from the specified sources.
|
149
|
+
# p ['ARGF.read', ARGF.read]
|
150
|
+
#
|
151
|
+
# * Command and output:
|
152
|
+
#
|
153
|
+
# $ ruby t.rb foo.txt bar.txt
|
154
|
+
# ["ARGV", [foo.txt, bar.txt]
|
155
|
+
# ["ARGF.read", "Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"]
|
156
|
+
#
|
157
|
+
# #### Specifying `$stdin` in `ARGV`
|
158
|
+
#
|
159
|
+
# To specify stream `$stdin` in `ARGV`, us the character `'-'`:
|
160
|
+
#
|
161
|
+
# * File `t.rb`:
|
162
|
+
#
|
163
|
+
# p ['ARGV', ARGV]
|
164
|
+
# p ['ARGF.read', ARGF.read]
|
165
|
+
#
|
166
|
+
# * Command and output:
|
167
|
+
#
|
168
|
+
# $ echo "Open the pod bay doors, Hal." | ruby t.rb -
|
169
|
+
# ["ARGV", ["-"]]
|
170
|
+
# ["ARGF.read", "Open the pod bay doors, Hal.\n"]
|
171
|
+
#
|
172
|
+
# When no character `'-'` is given, stream `$stdin` is ignored (exception: see
|
173
|
+
# [Specifying $stdin in ARGV](rdoc-ref:ARGF@Specifying+-24stdin+in+ARGV)):
|
174
|
+
#
|
175
|
+
# * Command and output:
|
176
|
+
#
|
177
|
+
# $ echo "Open the pod bay doors, Hal." | ruby t.rb foo.txt bar.txt
|
178
|
+
# "ARGV: [\"foo.txt\", \"bar.txt\"]"
|
179
|
+
# "Read: Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"
|
180
|
+
#
|
181
|
+
# #### Mixtures and Repetitions in `ARGV`
|
182
|
+
#
|
183
|
+
# For an ARGF reader, `ARGV` may contain any mixture of filepaths and character
|
184
|
+
# `'-'`, including repetitions.
|
185
|
+
#
|
186
|
+
# #### Modifications to `ARGV`
|
187
|
+
#
|
188
|
+
# The running Ruby program may make any modifications to the `ARGV` array; the
|
189
|
+
# current value of `ARGV` affects ARGF reading.
|
190
|
+
#
|
191
|
+
# #### Empty `ARGV`
|
192
|
+
#
|
193
|
+
# For an empty `ARGV`, an ARGF read method either returns `nil` or raises an
|
194
|
+
# exception, depending on the specific method.
|
195
|
+
#
|
196
|
+
# ### More Read Methods
|
197
|
+
#
|
198
|
+
# As seen above, method ARGF#read reads the content of all sources into a single
|
199
|
+
# string. Other ARGF methods provide other ways to access that content; these
|
200
|
+
# include:
|
201
|
+
#
|
202
|
+
# * Byte access: #each_byte, #getbyte, #readbyte.
|
203
|
+
# * Character access: #each_char, #getc, #readchar.
|
204
|
+
# * Codepoint access: #each_codepoint.
|
205
|
+
# * Line access: #each_line, #gets, #readline, #readlines.
|
206
|
+
# * Source access: #read, #read_nonblock, #readpartial.
|
207
|
+
#
|
208
|
+
# ### About Enumerable
|
209
|
+
#
|
210
|
+
# ARGF includes module Enumerable. Virtually all methods in Enumerable call
|
211
|
+
# method `#each` in the including class.
|
212
|
+
#
|
213
|
+
# **Note well**: In ARGF, method #each returns data from the *sources*, *not*
|
214
|
+
# from `ARGV`; therefore, for example, `ARGF#entries` returns an array of lines
|
215
|
+
# from the sources, not an array of the strings from `ARGV`:
|
216
|
+
#
|
217
|
+
# * File `t.rb`:
|
218
|
+
#
|
219
|
+
# p ['ARGV', ARGV]
|
220
|
+
# p ['ARGF.entries', ARGF.entries]
|
221
|
+
#
|
222
|
+
# * Command and output:
|
223
|
+
#
|
224
|
+
# $ ruby t.rb foo.txt bar.txt
|
225
|
+
# ["ARGV", ["foo.txt", "bar.txt"]]
|
226
|
+
# ["ARGF.entries", ["Foo 0\n", "Foo 1\n", "Bar 0\n", "Bar 1\n", "Bar 2\n", "Bar 3\n"]]
|
227
|
+
#
|
228
|
+
# ## Writing
|
229
|
+
#
|
230
|
+
# If *inplace mode* is in effect, ARGF may write to target streams, which at any
|
231
|
+
# particular time are determined by the content of ARGV.
|
232
|
+
#
|
233
|
+
# Methods about inplace mode:
|
234
|
+
#
|
235
|
+
# * #inplace_mode
|
236
|
+
# * #inplace_mode=
|
237
|
+
# * #to_write_io
|
238
|
+
#
|
239
|
+
# Methods for writing:
|
240
|
+
#
|
241
|
+
# * #print
|
242
|
+
# * #printf
|
243
|
+
# * #putc
|
244
|
+
# * #puts
|
245
|
+
# * #write
|
246
|
+
#
|
247
|
+
%a{annotate:rdoc:copy:ARGF}
|
248
|
+
class ARGFClass
|
249
|
+
include Enumerable[String]
|
250
|
+
|
251
|
+
# <!--
|
252
|
+
# rdoc-file=io.c
|
253
|
+
# - ARGF.argv -> ARGV
|
254
|
+
# -->
|
255
|
+
# Returns the `ARGV` array, which contains the arguments passed to your script,
|
256
|
+
# one per element.
|
257
|
+
#
|
258
|
+
# For example:
|
259
|
+
#
|
260
|
+
# $ ruby argf.rb -v glark.txt
|
261
|
+
#
|
262
|
+
# ARGF.argv #=> ["-v", "glark.txt"]
|
263
|
+
#
|
264
|
+
%a{annotate:rdoc:copy:ARGF#argv}
|
265
|
+
def argv: () -> ::Array[String]
|
266
|
+
|
267
|
+
# <!--
|
268
|
+
# rdoc-file=io.c
|
269
|
+
# - ARGF.binmode -> ARGF
|
270
|
+
# -->
|
271
|
+
# Puts ARGF into binary mode. Once a stream is in binary mode, it cannot be
|
272
|
+
# reset to non-binary mode. This option has the following effects:
|
273
|
+
#
|
274
|
+
# * Newline conversion is disabled.
|
275
|
+
# * Encoding conversion is disabled.
|
276
|
+
# * Content is treated as ASCII-8BIT.
|
277
|
+
#
|
278
|
+
%a{annotate:rdoc:copy:ARGF#binmode}
|
279
|
+
def binmode: () -> self
|
280
|
+
|
281
|
+
# <!--
|
282
|
+
# rdoc-file=io.c
|
283
|
+
# - ARGF.binmode? -> true or false
|
284
|
+
# -->
|
285
|
+
# Returns true if ARGF is being read in binary mode; false otherwise. To enable
|
286
|
+
# binary mode use ARGF.binmode.
|
287
|
+
#
|
288
|
+
# For example:
|
289
|
+
#
|
290
|
+
# ARGF.binmode? #=> false
|
291
|
+
# ARGF.binmode
|
292
|
+
# ARGF.binmode? #=> true
|
293
|
+
#
|
294
|
+
%a{annotate:rdoc:copy:ARGF#binmode?}
|
295
|
+
def binmode?: () -> bool
|
296
|
+
|
297
|
+
# <!--
|
298
|
+
# rdoc-file=io.c
|
299
|
+
# - ARGF.close -> ARGF
|
300
|
+
# -->
|
301
|
+
# Closes the current file and skips to the next file in ARGV. If there are no
|
302
|
+
# more files to open, just closes the current file. STDIN will not be closed.
|
303
|
+
#
|
304
|
+
# For example:
|
305
|
+
#
|
306
|
+
# $ ruby argf.rb foo bar
|
307
|
+
#
|
308
|
+
# ARGF.filename #=> "foo"
|
309
|
+
# ARGF.close
|
310
|
+
# ARGF.filename #=> "bar"
|
311
|
+
# ARGF.close
|
312
|
+
#
|
313
|
+
%a{annotate:rdoc:copy:ARGF#close}
|
314
|
+
def close: () -> self
|
315
|
+
|
316
|
+
# <!--
|
317
|
+
# rdoc-file=io.c
|
318
|
+
# - ARGF.closed? -> true or false
|
319
|
+
# -->
|
320
|
+
# Returns *true* if the current file has been closed; *false* otherwise. Use
|
321
|
+
# ARGF.close to actually close the current file.
|
322
|
+
#
|
323
|
+
%a{annotate:rdoc:copy:ARGF#closed?}
|
324
|
+
def closed?: () -> bool
|
325
|
+
|
326
|
+
# <!--
|
327
|
+
# rdoc-file=io.c
|
328
|
+
# - ARGF.each(sep=$/) {|line| block } -> ARGF
|
329
|
+
# - ARGF.each(sep=$/, limit) {|line| block } -> ARGF
|
330
|
+
# - ARGF.each(...) -> an_enumerator
|
331
|
+
# - ARGF.each_line(sep=$/) {|line| block } -> ARGF
|
332
|
+
# - ARGF.each_line(sep=$/, limit) {|line| block } -> ARGF
|
333
|
+
# - ARGF.each_line(...) -> an_enumerator
|
334
|
+
# -->
|
335
|
+
# Returns an enumerator which iterates over each line (separated by *sep*, which
|
336
|
+
# defaults to your platform's newline character) of each file in `ARGV`. If a
|
337
|
+
# block is supplied, each line in turn will be yielded to the block, otherwise
|
338
|
+
# an enumerator is returned. The optional *limit* argument is an Integer
|
339
|
+
# specifying the maximum length of each line; longer lines will be split
|
340
|
+
# according to this limit.
|
341
|
+
#
|
342
|
+
# This method allows you to treat the files supplied on the command line as a
|
343
|
+
# single file consisting of the concatenation of each named file. After the last
|
344
|
+
# line of the first file has been returned, the first line of the second file is
|
345
|
+
# returned. The ARGF.filename and ARGF.lineno methods can be used to determine
|
346
|
+
# the filename of the current line and line number of the whole input,
|
347
|
+
# respectively.
|
348
|
+
#
|
349
|
+
# For example, the following code prints out each line of each named file
|
350
|
+
# prefixed with its line number, displaying the filename once per file:
|
351
|
+
#
|
352
|
+
# ARGF.each_line do |line|
|
353
|
+
# puts ARGF.filename if ARGF.file.lineno == 1
|
354
|
+
# puts "#{ARGF.file.lineno}: #{line}"
|
355
|
+
# end
|
356
|
+
#
|
357
|
+
# While the following code prints only the first file's name at first, and the
|
358
|
+
# contents with line number counted through all named files.
|
359
|
+
#
|
360
|
+
# ARGF.each_line do |line|
|
361
|
+
# puts ARGF.filename if ARGF.lineno == 1
|
362
|
+
# puts "#{ARGF.lineno}: #{line}"
|
363
|
+
# end
|
364
|
+
#
|
365
|
+
%a{annotate:rdoc:copy:ARGF#each}
|
366
|
+
def each: (?String sep, ?Integer limit) { (String line) -> untyped } -> self
|
367
|
+
| (?String sep, ?Integer limit) -> ::Enumerator[String, self]
|
368
|
+
|
369
|
+
# <!--
|
370
|
+
# rdoc-file=io.c
|
371
|
+
# - ARGF.each_byte {|byte| block } -> ARGF
|
372
|
+
# - ARGF.each_byte -> an_enumerator
|
373
|
+
# -->
|
374
|
+
# Iterates over each byte of each file in `ARGV`. A byte is returned as an
|
375
|
+
# Integer in the range 0..255.
|
376
|
+
#
|
377
|
+
# This method allows you to treat the files supplied on the command line as a
|
378
|
+
# single file consisting of the concatenation of each named file. After the last
|
379
|
+
# byte of the first file has been returned, the first byte of the second file is
|
380
|
+
# returned. The ARGF.filename method can be used to determine the filename of
|
381
|
+
# the current byte.
|
382
|
+
#
|
383
|
+
# If no block is given, an enumerator is returned instead.
|
384
|
+
#
|
385
|
+
# For example:
|
386
|
+
#
|
387
|
+
# ARGF.bytes.to_a #=> [35, 32, ... 95, 10]
|
388
|
+
#
|
389
|
+
%a{annotate:rdoc:copy:ARGF#each_byte}
|
390
|
+
def each_byte: () { (Integer byte) -> untyped } -> self
|
391
|
+
| () -> ::Enumerator[Integer, self]
|
392
|
+
|
393
|
+
# <!--
|
394
|
+
# rdoc-file=io.c
|
395
|
+
# - ARGF.each_char {|char| block } -> ARGF
|
396
|
+
# - ARGF.each_char -> an_enumerator
|
397
|
+
# -->
|
398
|
+
# Iterates over each character of each file in ARGF.
|
399
|
+
#
|
400
|
+
# This method allows you to treat the files supplied on the command line as a
|
401
|
+
# single file consisting of the concatenation of each named file. After the last
|
402
|
+
# character of the first file has been returned, the first character of the
|
403
|
+
# second file is returned. The ARGF.filename method can be used to determine the
|
404
|
+
# name of the file in which the current character appears.
|
405
|
+
#
|
406
|
+
# If no block is given, an enumerator is returned instead.
|
407
|
+
#
|
408
|
+
%a{annotate:rdoc:copy:ARGF#each_char}
|
409
|
+
def each_char: () { (String char) -> untyped } -> self
|
410
|
+
| () -> ::Enumerator[String, self]
|
411
|
+
|
412
|
+
# <!--
|
413
|
+
# rdoc-file=io.c
|
414
|
+
# - ARGF.each_codepoint {|codepoint| block } -> ARGF
|
415
|
+
# - ARGF.each_codepoint -> an_enumerator
|
416
|
+
# -->
|
417
|
+
# Iterates over each codepoint of each file in ARGF.
|
418
|
+
#
|
419
|
+
# This method allows you to treat the files supplied on the command line as a
|
420
|
+
# single file consisting of the concatenation of each named file. After the last
|
421
|
+
# codepoint of the first file has been returned, the first codepoint of the
|
422
|
+
# second file is returned. The ARGF.filename method can be used to determine the
|
423
|
+
# name of the file in which the current codepoint appears.
|
424
|
+
#
|
425
|
+
# If no block is given, an enumerator is returned instead.
|
426
|
+
#
|
427
|
+
%a{annotate:rdoc:copy:ARGF#each_codepoint}
|
428
|
+
def each_codepoint: () { (Integer codepoint) -> untyped } -> self
|
429
|
+
| () -> ::Enumerator[Integer, self]
|
430
|
+
|
431
|
+
# <!-- rdoc-file=io.c -->
|
432
|
+
# Returns an enumerator which iterates over each line (separated by *sep*, which
|
433
|
+
# defaults to your platform's newline character) of each file in `ARGV`. If a
|
434
|
+
# block is supplied, each line in turn will be yielded to the block, otherwise
|
435
|
+
# an enumerator is returned. The optional *limit* argument is an Integer
|
436
|
+
# specifying the maximum length of each line; longer lines will be split
|
437
|
+
# according to this limit.
|
438
|
+
#
|
439
|
+
# This method allows you to treat the files supplied on the command line as a
|
440
|
+
# single file consisting of the concatenation of each named file. After the last
|
441
|
+
# line of the first file has been returned, the first line of the second file is
|
442
|
+
# returned. The ARGF.filename and ARGF.lineno methods can be used to determine
|
443
|
+
# the filename of the current line and line number of the whole input,
|
444
|
+
# respectively.
|
445
|
+
#
|
446
|
+
# For example, the following code prints out each line of each named file
|
447
|
+
# prefixed with its line number, displaying the filename once per file:
|
448
|
+
#
|
449
|
+
# ARGF.each_line do |line|
|
450
|
+
# puts ARGF.filename if ARGF.file.lineno == 1
|
451
|
+
# puts "#{ARGF.file.lineno}: #{line}"
|
452
|
+
# end
|
453
|
+
#
|
454
|
+
# While the following code prints only the first file's name at first, and the
|
455
|
+
# contents with line number counted through all named files.
|
456
|
+
#
|
457
|
+
# ARGF.each_line do |line|
|
458
|
+
# puts ARGF.filename if ARGF.lineno == 1
|
459
|
+
# puts "#{ARGF.lineno}: #{line}"
|
460
|
+
# end
|
461
|
+
#
|
462
|
+
%a{annotate:rdoc:copy:ARGF#each_line}
|
463
|
+
def each_line: (?String sep, ?Integer limit) { (String line) -> untyped } -> self
|
464
|
+
| (?String sep, ?Integer limit) -> ::Enumerator[String, self]
|
465
|
+
|
466
|
+
# <!--
|
467
|
+
# rdoc-file=io.c
|
468
|
+
# - ARGF.eof? -> true or false
|
469
|
+
# - ARGF.eof -> true or false
|
470
|
+
# -->
|
471
|
+
# Returns true if the current file in ARGF is at end of file, i.e. it has no
|
472
|
+
# data to read. The stream must be opened for reading or an IOError will be
|
473
|
+
# raised.
|
474
|
+
#
|
475
|
+
# $ echo "eof" | ruby argf.rb
|
476
|
+
#
|
477
|
+
# ARGF.eof? #=> false
|
478
|
+
# 3.times { ARGF.readchar }
|
479
|
+
# ARGF.eof? #=> false
|
480
|
+
# ARGF.readchar #=> "\n"
|
481
|
+
# ARGF.eof? #=> true
|
482
|
+
#
|
483
|
+
%a{annotate:rdoc:copy:ARGF#eof}
|
484
|
+
def eof: () -> bool
|
485
|
+
|
486
|
+
# <!-- rdoc-file=io.c -->
|
487
|
+
# Returns true if the current file in ARGF is at end of file, i.e. it has no
|
488
|
+
# data to read. The stream must be opened for reading or an IOError will be
|
489
|
+
# raised.
|
490
|
+
#
|
491
|
+
# $ echo "eof" | ruby argf.rb
|
492
|
+
#
|
493
|
+
# ARGF.eof? #=> false
|
494
|
+
# 3.times { ARGF.readchar }
|
495
|
+
# ARGF.eof? #=> false
|
496
|
+
# ARGF.readchar #=> "\n"
|
497
|
+
# ARGF.eof? #=> true
|
498
|
+
#
|
499
|
+
%a{annotate:rdoc:copy:ARGF#eof?}
|
500
|
+
def eof?: () -> bool
|
501
|
+
|
502
|
+
# <!--
|
503
|
+
# rdoc-file=io.c
|
504
|
+
# - ARGF.external_encoding -> encoding
|
505
|
+
# -->
|
506
|
+
# Returns the external encoding for files read from ARGF as an Encoding object.
|
507
|
+
# The external encoding is the encoding of the text as stored in a file.
|
508
|
+
# Contrast with ARGF.internal_encoding, which is the encoding used to represent
|
509
|
+
# this text within Ruby.
|
510
|
+
#
|
511
|
+
# To set the external encoding use ARGF.set_encoding.
|
512
|
+
#
|
513
|
+
# For example:
|
514
|
+
#
|
515
|
+
# ARGF.external_encoding #=> #<Encoding:UTF-8>
|
516
|
+
#
|
517
|
+
%a{annotate:rdoc:copy:ARGF#external_encoding}
|
518
|
+
def external_encoding: () -> Encoding
|
519
|
+
|
520
|
+
# <!--
|
521
|
+
# rdoc-file=io.c
|
522
|
+
# - ARGF.file -> IO or File object
|
523
|
+
# -->
|
524
|
+
# Returns the current file as an IO or File object. `$stdin` is returned when
|
525
|
+
# the current file is STDIN.
|
526
|
+
#
|
527
|
+
# For example:
|
528
|
+
#
|
529
|
+
# $ echo "foo" > foo
|
530
|
+
# $ echo "bar" > bar
|
531
|
+
#
|
532
|
+
# $ ruby argf.rb foo bar
|
533
|
+
#
|
534
|
+
# ARGF.file #=> #<File:foo>
|
535
|
+
# ARGF.read(5) #=> "foo\nb"
|
536
|
+
# ARGF.file #=> #<File:bar>
|
537
|
+
#
|
538
|
+
%a{annotate:rdoc:copy:ARGF#file}
|
539
|
+
def file: () -> (IO | File)
|
540
|
+
|
541
|
+
# <!--
|
542
|
+
# rdoc-file=io.c
|
543
|
+
# - ARGF.filename -> String
|
544
|
+
# - ARGF.path -> String
|
545
|
+
# -->
|
546
|
+
# Returns the current filename. "-" is returned when the current file is STDIN.
|
547
|
+
#
|
548
|
+
# For example:
|
549
|
+
#
|
550
|
+
# $ echo "foo" > foo
|
551
|
+
# $ echo "bar" > bar
|
552
|
+
# $ echo "glark" > glark
|
553
|
+
#
|
554
|
+
# $ ruby argf.rb foo bar glark
|
555
|
+
#
|
556
|
+
# ARGF.filename #=> "foo"
|
557
|
+
# ARGF.read(5) #=> "foo\nb"
|
558
|
+
# ARGF.filename #=> "bar"
|
559
|
+
# ARGF.skip
|
560
|
+
# ARGF.filename #=> "glark"
|
561
|
+
#
|
562
|
+
%a{annotate:rdoc:copy:ARGF#filename}
|
563
|
+
def filename: () -> String
|
564
|
+
|
565
|
+
# <!--
|
566
|
+
# rdoc-file=io.c
|
567
|
+
# - ARGF.fileno -> integer
|
568
|
+
# - ARGF.to_i -> integer
|
569
|
+
# -->
|
570
|
+
# Returns an integer representing the numeric file descriptor for the current
|
571
|
+
# file. Raises an ArgumentError if there isn't a current file.
|
572
|
+
#
|
573
|
+
# ARGF.fileno #=> 3
|
574
|
+
#
|
575
|
+
%a{annotate:rdoc:copy:ARGF#fileno}
|
576
|
+
def fileno: () -> Integer
|
577
|
+
|
578
|
+
# <!--
|
579
|
+
# rdoc-file=io.c
|
580
|
+
# - ARGF.getbyte -> Integer or nil
|
581
|
+
# -->
|
582
|
+
# Gets the next 8-bit byte (0..255) from ARGF. Returns `nil` if called at the
|
583
|
+
# end of the stream.
|
584
|
+
#
|
585
|
+
# For example:
|
586
|
+
#
|
587
|
+
# $ echo "foo" > file
|
588
|
+
# $ ruby argf.rb file
|
589
|
+
#
|
590
|
+
# ARGF.getbyte #=> 102
|
591
|
+
# ARGF.getbyte #=> 111
|
592
|
+
# ARGF.getbyte #=> 111
|
593
|
+
# ARGF.getbyte #=> 10
|
594
|
+
# ARGF.getbyte #=> nil
|
595
|
+
#
|
596
|
+
%a{annotate:rdoc:copy:ARGF#getbyte}
|
597
|
+
def getbyte: () -> Integer?
|
598
|
+
|
599
|
+
# <!--
|
600
|
+
# rdoc-file=io.c
|
601
|
+
# - ARGF.getc -> String or nil
|
602
|
+
# -->
|
603
|
+
# Reads the next character from ARGF and returns it as a String. Returns `nil`
|
604
|
+
# at the end of the stream.
|
605
|
+
#
|
606
|
+
# ARGF treats the files named on the command line as a single file created by
|
607
|
+
# concatenating their contents. After returning the last character of the first
|
608
|
+
# file, it returns the first character of the second file, and so on.
|
609
|
+
#
|
610
|
+
# For example:
|
611
|
+
#
|
612
|
+
# $ echo "foo" > file
|
613
|
+
# $ ruby argf.rb file
|
614
|
+
#
|
615
|
+
# ARGF.getc #=> "f"
|
616
|
+
# ARGF.getc #=> "o"
|
617
|
+
# ARGF.getc #=> "o"
|
618
|
+
# ARGF.getc #=> "\n"
|
619
|
+
# ARGF.getc #=> nil
|
620
|
+
# ARGF.getc #=> nil
|
621
|
+
#
|
622
|
+
%a{annotate:rdoc:copy:ARGF#getc}
|
623
|
+
def getc: () -> String?
|
624
|
+
|
625
|
+
# <!--
|
626
|
+
# rdoc-file=io.c
|
627
|
+
# - ARGF.gets(sep=$/ [, getline_args]) -> string or nil
|
628
|
+
# - ARGF.gets(limit [, getline_args]) -> string or nil
|
629
|
+
# - ARGF.gets(sep, limit [, getline_args]) -> string or nil
|
630
|
+
# -->
|
631
|
+
# Returns the next line from the current file in ARGF.
|
632
|
+
#
|
633
|
+
# By default lines are assumed to be separated by `$/`; to use a different
|
634
|
+
# character as a separator, supply it as a String for the *sep* argument.
|
635
|
+
#
|
636
|
+
# The optional *limit* argument specifies how many characters of each line to
|
637
|
+
# return. By default all characters are returned.
|
638
|
+
#
|
639
|
+
# See IO.readlines for details about getline_args.
|
640
|
+
#
|
641
|
+
%a{annotate:rdoc:copy:ARGF#gets}
|
642
|
+
def gets: (?String sep, ?Integer limit) -> String?
|
643
|
+
|
644
|
+
# <!--
|
645
|
+
# rdoc-file=io.c
|
646
|
+
# - ARGF.inplace_mode -> String
|
647
|
+
# -->
|
648
|
+
# Returns the file extension appended to the names of backup copies of modified
|
649
|
+
# files under in-place edit mode. This value can be set using ARGF.inplace_mode=
|
650
|
+
# or passing the `-i` switch to the Ruby binary.
|
651
|
+
#
|
652
|
+
%a{annotate:rdoc:copy:ARGF#inplace_mode}
|
653
|
+
def inplace_mode: () -> String?
|
654
|
+
|
655
|
+
# <!--
|
656
|
+
# rdoc-file=io.c
|
657
|
+
# - ARGF.inplace_mode = ext -> ARGF
|
658
|
+
# -->
|
659
|
+
# Sets the filename extension for in-place editing mode to the given String. The
|
660
|
+
# backup copy of each file being edited has this value appended to its filename.
|
661
|
+
#
|
662
|
+
# For example:
|
663
|
+
#
|
664
|
+
# $ ruby argf.rb file.txt
|
665
|
+
#
|
666
|
+
# ARGF.inplace_mode = '.bak'
|
667
|
+
# ARGF.each_line do |line|
|
668
|
+
# print line.sub("foo","bar")
|
669
|
+
# end
|
670
|
+
#
|
671
|
+
# First, *file.txt.bak* is created as a backup copy of *file.txt*. Then, each
|
672
|
+
# line of *file.txt* has the first occurrence of "foo" replaced with "bar".
|
673
|
+
#
|
674
|
+
%a{annotate:rdoc:copy:ARGF#inplace_mode=}
|
675
|
+
def inplace_mode=: (String) -> self
|
676
|
+
|
677
|
+
alias inspect to_s
|
678
|
+
|
679
|
+
# <!--
|
680
|
+
# rdoc-file=io.c
|
681
|
+
# - ARGF.internal_encoding -> encoding
|
682
|
+
# -->
|
683
|
+
# Returns the internal encoding for strings read from ARGF as an Encoding
|
684
|
+
# object.
|
685
|
+
#
|
686
|
+
# If ARGF.set_encoding has been called with two encoding names, the second is
|
687
|
+
# returned. Otherwise, if `Encoding.default_external` has been set, that value
|
688
|
+
# is returned. Failing that, if a default external encoding was specified on the
|
689
|
+
# command-line, that value is used. If the encoding is unknown, `nil` is
|
690
|
+
# returned.
|
691
|
+
#
|
692
|
+
%a{annotate:rdoc:copy:ARGF#internal_encoding}
|
693
|
+
def internal_encoding: () -> Encoding
|
694
|
+
|
695
|
+
# <!--
|
696
|
+
# rdoc-file=io.c
|
697
|
+
# - ARGF.lineno -> integer
|
698
|
+
# -->
|
699
|
+
# Returns the current line number of ARGF as a whole. This value can be set
|
700
|
+
# manually with ARGF.lineno=.
|
701
|
+
#
|
702
|
+
# For example:
|
703
|
+
#
|
704
|
+
# ARGF.lineno #=> 0
|
705
|
+
# ARGF.readline #=> "This is line 1\n"
|
706
|
+
# ARGF.lineno #=> 1
|
707
|
+
#
|
708
|
+
%a{annotate:rdoc:copy:ARGF#lineno}
|
709
|
+
def lineno: () -> Integer
|
710
|
+
|
711
|
+
# <!--
|
712
|
+
# rdoc-file=io.c
|
713
|
+
# - ARGF.lineno = integer -> integer
|
714
|
+
# -->
|
715
|
+
# Sets the line number of ARGF as a whole to the given Integer.
|
716
|
+
#
|
717
|
+
# ARGF sets the line number automatically as you read data, so normally you will
|
718
|
+
# not need to set it explicitly. To access the current line number use
|
719
|
+
# ARGF.lineno.
|
720
|
+
#
|
721
|
+
# For example:
|
722
|
+
#
|
723
|
+
# ARGF.lineno #=> 0
|
724
|
+
# ARGF.readline #=> "This is line 1\n"
|
725
|
+
# ARGF.lineno #=> 1
|
726
|
+
# ARGF.lineno = 0 #=> 0
|
727
|
+
# ARGF.lineno #=> 0
|
728
|
+
#
|
729
|
+
%a{annotate:rdoc:copy:ARGF#lineno=}
|
730
|
+
def lineno=: (Integer) -> untyped
|
731
|
+
|
732
|
+
# <!-- rdoc-file=io.c -->
|
733
|
+
# Returns the current filename. "-" is returned when the current file is STDIN.
|
734
|
+
#
|
735
|
+
# For example:
|
736
|
+
#
|
737
|
+
# $ echo "foo" > foo
|
738
|
+
# $ echo "bar" > bar
|
739
|
+
# $ echo "glark" > glark
|
740
|
+
#
|
741
|
+
# $ ruby argf.rb foo bar glark
|
742
|
+
#
|
743
|
+
# ARGF.filename #=> "foo"
|
744
|
+
# ARGF.read(5) #=> "foo\nb"
|
745
|
+
# ARGF.filename #=> "bar"
|
746
|
+
# ARGF.skip
|
747
|
+
# ARGF.filename #=> "glark"
|
748
|
+
#
|
749
|
+
%a{annotate:rdoc:copy:ARGF#path}
|
750
|
+
def path: () -> String
|
751
|
+
|
752
|
+
# <!-- rdoc-file=io.c -->
|
753
|
+
# Returns the current offset (in bytes) of the current file in ARGF.
|
754
|
+
#
|
755
|
+
# ARGF.pos #=> 0
|
756
|
+
# ARGF.gets #=> "This is line one\n"
|
757
|
+
# ARGF.pos #=> 17
|
758
|
+
#
|
759
|
+
%a{annotate:rdoc:copy:ARGF#pos}
|
760
|
+
def pos: () -> Integer
|
761
|
+
|
762
|
+
# <!--
|
763
|
+
# rdoc-file=io.c
|
764
|
+
# - ARGF.pos = position -> Integer
|
765
|
+
# -->
|
766
|
+
# Seeks to the position given by *position* (in bytes) in ARGF.
|
767
|
+
#
|
768
|
+
# For example:
|
769
|
+
#
|
770
|
+
# ARGF.pos = 17
|
771
|
+
# ARGF.gets #=> "This is line two\n"
|
772
|
+
#
|
773
|
+
%a{annotate:rdoc:copy:ARGF#pos=}
|
774
|
+
def pos=: (Integer) -> Integer
|
775
|
+
|
776
|
+
# <!--
|
777
|
+
# rdoc-file=io.c
|
778
|
+
# - print(*objects) -> nil
|
779
|
+
# -->
|
780
|
+
# Writes the given objects to the stream; returns `nil`. Appends the output
|
781
|
+
# record separator `$OUTPUT_RECORD_SEPARATOR` (`$\`), if it is not `nil`. See
|
782
|
+
# [Line IO](rdoc-ref:IO@Line+IO).
|
783
|
+
#
|
784
|
+
# With argument `objects` given, for each object:
|
785
|
+
#
|
786
|
+
# * Converts via its method `to_s` if not a string.
|
787
|
+
# * Writes to the stream.
|
788
|
+
# * If not the last object, writes the output field separator
|
789
|
+
# `$OUTPUT_FIELD_SEPARATOR` (`$,`) if it is not `nil`.
|
790
|
+
#
|
791
|
+
# With default separators:
|
792
|
+
#
|
793
|
+
# f = File.open('t.tmp', 'w+')
|
794
|
+
# objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero']
|
795
|
+
# p $OUTPUT_RECORD_SEPARATOR
|
796
|
+
# p $OUTPUT_FIELD_SEPARATOR
|
797
|
+
# f.print(*objects)
|
798
|
+
# f.rewind
|
799
|
+
# p f.read
|
800
|
+
# f.close
|
801
|
+
#
|
802
|
+
# Output:
|
803
|
+
#
|
804
|
+
# nil
|
805
|
+
# nil
|
806
|
+
# "00.00/10+0izerozero"
|
807
|
+
#
|
808
|
+
# With specified separators:
|
809
|
+
#
|
810
|
+
# $\ = "\n"
|
811
|
+
# $, = ','
|
812
|
+
# f.rewind
|
813
|
+
# f.print(*objects)
|
814
|
+
# f.rewind
|
815
|
+
# p f.read
|
816
|
+
#
|
817
|
+
# Output:
|
818
|
+
#
|
819
|
+
# "0,0.0,0/1,0+0i,zero,zero\n"
|
820
|
+
#
|
821
|
+
# With no argument given, writes the content of `$_` (which is usually the most
|
822
|
+
# recent user input):
|
823
|
+
#
|
824
|
+
# f = File.open('t.tmp', 'w+')
|
825
|
+
# gets # Sets $_ to the most recent user input.
|
826
|
+
# f.print
|
827
|
+
# f.close
|
828
|
+
#
|
829
|
+
%a{annotate:rdoc:copy:ARGF#print}
|
830
|
+
def print: (*untyped args) -> nil
|
831
|
+
|
832
|
+
# <!--
|
833
|
+
# rdoc-file=io.c
|
834
|
+
# - printf(format_string, *objects) -> nil
|
835
|
+
# -->
|
836
|
+
# Formats and writes `objects` to the stream.
|
837
|
+
#
|
838
|
+
# For details on `format_string`, see [Format
|
839
|
+
# Specifications](rdoc-ref:format_specifications.rdoc).
|
840
|
+
#
|
841
|
+
%a{annotate:rdoc:copy:ARGF#printf}
|
842
|
+
def printf: (String format_string, *untyped args) -> nil
|
843
|
+
|
844
|
+
# <!--
|
845
|
+
# rdoc-file=io.c
|
846
|
+
# - putc(object) -> object
|
847
|
+
# -->
|
848
|
+
# Writes a character to the stream. See [Character
|
849
|
+
# IO](rdoc-ref:IO@Character+IO).
|
850
|
+
#
|
851
|
+
# If `object` is numeric, converts to integer if necessary, then writes the
|
852
|
+
# character whose code is the least significant byte; if `object` is a string,
|
853
|
+
# writes the first character:
|
854
|
+
#
|
855
|
+
# $stdout.putc "A"
|
856
|
+
# $stdout.putc 65
|
857
|
+
#
|
858
|
+
# Output:
|
859
|
+
#
|
860
|
+
# AA
|
861
|
+
#
|
862
|
+
%a{annotate:rdoc:copy:ARGF#putc}
|
863
|
+
def putc: (Numeric | String obj) -> untyped
|
864
|
+
|
865
|
+
# <!--
|
866
|
+
# rdoc-file=io.c
|
867
|
+
# - puts(*objects) -> nil
|
868
|
+
# -->
|
869
|
+
# Writes the given `objects` to the stream, which must be open for writing;
|
870
|
+
# returns `nil`.\ Writes a newline after each that does not already end with a
|
871
|
+
# newline sequence. If called without arguments, writes a newline. See [Line
|
872
|
+
# IO](rdoc-ref:IO@Line+IO).
|
873
|
+
#
|
874
|
+
# Note that each added newline is the character `"\n"<//tt>, not the output
|
875
|
+
# record separator (<tt>$\`).
|
876
|
+
#
|
877
|
+
# Treatment for each object:
|
878
|
+
#
|
879
|
+
# * String: writes the string.
|
880
|
+
# * Neither string nor array: writes `object.to_s`.
|
881
|
+
# * Array: writes each element of the array; arrays may be nested.
|
882
|
+
#
|
883
|
+
# To keep these examples brief, we define this helper method:
|
884
|
+
#
|
885
|
+
# def show(*objects)
|
886
|
+
# # Puts objects to file.
|
887
|
+
# f = File.new('t.tmp', 'w+')
|
888
|
+
# f.puts(objects)
|
889
|
+
# # Return file content.
|
890
|
+
# f.rewind
|
891
|
+
# p f.read
|
892
|
+
# f.close
|
893
|
+
# end
|
894
|
+
#
|
895
|
+
# # Strings without newlines.
|
896
|
+
# show('foo', 'bar', 'baz') # => "foo\nbar\nbaz\n"
|
897
|
+
# # Strings, some with newlines.
|
898
|
+
# show("foo\n", 'bar', "baz\n") # => "foo\nbar\nbaz\n"
|
899
|
+
#
|
900
|
+
# # Neither strings nor arrays:
|
901
|
+
# show(0, 0.0, Rational(0, 1), Complex(9, 0), :zero)
|
902
|
+
# # => "0\n0.0\n0/1\n9+0i\nzero\n"
|
903
|
+
#
|
904
|
+
# # Array of strings.
|
905
|
+
# show(['foo', "bar\n", 'baz']) # => "foo\nbar\nbaz\n"
|
906
|
+
# # Nested arrays.
|
907
|
+
# show([[[0, 1], 2, 3], 4, 5]) # => "0\n1\n2\n3\n4\n5\n"
|
908
|
+
#
|
909
|
+
%a{annotate:rdoc:copy:ARGF#puts}
|
910
|
+
def puts: (*untyped obj) -> nil
|
911
|
+
|
912
|
+
# <!--
|
913
|
+
# rdoc-file=io.c
|
914
|
+
# - ARGF.read([length [, outbuf]]) -> string, outbuf, or nil
|
915
|
+
# -->
|
916
|
+
# Reads *length* bytes from ARGF. The files named on the command line are
|
917
|
+
# concatenated and treated as a single file by this method, so when called
|
918
|
+
# without arguments the contents of this pseudo file are returned in their
|
919
|
+
# entirety.
|
920
|
+
#
|
921
|
+
# *length* must be a non-negative integer or `nil`.
|
922
|
+
#
|
923
|
+
# If *length* is a positive integer, `read` tries to read *length* bytes without
|
924
|
+
# any conversion (binary mode). It returns `nil` if an EOF is encountered before
|
925
|
+
# anything can be read. Fewer than *length* bytes are returned if an EOF is
|
926
|
+
# encountered during the read. In the case of an integer *length*, the resulting
|
927
|
+
# string is always in ASCII-8BIT encoding.
|
928
|
+
#
|
929
|
+
# If *length* is omitted or is `nil`, it reads until EOF and the encoding
|
930
|
+
# conversion is applied, if applicable. A string is returned even if EOF is
|
931
|
+
# encountered before any data is read.
|
932
|
+
#
|
933
|
+
# If *length* is zero, it returns an empty string (`""`).
|
934
|
+
#
|
935
|
+
# If the optional *outbuf* argument is present, it must reference a String,
|
936
|
+
# which will receive the data. The *outbuf* will contain only the received data
|
937
|
+
# after the method call even if it is not empty at the beginning.
|
938
|
+
#
|
939
|
+
# For example:
|
940
|
+
#
|
941
|
+
# $ echo "small" > small.txt
|
942
|
+
# $ echo "large" > large.txt
|
943
|
+
# $ ./glark.rb small.txt large.txt
|
944
|
+
#
|
945
|
+
# ARGF.read #=> "small\nlarge"
|
946
|
+
# ARGF.read(200) #=> "small\nlarge"
|
947
|
+
# ARGF.read(2) #=> "sm"
|
948
|
+
# ARGF.read(0) #=> ""
|
949
|
+
#
|
950
|
+
# Note that this method behaves like the fread() function in C. This means it
|
951
|
+
# retries to invoke read(2) system calls to read data with the specified length.
|
952
|
+
# If you need the behavior like a single read(2) system call, consider
|
953
|
+
# ARGF#readpartial or ARGF#read_nonblock.
|
954
|
+
#
|
955
|
+
%a{annotate:rdoc:copy:ARGF#read}
|
956
|
+
def read: (?int? length, ?string outbuf) -> String?
|
957
|
+
|
958
|
+
# <!--
|
959
|
+
# rdoc-file=io.c
|
960
|
+
# - ARGF.read_nonblock(maxlen[, options]) -> string
|
961
|
+
# - ARGF.read_nonblock(maxlen, outbuf[, options]) -> outbuf
|
962
|
+
# -->
|
963
|
+
# Reads at most *maxlen* bytes from the ARGF stream in non-blocking mode.
|
964
|
+
#
|
965
|
+
%a{annotate:rdoc:copy:ARGF#read_nonblock}
|
966
|
+
def read_nonblock: (int maxlen, ?string buf, **untyped options) -> String
|
967
|
+
|
968
|
+
# <!--
|
969
|
+
# rdoc-file=io.c
|
970
|
+
# - ARGF.readbyte -> Integer
|
971
|
+
# -->
|
972
|
+
# Reads the next 8-bit byte from ARGF and returns it as an Integer. Raises an
|
973
|
+
# EOFError after the last byte of the last file has been read.
|
974
|
+
#
|
975
|
+
# For example:
|
976
|
+
#
|
977
|
+
# $ echo "foo" > file
|
978
|
+
# $ ruby argf.rb file
|
979
|
+
#
|
980
|
+
# ARGF.readbyte #=> 102
|
981
|
+
# ARGF.readbyte #=> 111
|
982
|
+
# ARGF.readbyte #=> 111
|
983
|
+
# ARGF.readbyte #=> 10
|
984
|
+
# ARGF.readbyte #=> end of file reached (EOFError)
|
985
|
+
#
|
986
|
+
%a{annotate:rdoc:copy:ARGF#readbyte}
|
987
|
+
def readbyte: () -> Integer
|
988
|
+
|
989
|
+
# <!--
|
990
|
+
# rdoc-file=io.c
|
991
|
+
# - ARGF.readchar -> String or nil
|
992
|
+
# -->
|
993
|
+
# Reads the next character from ARGF and returns it as a String. Raises an
|
994
|
+
# EOFError after the last character of the last file has been read.
|
995
|
+
#
|
996
|
+
# For example:
|
997
|
+
#
|
998
|
+
# $ echo "foo" > file
|
999
|
+
# $ ruby argf.rb file
|
1000
|
+
#
|
1001
|
+
# ARGF.readchar #=> "f"
|
1002
|
+
# ARGF.readchar #=> "o"
|
1003
|
+
# ARGF.readchar #=> "o"
|
1004
|
+
# ARGF.readchar #=> "\n"
|
1005
|
+
# ARGF.readchar #=> end of file reached (EOFError)
|
1006
|
+
#
|
1007
|
+
%a{annotate:rdoc:copy:ARGF#readchar}
|
1008
|
+
def readchar: () -> String
|
1009
|
+
|
1010
|
+
# <!--
|
1011
|
+
# rdoc-file=io.c
|
1012
|
+
# - ARGF.readline(sep=$/) -> string
|
1013
|
+
# - ARGF.readline(limit) -> string
|
1014
|
+
# - ARGF.readline(sep, limit) -> string
|
1015
|
+
# -->
|
1016
|
+
# Returns the next line from the current file in ARGF.
|
1017
|
+
#
|
1018
|
+
# By default lines are assumed to be separated by `$/`; to use a different
|
1019
|
+
# character as a separator, supply it as a String for the *sep* argument.
|
1020
|
+
#
|
1021
|
+
# The optional *limit* argument specifies how many characters of each line to
|
1022
|
+
# return. By default all characters are returned.
|
1023
|
+
#
|
1024
|
+
# An EOFError is raised at the end of the file.
|
1025
|
+
#
|
1026
|
+
%a{annotate:rdoc:copy:ARGF#readline}
|
1027
|
+
def readline: (?String sep, ?Integer limit) -> String
|
1028
|
+
|
1029
|
+
# <!--
|
1030
|
+
# rdoc-file=io.c
|
1031
|
+
# - ARGF.readlines(sep = $/, chomp: false) -> array
|
1032
|
+
# - ARGF.readlines(limit, chomp: false) -> array
|
1033
|
+
# - ARGF.readlines(sep, limit, chomp: false) -> array
|
1034
|
+
# - ARGF.to_a(sep = $/, chomp: false) -> array
|
1035
|
+
# - ARGF.to_a(limit, chomp: false) -> array
|
1036
|
+
# - ARGF.to_a(sep, limit, chomp: false) -> array
|
1037
|
+
# -->
|
1038
|
+
# Reads each file in ARGF in its entirety, returning an Array containing lines
|
1039
|
+
# from the files. Lines are assumed to be separated by *sep*.
|
1040
|
+
#
|
1041
|
+
# lines = ARGF.readlines
|
1042
|
+
# lines[0] #=> "This is line one\n"
|
1043
|
+
#
|
1044
|
+
# See `IO.readlines` for a full description of all options.
|
1045
|
+
#
|
1046
|
+
%a{annotate:rdoc:copy:ARGF#readlines}
|
1047
|
+
def readlines: (?String sep, ?Integer limit) -> ::Array[String]
|
1048
|
+
|
1049
|
+
# <!--
|
1050
|
+
# rdoc-file=io.c
|
1051
|
+
# - ARGF.readpartial(maxlen) -> string
|
1052
|
+
# - ARGF.readpartial(maxlen, outbuf) -> outbuf
|
1053
|
+
# -->
|
1054
|
+
# Reads at most *maxlen* bytes from the ARGF stream.
|
1055
|
+
#
|
1056
|
+
# If the optional *outbuf* argument is present, it must reference a String,
|
1057
|
+
# which will receive the data. The *outbuf* will contain only the received data
|
1058
|
+
# after the method call even if it is not empty at the beginning.
|
1059
|
+
#
|
1060
|
+
# It raises EOFError on end of ARGF stream. Since ARGF stream is a concatenation
|
1061
|
+
# of multiple files, internally EOF is occur for each file. ARGF.readpartial
|
1062
|
+
# returns empty strings for EOFs except the last one and raises EOFError for the
|
1063
|
+
# last one.
|
1064
|
+
#
|
1065
|
+
%a{annotate:rdoc:copy:ARGF#readpartial}
|
1066
|
+
def readpartial: (int maxlen, ?string outbuf) -> String
|
1067
|
+
|
1068
|
+
# <!--
|
1069
|
+
# rdoc-file=io.c
|
1070
|
+
# - ARGF.rewind -> 0
|
1071
|
+
# -->
|
1072
|
+
# Positions the current file to the beginning of input, resetting ARGF.lineno to
|
1073
|
+
# zero.
|
1074
|
+
#
|
1075
|
+
# ARGF.readline #=> "This is line one\n"
|
1076
|
+
# ARGF.rewind #=> 0
|
1077
|
+
# ARGF.lineno #=> 0
|
1078
|
+
# ARGF.readline #=> "This is line one\n"
|
1079
|
+
#
|
1080
|
+
%a{annotate:rdoc:copy:ARGF#rewind}
|
1081
|
+
def rewind: () -> Integer
|
1082
|
+
|
1083
|
+
# <!--
|
1084
|
+
# rdoc-file=io.c
|
1085
|
+
# - ARGF.seek(amount, whence=IO::SEEK_SET) -> 0
|
1086
|
+
# -->
|
1087
|
+
# Seeks to offset *amount* (an Integer) in the ARGF stream according to the
|
1088
|
+
# value of *whence*. See IO#seek for further details.
|
1089
|
+
#
|
1090
|
+
%a{annotate:rdoc:copy:ARGF#seek}
|
1091
|
+
def seek: (Integer amount, ?Integer whence) -> Integer
|
1092
|
+
|
1093
|
+
# <!--
|
1094
|
+
# rdoc-file=io.c
|
1095
|
+
# - ARGF.set_encoding(ext_enc) -> ARGF
|
1096
|
+
# - ARGF.set_encoding("ext_enc:int_enc") -> ARGF
|
1097
|
+
# - ARGF.set_encoding(ext_enc, int_enc) -> ARGF
|
1098
|
+
# - ARGF.set_encoding("ext_enc:int_enc", opt) -> ARGF
|
1099
|
+
# - ARGF.set_encoding(ext_enc, int_enc, opt) -> ARGF
|
1100
|
+
# -->
|
1101
|
+
# If single argument is specified, strings read from ARGF are tagged with the
|
1102
|
+
# encoding specified.
|
1103
|
+
#
|
1104
|
+
# If two encoding names separated by a colon are given, e.g. "ascii:utf-8", the
|
1105
|
+
# read string is converted from the first encoding (external encoding) to the
|
1106
|
+
# second encoding (internal encoding), then tagged with the second encoding.
|
1107
|
+
#
|
1108
|
+
# If two arguments are specified, they must be encoding objects or encoding
|
1109
|
+
# names. Again, the first specifies the external encoding; the second specifies
|
1110
|
+
# the internal encoding.
|
1111
|
+
#
|
1112
|
+
# If the external encoding and the internal encoding are specified, the optional
|
1113
|
+
# Hash argument can be used to adjust the conversion process. The structure of
|
1114
|
+
# this hash is explained in the String#encode documentation.
|
1115
|
+
#
|
1116
|
+
# For example:
|
1117
|
+
#
|
1118
|
+
# ARGF.set_encoding('ascii') # Tag the input as US-ASCII text
|
1119
|
+
# ARGF.set_encoding(Encoding::UTF_8) # Tag the input as UTF-8 text
|
1120
|
+
# ARGF.set_encoding('utf-8','ascii') # Transcode the input from US-ASCII
|
1121
|
+
# # to UTF-8.
|
1122
|
+
#
|
1123
|
+
%a{annotate:rdoc:copy:ARGF#set_encoding}
|
1124
|
+
def set_encoding: (String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
|
1125
|
+
|
1126
|
+
# <!--
|
1127
|
+
# rdoc-file=io.c
|
1128
|
+
# - ARGF.skip -> ARGF
|
1129
|
+
# -->
|
1130
|
+
# Sets the current file to the next file in ARGV. If there aren't any more files
|
1131
|
+
# it has no effect.
|
1132
|
+
#
|
1133
|
+
# For example:
|
1134
|
+
#
|
1135
|
+
# $ ruby argf.rb foo bar
|
1136
|
+
# ARGF.filename #=> "foo"
|
1137
|
+
# ARGF.skip
|
1138
|
+
# ARGF.filename #=> "bar"
|
1139
|
+
#
|
1140
|
+
%a{annotate:rdoc:copy:ARGF#skip}
|
1141
|
+
def skip: () -> self
|
1142
|
+
|
1143
|
+
# <!--
|
1144
|
+
# rdoc-file=io.c
|
1145
|
+
# - ARGF.tell -> Integer
|
1146
|
+
# - ARGF.pos -> Integer
|
1147
|
+
# -->
|
1148
|
+
# Returns the current offset (in bytes) of the current file in ARGF.
|
1149
|
+
#
|
1150
|
+
# ARGF.pos #=> 0
|
1151
|
+
# ARGF.gets #=> "This is line one\n"
|
1152
|
+
# ARGF.pos #=> 17
|
1153
|
+
#
|
1154
|
+
%a{annotate:rdoc:copy:ARGF#tell}
|
1155
|
+
def tell: () -> Integer
|
1156
|
+
|
1157
|
+
# <!-- rdoc-file=io.c -->
|
1158
|
+
# Reads each file in ARGF in its entirety, returning an Array containing lines
|
1159
|
+
# from the files. Lines are assumed to be separated by *sep*.
|
1160
|
+
#
|
1161
|
+
# lines = ARGF.readlines
|
1162
|
+
# lines[0] #=> "This is line one\n"
|
1163
|
+
#
|
1164
|
+
# See `IO.readlines` for a full description of all options.
|
1165
|
+
#
|
1166
|
+
%a{annotate:rdoc:copy:ARGF#to_a}
|
1167
|
+
def to_a: (?String sep, ?Integer limit) -> ::Array[String]
|
1168
|
+
|
1169
|
+
# <!-- rdoc-file=io.c -->
|
1170
|
+
# Returns an integer representing the numeric file descriptor for the current
|
1171
|
+
# file. Raises an ArgumentError if there isn't a current file.
|
1172
|
+
#
|
1173
|
+
# ARGF.fileno #=> 3
|
1174
|
+
#
|
1175
|
+
%a{annotate:rdoc:copy:ARGF#to_i}
|
1176
|
+
def to_i: () -> Integer
|
1177
|
+
|
1178
|
+
# <!--
|
1179
|
+
# rdoc-file=io.c
|
1180
|
+
# - ARGF.to_io -> IO
|
1181
|
+
# -->
|
1182
|
+
# Returns an IO object representing the current file. This will be a File object
|
1183
|
+
# unless the current file is a stream such as STDIN.
|
1184
|
+
#
|
1185
|
+
# For example:
|
1186
|
+
#
|
1187
|
+
# ARGF.to_io #=> #<File:glark.txt>
|
1188
|
+
# ARGF.to_io #=> #<IO:<STDIN>>
|
1189
|
+
#
|
1190
|
+
%a{annotate:rdoc:copy:ARGF#to_io}
|
1191
|
+
def to_io: () -> IO
|
1192
|
+
|
1193
|
+
# <!--
|
1194
|
+
# rdoc-file=io.c
|
1195
|
+
# - ARGF.to_s -> String
|
1196
|
+
# -->
|
1197
|
+
# Returns "ARGF".
|
1198
|
+
#
|
1199
|
+
%a{annotate:rdoc:copy:ARGF#to_s}
|
1200
|
+
def to_s: () -> String
|
1201
|
+
|
1202
|
+
# <!--
|
1203
|
+
# rdoc-file=io.c
|
1204
|
+
# - ARGF.to_write_io -> io
|
1205
|
+
# -->
|
1206
|
+
# Returns IO instance tied to *ARGF* for writing if inplace mode is enabled.
|
1207
|
+
#
|
1208
|
+
%a{annotate:rdoc:copy:ARGF#to_write_io}
|
1209
|
+
def to_write_io: () -> IO
|
1210
|
+
|
1211
|
+
# <!--
|
1212
|
+
# rdoc-file=io.c
|
1213
|
+
# - ARGF.write(*objects) -> integer
|
1214
|
+
# -->
|
1215
|
+
# Writes each of the given `objects` if inplace mode.
|
1216
|
+
#
|
1217
|
+
%a{annotate:rdoc:copy:ARGF#write}
|
1218
|
+
def write: (_ToS string) -> Integer
|
1219
|
+
|
1220
|
+
private
|
1221
|
+
|
1222
|
+
%a{annotate:rdoc:copy:ARGF#initialize}
|
1223
|
+
def initialize: (*String argv) -> void
|
1224
|
+
|
1225
|
+
%a{annotate:rdoc:copy:ARGF#initialize_copy}
|
1226
|
+
def initialize_copy: (self orig) -> self
|
1227
|
+
end
|
1228
|
+
end
|
1229
|
+
end
|