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
data/core/module.rbs
ADDED
@@ -0,0 +1,1704 @@
|
|
1
|
+
# <!-- rdoc-file=object.c -->
|
2
|
+
# A Module is a collection of methods and constants. The methods in a module may
|
3
|
+
# be instance methods or module methods. Instance methods appear as methods in a
|
4
|
+
# class when the module is included, module methods do not. Conversely, module
|
5
|
+
# methods may be called without creating an encapsulating object, while instance
|
6
|
+
# methods may not. (See Module#module_function.)
|
7
|
+
#
|
8
|
+
# In the descriptions that follow, the parameter *sym* refers to a symbol, which
|
9
|
+
# is either a quoted string or a Symbol (such as `:name`).
|
10
|
+
#
|
11
|
+
# module Mod
|
12
|
+
# include Math
|
13
|
+
# CONST = 1
|
14
|
+
# def meth
|
15
|
+
# # ...
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# Mod.class #=> Module
|
19
|
+
# Mod.constants #=> [:CONST, :PI, :E]
|
20
|
+
# Mod.instance_methods #=> [:meth]
|
21
|
+
#
|
22
|
+
class Module < Object
|
23
|
+
# <!--
|
24
|
+
# rdoc-file=eval.c
|
25
|
+
# - Module.constants -> array
|
26
|
+
# - Module.constants(inherited) -> array
|
27
|
+
# -->
|
28
|
+
# In the first form, returns an array of the names of all constants accessible
|
29
|
+
# from the point of call. This list includes the names of all modules and
|
30
|
+
# classes defined in the global scope.
|
31
|
+
#
|
32
|
+
# Module.constants.first(4)
|
33
|
+
# # => [:ARGF, :ARGV, :ArgumentError, :Array]
|
34
|
+
#
|
35
|
+
# Module.constants.include?(:SEEK_SET) # => false
|
36
|
+
#
|
37
|
+
# class IO
|
38
|
+
# Module.constants.include?(:SEEK_SET) # => true
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# The second form calls the instance method `constants`.
|
42
|
+
#
|
43
|
+
def self.constants: () -> ::Array[Integer]
|
44
|
+
|
45
|
+
# <!--
|
46
|
+
# rdoc-file=eval.c
|
47
|
+
# - Module.nesting -> array
|
48
|
+
# -->
|
49
|
+
# Returns the list of `Modules` nested at the point of call.
|
50
|
+
#
|
51
|
+
# module M1
|
52
|
+
# module M2
|
53
|
+
# $a = Module.nesting
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
# $a #=> [M1::M2, M1]
|
57
|
+
# $a[0].name #=> "M1::M2"
|
58
|
+
#
|
59
|
+
def self.nesting: () -> ::Array[Module]
|
60
|
+
|
61
|
+
# <!--
|
62
|
+
# rdoc-file=eval.c
|
63
|
+
# - used_modules -> array
|
64
|
+
# -->
|
65
|
+
# Returns an array of all modules used in the current scope. The ordering of
|
66
|
+
# modules in the resulting array is not defined.
|
67
|
+
#
|
68
|
+
# module A
|
69
|
+
# refine Object do
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# module B
|
74
|
+
# refine Object do
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# using A
|
79
|
+
# using B
|
80
|
+
# p Module.used_modules
|
81
|
+
#
|
82
|
+
# *produces:*
|
83
|
+
#
|
84
|
+
# [B, A]
|
85
|
+
#
|
86
|
+
def self.used_modules: () -> ::Array[Module]
|
87
|
+
|
88
|
+
# <!--
|
89
|
+
# rdoc-file=eval.c
|
90
|
+
# - used_refinements -> array
|
91
|
+
# -->
|
92
|
+
# Returns an array of all modules used in the current scope. The ordering of
|
93
|
+
# modules in the resulting array is not defined.
|
94
|
+
#
|
95
|
+
# module A
|
96
|
+
# refine Object do
|
97
|
+
# end
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# module B
|
101
|
+
# refine Object do
|
102
|
+
# end
|
103
|
+
# end
|
104
|
+
#
|
105
|
+
# using A
|
106
|
+
# using B
|
107
|
+
# p Module.used_refinements
|
108
|
+
#
|
109
|
+
# *produces:*
|
110
|
+
#
|
111
|
+
# [#<refinement:Object@B>, #<refinement:Object@A>]
|
112
|
+
#
|
113
|
+
def self.used_refinements: () -> Array[Refinement]
|
114
|
+
|
115
|
+
# <!--
|
116
|
+
# rdoc-file=object.c
|
117
|
+
# - mod < other -> true, false, or nil
|
118
|
+
# -->
|
119
|
+
# Returns true if *mod* is a subclass of *other*. Returns `false` if *mod* is
|
120
|
+
# the same as *other* or *mod* is an ancestor of *other*. Returns `nil` if
|
121
|
+
# there's no relationship between the two. (Think of the relationship in terms
|
122
|
+
# of the class definition: "class A < B" implies "A < B".)
|
123
|
+
#
|
124
|
+
def <: (Module other) -> bool?
|
125
|
+
|
126
|
+
# <!--
|
127
|
+
# rdoc-file=object.c
|
128
|
+
# - mod <= other -> true, false, or nil
|
129
|
+
# -->
|
130
|
+
# Returns true if *mod* is a subclass of *other* or is the same as *other*.
|
131
|
+
# Returns `nil` if there's no relationship between the two. (Think of the
|
132
|
+
# relationship in terms of the class definition: "class A < B" implies "A < B".)
|
133
|
+
#
|
134
|
+
def <=: (Module other) -> bool?
|
135
|
+
|
136
|
+
# <!--
|
137
|
+
# rdoc-file=object.c
|
138
|
+
# - module <=> other_module -> -1, 0, +1, or nil
|
139
|
+
# -->
|
140
|
+
# Comparison---Returns -1, 0, +1 or nil depending on whether `module` includes
|
141
|
+
# `other_module`, they are the same, or if `module` is included by
|
142
|
+
# `other_module`.
|
143
|
+
#
|
144
|
+
# Returns `nil` if `module` has no relationship with `other_module`, if
|
145
|
+
# `other_module` is not a module, or if the two values are incomparable.
|
146
|
+
#
|
147
|
+
def <=>: (untyped other) -> Integer?
|
148
|
+
|
149
|
+
# <!--
|
150
|
+
# rdoc-file=object.c
|
151
|
+
# - obj == other -> true or false
|
152
|
+
# - obj.equal?(other) -> true or false
|
153
|
+
# - obj.eql?(other) -> true or false
|
154
|
+
# -->
|
155
|
+
# Equality --- At the Object level, #== returns `true` only if `obj` and `other`
|
156
|
+
# are the same object. Typically, this method is overridden in descendant
|
157
|
+
# classes to provide class-specific meaning.
|
158
|
+
#
|
159
|
+
# Unlike #==, the #equal? method should never be overridden by subclasses as it
|
160
|
+
# is used to determine object identity (that is, `a.equal?(b)` if and only if
|
161
|
+
# `a` is the same object as `b`):
|
162
|
+
#
|
163
|
+
# obj = "a"
|
164
|
+
# other = obj.dup
|
165
|
+
#
|
166
|
+
# obj == other #=> true
|
167
|
+
# obj.equal? other #=> false
|
168
|
+
# obj.equal? obj #=> true
|
169
|
+
#
|
170
|
+
# The #eql? method returns `true` if `obj` and `other` refer to the same hash
|
171
|
+
# key. This is used by Hash to test members for equality. For any pair of
|
172
|
+
# objects where #eql? returns `true`, the #hash value of both objects must be
|
173
|
+
# equal. So any subclass that overrides #eql? should also override #hash
|
174
|
+
# appropriately.
|
175
|
+
#
|
176
|
+
# For objects of class Object, #eql? is synonymous with #==. Subclasses
|
177
|
+
# normally continue this tradition by aliasing #eql? to their overridden #==
|
178
|
+
# method, but there are exceptions. Numeric types, for example, perform type
|
179
|
+
# conversion across #==, but not across #eql?, so:
|
180
|
+
#
|
181
|
+
# 1 == 1.0 #=> true
|
182
|
+
# 1.eql? 1.0 #=> false
|
183
|
+
#
|
184
|
+
def ==: (untyped other) -> bool
|
185
|
+
|
186
|
+
# <!--
|
187
|
+
# rdoc-file=object.c
|
188
|
+
# - mod === obj -> true or false
|
189
|
+
# -->
|
190
|
+
# Case Equality---Returns `true` if *obj* is an instance of *mod* or an instance
|
191
|
+
# of one of *mod*'s descendants. Of limited use for modules, but can be used in
|
192
|
+
# `case` statements to classify objects by class.
|
193
|
+
#
|
194
|
+
def ===: (untyped other) -> bool
|
195
|
+
|
196
|
+
# <!--
|
197
|
+
# rdoc-file=object.c
|
198
|
+
# - mod > other -> true, false, or nil
|
199
|
+
# -->
|
200
|
+
# Returns true if *mod* is an ancestor of *other*. Returns `false` if *mod* is
|
201
|
+
# the same as *other* or *mod* is a descendant of *other*. Returns `nil` if
|
202
|
+
# there's no relationship between the two. (Think of the relationship in terms
|
203
|
+
# of the class definition: "class A < B" implies "B > A".)
|
204
|
+
#
|
205
|
+
def >: (Module other) -> bool?
|
206
|
+
|
207
|
+
# <!--
|
208
|
+
# rdoc-file=object.c
|
209
|
+
# - mod >= other -> true, false, or nil
|
210
|
+
# -->
|
211
|
+
# Returns true if *mod* is an ancestor of *other*, or the two modules are the
|
212
|
+
# same. Returns `nil` if there's no relationship between the two. (Think of the
|
213
|
+
# relationship in terms of the class definition: "class A < B" implies "B > A".)
|
214
|
+
#
|
215
|
+
def >=: (Module other) -> bool?
|
216
|
+
|
217
|
+
# <!--
|
218
|
+
# rdoc-file=vm_method.c
|
219
|
+
# - alias_method(new_name, old_name) -> symbol
|
220
|
+
# -->
|
221
|
+
# Makes *new_name* a new copy of the method *old_name*. This can be used to
|
222
|
+
# retain access to methods that are overridden.
|
223
|
+
#
|
224
|
+
# module Mod
|
225
|
+
# alias_method :orig_exit, :exit #=> :orig_exit
|
226
|
+
# def exit(code=0)
|
227
|
+
# puts "Exiting with code #{code}"
|
228
|
+
# orig_exit(code)
|
229
|
+
# end
|
230
|
+
# end
|
231
|
+
# include Mod
|
232
|
+
# exit(99)
|
233
|
+
#
|
234
|
+
# *produces:*
|
235
|
+
#
|
236
|
+
# Exiting with code 99
|
237
|
+
#
|
238
|
+
def alias_method: (interned new_name, interned old_name) -> ::Symbol
|
239
|
+
|
240
|
+
# <!--
|
241
|
+
# rdoc-file=object.c
|
242
|
+
# - mod.ancestors -> array
|
243
|
+
# -->
|
244
|
+
# Returns a list of modules included/prepended in *mod* (including *mod*
|
245
|
+
# itself).
|
246
|
+
#
|
247
|
+
# module Mod
|
248
|
+
# include Math
|
249
|
+
# include Comparable
|
250
|
+
# prepend Enumerable
|
251
|
+
# end
|
252
|
+
#
|
253
|
+
# Mod.ancestors #=> [Enumerable, Mod, Comparable, Math]
|
254
|
+
# Math.ancestors #=> [Math]
|
255
|
+
# Enumerable.ancestors #=> [Enumerable]
|
256
|
+
#
|
257
|
+
def ancestors: () -> ::Array[Module]
|
258
|
+
|
259
|
+
# <!--
|
260
|
+
# rdoc-file=eval.c
|
261
|
+
# - append_features(mod) -> mod
|
262
|
+
# -->
|
263
|
+
# When this module is included in another, Ruby calls #append_features in this
|
264
|
+
# module, passing it the receiving module in *mod*. Ruby's default
|
265
|
+
# implementation is to add the constants, methods, and module variables of this
|
266
|
+
# module to *mod* if this module has not already been added to *mod* or one of
|
267
|
+
# its ancestors. See also Module#include.
|
268
|
+
#
|
269
|
+
def append_features: (Module arg0) -> self
|
270
|
+
|
271
|
+
# <!--
|
272
|
+
# rdoc-file=object.c
|
273
|
+
# - attr_accessor(symbol, ...) -> array
|
274
|
+
# - attr_accessor(string, ...) -> array
|
275
|
+
# -->
|
276
|
+
# Defines a named attribute for this module, where the name is
|
277
|
+
# *symbol.*`id2name`, creating an instance variable (`@name`) and a
|
278
|
+
# corresponding access method to read it. Also creates a method called `name=`
|
279
|
+
# to set the attribute. String arguments are converted to symbols. Returns an
|
280
|
+
# array of defined method names as symbols.
|
281
|
+
#
|
282
|
+
# module Mod
|
283
|
+
# attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=]
|
284
|
+
# end
|
285
|
+
# Mod.instance_methods.sort #=> [:one, :one=, :two, :two=]
|
286
|
+
#
|
287
|
+
def attr_accessor: (*interned arg0) -> Array[Symbol]
|
288
|
+
|
289
|
+
# <!--
|
290
|
+
# rdoc-file=object.c
|
291
|
+
# - attr_reader(symbol, ...) -> array
|
292
|
+
# - attr(symbol, ...) -> array
|
293
|
+
# - attr_reader(string, ...) -> array
|
294
|
+
# - attr(string, ...) -> array
|
295
|
+
# -->
|
296
|
+
# Creates instance variables and corresponding methods that return the value of
|
297
|
+
# each instance variable. Equivalent to calling ```attr`*:name*'' on each name
|
298
|
+
# in turn. String arguments are converted to symbols. Returns an array of
|
299
|
+
# defined method names as symbols.
|
300
|
+
#
|
301
|
+
def attr_reader: (*interned arg0) -> Array[Symbol]
|
302
|
+
|
303
|
+
# <!--
|
304
|
+
# rdoc-file=object.c
|
305
|
+
# - attr_writer(symbol, ...) -> array
|
306
|
+
# - attr_writer(string, ...) -> array
|
307
|
+
# -->
|
308
|
+
# Creates an accessor method to allow assignment to the attribute
|
309
|
+
# *symbol*`.id2name`. String arguments are converted to symbols. Returns an
|
310
|
+
# array of defined method names as symbols.
|
311
|
+
#
|
312
|
+
def attr_writer: (*interned arg0) -> Array[Symbol]
|
313
|
+
|
314
|
+
# <!--
|
315
|
+
# rdoc-file=load.c
|
316
|
+
# - mod.autoload(const, filename) -> nil
|
317
|
+
# -->
|
318
|
+
# Registers *filename* to be loaded (using Kernel::require) the first time that
|
319
|
+
# *const* (which may be a String or a symbol) is accessed in the namespace of
|
320
|
+
# *mod*.
|
321
|
+
#
|
322
|
+
# module A
|
323
|
+
# end
|
324
|
+
# A.autoload(:B, "b")
|
325
|
+
# A::B.doit # autoloads "b"
|
326
|
+
#
|
327
|
+
# If *const* in *mod* is defined as autoload, the file name to be loaded is
|
328
|
+
# replaced with *filename*. If *const* is defined but not as autoload, does
|
329
|
+
# nothing.
|
330
|
+
#
|
331
|
+
def autoload: (interned _module, String filename) -> NilClass
|
332
|
+
|
333
|
+
# <!--
|
334
|
+
# rdoc-file=load.c
|
335
|
+
# - mod.autoload?(name, inherit=true) -> String or nil
|
336
|
+
# -->
|
337
|
+
# Returns *filename* to be loaded if *name* is registered as `autoload` in the
|
338
|
+
# namespace of *mod* or one of its ancestors.
|
339
|
+
#
|
340
|
+
# module A
|
341
|
+
# end
|
342
|
+
# A.autoload(:B, "b")
|
343
|
+
# A.autoload?(:B) #=> "b"
|
344
|
+
#
|
345
|
+
# If `inherit` is false, the lookup only checks the autoloads in the receiver:
|
346
|
+
#
|
347
|
+
# class A
|
348
|
+
# autoload :CONST, "const.rb"
|
349
|
+
# end
|
350
|
+
#
|
351
|
+
# class B < A
|
352
|
+
# end
|
353
|
+
#
|
354
|
+
# B.autoload?(:CONST) #=> "const.rb", found in A (ancestor)
|
355
|
+
# B.autoload?(:CONST, false) #=> nil, not found in B itself
|
356
|
+
#
|
357
|
+
def autoload?: (interned name, ?boolish inherit) -> String?
|
358
|
+
|
359
|
+
# <!-- rdoc-file=vm_eval.c -->
|
360
|
+
# Evaluates the string or block in the context of *mod*, except that when a
|
361
|
+
# block is given, constant/class variable lookup is not affected. This can be
|
362
|
+
# used to add methods to a class. `module_eval` returns the result of evaluating
|
363
|
+
# its argument. The optional *filename* and *lineno* parameters set the text for
|
364
|
+
# error messages.
|
365
|
+
#
|
366
|
+
# class Thing
|
367
|
+
# end
|
368
|
+
# a = %q{def hello() "Hello there!" end}
|
369
|
+
# Thing.module_eval(a)
|
370
|
+
# puts Thing.new.hello()
|
371
|
+
# Thing.module_eval("invalid code", "dummy", 123)
|
372
|
+
#
|
373
|
+
# *produces:*
|
374
|
+
#
|
375
|
+
# Hello there!
|
376
|
+
# dummy:123:in `module_eval': undefined local variable
|
377
|
+
# or method `code' for Thing:Class
|
378
|
+
#
|
379
|
+
def class_eval: (String arg0, ?String filename, ?Integer lineno) -> untyped
|
380
|
+
| [U] () { (self m) [self: self] -> U } -> U
|
381
|
+
|
382
|
+
# <!-- rdoc-file=vm_eval.c -->
|
383
|
+
# Evaluates the given block in the context of the class/module. The method
|
384
|
+
# defined in the block will belong to the receiver. Any arguments passed to the
|
385
|
+
# method will be passed to the block. This can be used if the block needs to
|
386
|
+
# access instance variables.
|
387
|
+
#
|
388
|
+
# class Thing
|
389
|
+
# end
|
390
|
+
# Thing.class_exec{
|
391
|
+
# def hello() "Hello there!" end
|
392
|
+
# }
|
393
|
+
# puts Thing.new.hello()
|
394
|
+
#
|
395
|
+
# *produces:*
|
396
|
+
#
|
397
|
+
# Hello there!
|
398
|
+
#
|
399
|
+
def class_exec: [U] (*untyped, **untyped) { (?) [self: self] -> U } -> U
|
400
|
+
|
401
|
+
# <!--
|
402
|
+
# rdoc-file=object.c
|
403
|
+
# - obj.class_variable_defined?(symbol) -> true or false
|
404
|
+
# - obj.class_variable_defined?(string) -> true or false
|
405
|
+
# -->
|
406
|
+
# Returns `true` if the given class variable is defined in *obj*. String
|
407
|
+
# arguments are converted to symbols.
|
408
|
+
#
|
409
|
+
# class Fred
|
410
|
+
# @@foo = 99
|
411
|
+
# end
|
412
|
+
# Fred.class_variable_defined?(:@@foo) #=> true
|
413
|
+
# Fred.class_variable_defined?(:@@bar) #=> false
|
414
|
+
#
|
415
|
+
def class_variable_defined?: (interned arg0) -> bool
|
416
|
+
|
417
|
+
# <!--
|
418
|
+
# rdoc-file=object.c
|
419
|
+
# - mod.class_variable_get(symbol) -> obj
|
420
|
+
# - mod.class_variable_get(string) -> obj
|
421
|
+
# -->
|
422
|
+
# Returns the value of the given class variable (or throws a NameError
|
423
|
+
# exception). The `@@` part of the variable name should be included for regular
|
424
|
+
# class variables. String arguments are converted to symbols.
|
425
|
+
#
|
426
|
+
# class Fred
|
427
|
+
# @@foo = 99
|
428
|
+
# end
|
429
|
+
# Fred.class_variable_get(:@@foo) #=> 99
|
430
|
+
#
|
431
|
+
def class_variable_get: (interned arg0) -> untyped
|
432
|
+
|
433
|
+
# <!--
|
434
|
+
# rdoc-file=object.c
|
435
|
+
# - obj.class_variable_set(symbol, obj) -> obj
|
436
|
+
# - obj.class_variable_set(string, obj) -> obj
|
437
|
+
# -->
|
438
|
+
# Sets the class variable named by *symbol* to the given object. If the class
|
439
|
+
# variable name is passed as a string, that string is converted to a symbol.
|
440
|
+
#
|
441
|
+
# class Fred
|
442
|
+
# @@foo = 99
|
443
|
+
# def foo
|
444
|
+
# @@foo
|
445
|
+
# end
|
446
|
+
# end
|
447
|
+
# Fred.class_variable_set(:@@foo, 101) #=> 101
|
448
|
+
# Fred.new.foo #=> 101
|
449
|
+
#
|
450
|
+
def class_variable_set: (interned arg0, untyped arg1) -> untyped
|
451
|
+
|
452
|
+
# <!--
|
453
|
+
# rdoc-file=object.c
|
454
|
+
# - mod.class_variables(inherit=true) -> array
|
455
|
+
# -->
|
456
|
+
# Returns an array of the names of class variables in *mod*. This includes the
|
457
|
+
# names of class variables in any included modules, unless the *inherit*
|
458
|
+
# parameter is set to `false`.
|
459
|
+
#
|
460
|
+
# class One
|
461
|
+
# @@var1 = 1
|
462
|
+
# end
|
463
|
+
# class Two < One
|
464
|
+
# @@var2 = 2
|
465
|
+
# end
|
466
|
+
# One.class_variables #=> [:@@var1]
|
467
|
+
# Two.class_variables #=> [:@@var2, :@@var1]
|
468
|
+
# Two.class_variables(false) #=> [:@@var2]
|
469
|
+
#
|
470
|
+
def class_variables: (?boolish inherit) -> ::Array[Symbol]
|
471
|
+
|
472
|
+
# <!--
|
473
|
+
# rdoc-file=object.c
|
474
|
+
# - const_added(const_name)
|
475
|
+
# -->
|
476
|
+
# Invoked as a callback whenever a constant is assigned on the receiver
|
477
|
+
#
|
478
|
+
# module Chatty
|
479
|
+
# def self.const_added(const_name)
|
480
|
+
# super
|
481
|
+
# puts "Added #{const_name.inspect}"
|
482
|
+
# end
|
483
|
+
# FOO = 1
|
484
|
+
# end
|
485
|
+
#
|
486
|
+
# *produces:*
|
487
|
+
#
|
488
|
+
# Added :FOO
|
489
|
+
#
|
490
|
+
def const_added: (Symbol) -> void
|
491
|
+
|
492
|
+
# <!--
|
493
|
+
# rdoc-file=object.c
|
494
|
+
# - mod.const_defined?(sym, inherit=true) -> true or false
|
495
|
+
# - mod.const_defined?(str, inherit=true) -> true or false
|
496
|
+
# -->
|
497
|
+
# Says whether *mod* or its ancestors have a constant with the given name:
|
498
|
+
#
|
499
|
+
# Float.const_defined?(:EPSILON) #=> true, found in Float itself
|
500
|
+
# Float.const_defined?("String") #=> true, found in Object (ancestor)
|
501
|
+
# BasicObject.const_defined?(:Hash) #=> false
|
502
|
+
#
|
503
|
+
# If *mod* is a `Module`, additionally `Object` and its ancestors are checked:
|
504
|
+
#
|
505
|
+
# Math.const_defined?(:String) #=> true, found in Object
|
506
|
+
#
|
507
|
+
# In each of the checked classes or modules, if the constant is not present but
|
508
|
+
# there is an autoload for it, `true` is returned directly without autoloading:
|
509
|
+
#
|
510
|
+
# module Admin
|
511
|
+
# autoload :User, 'admin/user'
|
512
|
+
# end
|
513
|
+
# Admin.const_defined?(:User) #=> true
|
514
|
+
#
|
515
|
+
# If the constant is not found the callback `const_missing` is **not** called
|
516
|
+
# and the method returns `false`.
|
517
|
+
#
|
518
|
+
# If `inherit` is false, the lookup only checks the constants in the receiver:
|
519
|
+
#
|
520
|
+
# IO.const_defined?(:SYNC) #=> true, found in File::Constants (ancestor)
|
521
|
+
# IO.const_defined?(:SYNC, false) #=> false, not found in IO itself
|
522
|
+
#
|
523
|
+
# In this case, the same logic for autoloading applies.
|
524
|
+
#
|
525
|
+
# If the argument is not a valid constant name a `NameError` is raised with the
|
526
|
+
# message "wrong constant name *name*":
|
527
|
+
#
|
528
|
+
# Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar
|
529
|
+
#
|
530
|
+
def const_defined?: (interned name, ?boolish inherit) -> bool
|
531
|
+
|
532
|
+
# <!--
|
533
|
+
# rdoc-file=object.c
|
534
|
+
# - mod.const_get(sym, inherit=true) -> obj
|
535
|
+
# - mod.const_get(str, inherit=true) -> obj
|
536
|
+
# -->
|
537
|
+
# Checks for a constant with the given name in *mod*. If `inherit` is set, the
|
538
|
+
# lookup will also search the ancestors (and `Object` if *mod* is a `Module`).
|
539
|
+
#
|
540
|
+
# The value of the constant is returned if a definition is found, otherwise a
|
541
|
+
# `NameError` is raised.
|
542
|
+
#
|
543
|
+
# Math.const_get(:PI) #=> 3.14159265358979
|
544
|
+
#
|
545
|
+
# This method will recursively look up constant names if a namespaced class name
|
546
|
+
# is provided. For example:
|
547
|
+
#
|
548
|
+
# module Foo; class Bar; end end
|
549
|
+
# Object.const_get 'Foo::Bar'
|
550
|
+
#
|
551
|
+
# The `inherit` flag is respected on each lookup. For example:
|
552
|
+
#
|
553
|
+
# module Foo
|
554
|
+
# class Bar
|
555
|
+
# VAL = 10
|
556
|
+
# end
|
557
|
+
#
|
558
|
+
# class Baz < Bar; end
|
559
|
+
# end
|
560
|
+
#
|
561
|
+
# Object.const_get 'Foo::Baz::VAL' # => 10
|
562
|
+
# Object.const_get 'Foo::Baz::VAL', false # => NameError
|
563
|
+
#
|
564
|
+
# If the argument is not a valid constant name a `NameError` will be raised with
|
565
|
+
# a warning "wrong constant name".
|
566
|
+
#
|
567
|
+
# Object.const_get 'foobar' #=> NameError: wrong constant name foobar
|
568
|
+
#
|
569
|
+
def const_get: (interned name, ?boolish inherit) -> untyped
|
570
|
+
|
571
|
+
# <!--
|
572
|
+
# rdoc-file=object.c
|
573
|
+
# - mod.const_missing(sym) -> obj
|
574
|
+
# -->
|
575
|
+
# Invoked when a reference is made to an undefined constant in *mod*. It is
|
576
|
+
# passed a symbol for the undefined constant, and returns a value to be used for
|
577
|
+
# that constant. For example, consider:
|
578
|
+
#
|
579
|
+
# def Foo.const_missing(name)
|
580
|
+
# name # return the constant name as Symbol
|
581
|
+
# end
|
582
|
+
#
|
583
|
+
# Foo::UNDEFINED_CONST #=> :UNDEFINED_CONST: symbol returned
|
584
|
+
#
|
585
|
+
# As the example above shows, `const_missing` is not required to create the
|
586
|
+
# missing constant in *mod*, though that is often a side-effect. The caller gets
|
587
|
+
# its return value when triggered. If the constant is also defined, further
|
588
|
+
# lookups won't hit `const_missing` and will return the value stored in the
|
589
|
+
# constant as usual. Otherwise, `const_missing` will be invoked again.
|
590
|
+
#
|
591
|
+
# In the next example, when a reference is made to an undefined constant,
|
592
|
+
# `const_missing` attempts to load a file whose path is the lowercase version of
|
593
|
+
# the constant name (thus class `Fred` is assumed to be in file `fred.rb`). If
|
594
|
+
# defined as a side-effect of loading the file, the method returns the value
|
595
|
+
# stored in the constant. This implements an autoload feature similar to
|
596
|
+
# Kernel#autoload and Module#autoload, though it differs in important ways.
|
597
|
+
#
|
598
|
+
# def Object.const_missing(name)
|
599
|
+
# @looked_for ||= {}
|
600
|
+
# str_name = name.to_s
|
601
|
+
# raise "Constant not found: #{name}" if @looked_for[str_name]
|
602
|
+
# @looked_for[str_name] = 1
|
603
|
+
# file = str_name.downcase
|
604
|
+
# require file
|
605
|
+
# const_get(name, false)
|
606
|
+
# end
|
607
|
+
#
|
608
|
+
def const_missing: (Symbol arg0) -> untyped
|
609
|
+
|
610
|
+
# <!--
|
611
|
+
# rdoc-file=object.c
|
612
|
+
# - mod.const_set(sym, obj) -> obj
|
613
|
+
# - mod.const_set(str, obj) -> obj
|
614
|
+
# -->
|
615
|
+
# Sets the named constant to the given object, returning that object. Creates a
|
616
|
+
# new constant if no constant with the given name previously existed.
|
617
|
+
#
|
618
|
+
# Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714
|
619
|
+
# Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968
|
620
|
+
#
|
621
|
+
# If `sym` or `str` is not a valid constant name a `NameError` will be raised
|
622
|
+
# with a warning "wrong constant name".
|
623
|
+
#
|
624
|
+
# Object.const_set('foobar', 42) #=> NameError: wrong constant name foobar
|
625
|
+
#
|
626
|
+
def const_set: (interned arg0, untyped arg1) -> untyped
|
627
|
+
|
628
|
+
# <!--
|
629
|
+
# rdoc-file=object.c
|
630
|
+
# - mod.const_source_location(sym, inherit=true) -> [String, Integer]
|
631
|
+
# - mod.const_source_location(str, inherit=true) -> [String, Integer]
|
632
|
+
# -->
|
633
|
+
# Returns the Ruby source filename and line number containing the definition of
|
634
|
+
# the constant specified. If the named constant is not found, `nil` is returned.
|
635
|
+
# If the constant is found, but its source location can not be extracted
|
636
|
+
# (constant is defined in C code), empty array is returned.
|
637
|
+
#
|
638
|
+
# *inherit* specifies whether to lookup in `mod.ancestors` (`true` by default).
|
639
|
+
#
|
640
|
+
# # test.rb:
|
641
|
+
# class A # line 1
|
642
|
+
# C1 = 1
|
643
|
+
# C2 = 2
|
644
|
+
# end
|
645
|
+
#
|
646
|
+
# module M # line 6
|
647
|
+
# C3 = 3
|
648
|
+
# end
|
649
|
+
#
|
650
|
+
# class B < A # line 10
|
651
|
+
# include M
|
652
|
+
# C4 = 4
|
653
|
+
# end
|
654
|
+
#
|
655
|
+
# class A # continuation of A definition
|
656
|
+
# C2 = 8 # constant redefinition; warned yet allowed
|
657
|
+
# end
|
658
|
+
#
|
659
|
+
# p B.const_source_location('C4') # => ["test.rb", 12]
|
660
|
+
# p B.const_source_location('C3') # => ["test.rb", 7]
|
661
|
+
# p B.const_source_location('C1') # => ["test.rb", 2]
|
662
|
+
#
|
663
|
+
# p B.const_source_location('C3', false) # => nil -- don't lookup in ancestors
|
664
|
+
#
|
665
|
+
# p A.const_source_location('C2') # => ["test.rb", 16] -- actual (last) definition place
|
666
|
+
#
|
667
|
+
# p Object.const_source_location('B') # => ["test.rb", 10] -- top-level constant could be looked through Object
|
668
|
+
# p Object.const_source_location('A') # => ["test.rb", 1] -- class reopening is NOT considered new definition
|
669
|
+
#
|
670
|
+
# p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors
|
671
|
+
# p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules
|
672
|
+
#
|
673
|
+
# p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported
|
674
|
+
# p Object.const_source_location('String') # => [] -- constant is defined in C code
|
675
|
+
#
|
676
|
+
def const_source_location: (interned name, ?boolish inherit) -> ([ String, Integer ] | [ ] | nil)
|
677
|
+
|
678
|
+
# <!--
|
679
|
+
# rdoc-file=object.c
|
680
|
+
# - mod.constants(inherit=true) -> array
|
681
|
+
# -->
|
682
|
+
# Returns an array of the names of the constants accessible in *mod*. This
|
683
|
+
# includes the names of constants in any included modules (example at start of
|
684
|
+
# section), unless the *inherit* parameter is set to `false`.
|
685
|
+
#
|
686
|
+
# The implementation makes no guarantees about the order in which the constants
|
687
|
+
# are yielded.
|
688
|
+
#
|
689
|
+
# IO.constants.include?(:SYNC) #=> true
|
690
|
+
# IO.constants(false).include?(:SYNC) #=> false
|
691
|
+
#
|
692
|
+
# Also see Module#const_defined?.
|
693
|
+
#
|
694
|
+
def constants: (?boolish inherit) -> ::Array[Symbol]
|
695
|
+
|
696
|
+
# <!--
|
697
|
+
# rdoc-file=proc.c
|
698
|
+
# - define_method(symbol, method) -> symbol
|
699
|
+
# - define_method(symbol) { block } -> symbol
|
700
|
+
# -->
|
701
|
+
# Defines an instance method in the receiver. The *method* parameter can be a
|
702
|
+
# `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, it
|
703
|
+
# is used as the method body. If a block or the *method* parameter has
|
704
|
+
# parameters, they're used as method parameters. This block is evaluated using
|
705
|
+
# #instance_eval.
|
706
|
+
#
|
707
|
+
# class A
|
708
|
+
# def fred
|
709
|
+
# puts "In Fred"
|
710
|
+
# end
|
711
|
+
# def create_method(name, &block)
|
712
|
+
# self.class.define_method(name, &block)
|
713
|
+
# end
|
714
|
+
# define_method(:wilma) { puts "Charge it!" }
|
715
|
+
# define_method(:flint) {|name| puts "I'm #{name}!"}
|
716
|
+
# end
|
717
|
+
# class B < A
|
718
|
+
# define_method(:barney, instance_method(:fred))
|
719
|
+
# end
|
720
|
+
# a = B.new
|
721
|
+
# a.barney
|
722
|
+
# a.wilma
|
723
|
+
# a.flint('Dino')
|
724
|
+
# a.create_method(:betty) { p self }
|
725
|
+
# a.betty
|
726
|
+
#
|
727
|
+
# *produces:*
|
728
|
+
#
|
729
|
+
# In Fred
|
730
|
+
# Charge it!
|
731
|
+
# I'm Dino!
|
732
|
+
# #<B:0x401b39e8>
|
733
|
+
#
|
734
|
+
def define_method: (interned symbol, ^() [self: instance] -> untyped | Method | UnboundMethod method) -> Symbol
|
735
|
+
| (interned symbol) { () [self: instance] -> untyped } -> Symbol
|
736
|
+
|
737
|
+
# <!--
|
738
|
+
# rdoc-file=object.c
|
739
|
+
# - mod.deprecate_constant(symbol, ...) => mod
|
740
|
+
# -->
|
741
|
+
# Makes a list of existing constants deprecated. Attempt to refer to them will
|
742
|
+
# produce a warning.
|
743
|
+
#
|
744
|
+
# module HTTP
|
745
|
+
# NotFound = Exception.new
|
746
|
+
# NOT_FOUND = NotFound # previous version of the library used this name
|
747
|
+
#
|
748
|
+
# deprecate_constant :NOT_FOUND
|
749
|
+
# end
|
750
|
+
#
|
751
|
+
# HTTP::NOT_FOUND
|
752
|
+
# # warning: constant HTTP::NOT_FOUND is deprecated
|
753
|
+
#
|
754
|
+
def deprecate_constant: (*interned) -> self
|
755
|
+
|
756
|
+
def eql?: (untyped other) -> bool
|
757
|
+
|
758
|
+
def equal?: (untyped other) -> bool
|
759
|
+
|
760
|
+
# <!--
|
761
|
+
# rdoc-file=eval.c
|
762
|
+
# - extend_object(obj) -> obj
|
763
|
+
# -->
|
764
|
+
# Extends the specified object by adding this module's constants and methods
|
765
|
+
# (which are added as singleton methods). This is the callback method used by
|
766
|
+
# Object#extend.
|
767
|
+
#
|
768
|
+
# module Picky
|
769
|
+
# def Picky.extend_object(o)
|
770
|
+
# if String === o
|
771
|
+
# puts "Can't add Picky to a String"
|
772
|
+
# else
|
773
|
+
# puts "Picky added to #{o.class}"
|
774
|
+
# super
|
775
|
+
# end
|
776
|
+
# end
|
777
|
+
# end
|
778
|
+
# (s = Array.new).extend Picky # Call Object.extend
|
779
|
+
# (s = "quick brown fox").extend Picky
|
780
|
+
#
|
781
|
+
# *produces:*
|
782
|
+
#
|
783
|
+
# Picky added to Array
|
784
|
+
# Can't add Picky to a String
|
785
|
+
#
|
786
|
+
def extend_object: (untyped arg0) -> untyped
|
787
|
+
|
788
|
+
# <!--
|
789
|
+
# rdoc-file=object.c
|
790
|
+
# - extended(othermod)
|
791
|
+
# -->
|
792
|
+
# The equivalent of `included`, but for extended modules.
|
793
|
+
#
|
794
|
+
# module A
|
795
|
+
# def self.extended(mod)
|
796
|
+
# puts "#{self} extended in #{mod}"
|
797
|
+
# end
|
798
|
+
# end
|
799
|
+
# module Enumerable
|
800
|
+
# extend A
|
801
|
+
# end
|
802
|
+
# # => prints "A extended in Enumerable"
|
803
|
+
#
|
804
|
+
def extended: (Module othermod) -> untyped
|
805
|
+
|
806
|
+
# <!--
|
807
|
+
# rdoc-file=object.c
|
808
|
+
# - mod.freeze -> mod
|
809
|
+
# -->
|
810
|
+
# Prevents further modifications to *mod*.
|
811
|
+
#
|
812
|
+
# This method returns self.
|
813
|
+
#
|
814
|
+
def freeze: () -> self
|
815
|
+
|
816
|
+
# <!--
|
817
|
+
# rdoc-file=eval.c
|
818
|
+
# - include(module, ...) -> self
|
819
|
+
# -->
|
820
|
+
# Invokes Module.append_features on each parameter in reverse order.
|
821
|
+
#
|
822
|
+
def include: (Module, *Module arg0) -> self
|
823
|
+
|
824
|
+
# <!--
|
825
|
+
# rdoc-file=object.c
|
826
|
+
# - mod.include?(module) -> true or false
|
827
|
+
# -->
|
828
|
+
# Returns `true` if *module* is included or prepended in *mod* or one of *mod*'s
|
829
|
+
# ancestors.
|
830
|
+
#
|
831
|
+
# module A
|
832
|
+
# end
|
833
|
+
# class B
|
834
|
+
# include A
|
835
|
+
# end
|
836
|
+
# class C < B
|
837
|
+
# end
|
838
|
+
# B.include?(A) #=> true
|
839
|
+
# C.include?(A) #=> true
|
840
|
+
# A.include?(A) #=> false
|
841
|
+
#
|
842
|
+
def include?: (Module arg0) -> bool
|
843
|
+
|
844
|
+
# <!--
|
845
|
+
# rdoc-file=object.c
|
846
|
+
# - included(othermod)
|
847
|
+
# -->
|
848
|
+
# Callback invoked whenever the receiver is included in another module or class.
|
849
|
+
# This should be used in preference to `Module.append_features` if your code
|
850
|
+
# wants to perform some action when a module is included in another.
|
851
|
+
#
|
852
|
+
# module A
|
853
|
+
# def A.included(mod)
|
854
|
+
# puts "#{self} included in #{mod}"
|
855
|
+
# end
|
856
|
+
# end
|
857
|
+
# module Enumerable
|
858
|
+
# include A
|
859
|
+
# end
|
860
|
+
# # => prints "A included in Enumerable"
|
861
|
+
#
|
862
|
+
def included: (Module othermod) -> untyped
|
863
|
+
|
864
|
+
# <!--
|
865
|
+
# rdoc-file=object.c
|
866
|
+
# - mod.included_modules -> array
|
867
|
+
# -->
|
868
|
+
# Returns the list of modules included or prepended in *mod* or one of *mod*'s
|
869
|
+
# ancestors.
|
870
|
+
#
|
871
|
+
# module Sub
|
872
|
+
# end
|
873
|
+
#
|
874
|
+
# module Mixin
|
875
|
+
# prepend Sub
|
876
|
+
# end
|
877
|
+
#
|
878
|
+
# module Outer
|
879
|
+
# include Mixin
|
880
|
+
# end
|
881
|
+
#
|
882
|
+
# Mixin.included_modules #=> [Sub]
|
883
|
+
# Outer.included_modules #=> [Sub, Mixin]
|
884
|
+
#
|
885
|
+
def included_modules: () -> ::Array[Module]
|
886
|
+
|
887
|
+
# <!--
|
888
|
+
# rdoc-file=object.c
|
889
|
+
# - Module.new -> mod
|
890
|
+
# - Module.new {|mod| block } -> mod
|
891
|
+
# -->
|
892
|
+
# Creates a new anonymous module. If a block is given, it is passed the module
|
893
|
+
# object, and the block is evaluated in the context of this module like
|
894
|
+
# #module_eval.
|
895
|
+
#
|
896
|
+
# fred = Module.new do
|
897
|
+
# def meth1
|
898
|
+
# "hello"
|
899
|
+
# end
|
900
|
+
# def meth2
|
901
|
+
# "bye"
|
902
|
+
# end
|
903
|
+
# end
|
904
|
+
# a = "my string"
|
905
|
+
# a.extend(fred) #=> "my string"
|
906
|
+
# a.meth1 #=> "hello"
|
907
|
+
# a.meth2 #=> "bye"
|
908
|
+
#
|
909
|
+
# Assign the module to a constant (name starting uppercase) if you want to treat
|
910
|
+
# it like a regular module.
|
911
|
+
#
|
912
|
+
def initialize: () -> void
|
913
|
+
| () { (Module arg0) -> untyped } -> void
|
914
|
+
|
915
|
+
# <!--
|
916
|
+
# rdoc-file=proc.c
|
917
|
+
# - mod.instance_method(symbol) -> unbound_method
|
918
|
+
# -->
|
919
|
+
# Returns an `UnboundMethod` representing the given instance method in *mod*.
|
920
|
+
#
|
921
|
+
# class Interpreter
|
922
|
+
# def do_a() print "there, "; end
|
923
|
+
# def do_d() print "Hello "; end
|
924
|
+
# def do_e() print "!\n"; end
|
925
|
+
# def do_v() print "Dave"; end
|
926
|
+
# Dispatcher = {
|
927
|
+
# "a" => instance_method(:do_a),
|
928
|
+
# "d" => instance_method(:do_d),
|
929
|
+
# "e" => instance_method(:do_e),
|
930
|
+
# "v" => instance_method(:do_v)
|
931
|
+
# }
|
932
|
+
# def interpret(string)
|
933
|
+
# string.each_char {|b| Dispatcher[b].bind(self).call }
|
934
|
+
# end
|
935
|
+
# end
|
936
|
+
#
|
937
|
+
# interpreter = Interpreter.new
|
938
|
+
# interpreter.interpret('dave')
|
939
|
+
#
|
940
|
+
# *produces:*
|
941
|
+
#
|
942
|
+
# Hello there, Dave!
|
943
|
+
#
|
944
|
+
def instance_method: (interned arg0) -> UnboundMethod
|
945
|
+
|
946
|
+
# <!--
|
947
|
+
# rdoc-file=object.c
|
948
|
+
# - mod.instance_methods(include_super=true) -> array
|
949
|
+
# -->
|
950
|
+
# Returns an array containing the names of the public and protected instance
|
951
|
+
# methods in the receiver. For a module, these are the public and protected
|
952
|
+
# methods; for a class, they are the instance (not singleton) methods. If the
|
953
|
+
# optional parameter is `false`, the methods of any ancestors are not included.
|
954
|
+
#
|
955
|
+
# module A
|
956
|
+
# def method1() end
|
957
|
+
# end
|
958
|
+
# class B
|
959
|
+
# include A
|
960
|
+
# def method2() end
|
961
|
+
# end
|
962
|
+
# class C < B
|
963
|
+
# def method3() end
|
964
|
+
# end
|
965
|
+
#
|
966
|
+
# A.instance_methods(false) #=> [:method1]
|
967
|
+
# B.instance_methods(false) #=> [:method2]
|
968
|
+
# B.instance_methods(true).include?(:method1) #=> true
|
969
|
+
# C.instance_methods(false) #=> [:method3]
|
970
|
+
# C.instance_methods.include?(:method2) #=> true
|
971
|
+
#
|
972
|
+
# Note that method visibility changes in the current class, as well as aliases,
|
973
|
+
# are considered as methods of the current class by this method:
|
974
|
+
#
|
975
|
+
# class C < B
|
976
|
+
# alias method4 method2
|
977
|
+
# protected :method2
|
978
|
+
# end
|
979
|
+
# C.instance_methods(false).sort #=> [:method2, :method3, :method4]
|
980
|
+
#
|
981
|
+
def instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
982
|
+
|
983
|
+
# <!--
|
984
|
+
# rdoc-file=object.c
|
985
|
+
# - method_added(method_name)
|
986
|
+
# -->
|
987
|
+
# Invoked as a callback whenever an instance method is added to the receiver.
|
988
|
+
#
|
989
|
+
# module Chatty
|
990
|
+
# def self.method_added(method_name)
|
991
|
+
# puts "Adding #{method_name.inspect}"
|
992
|
+
# end
|
993
|
+
# def self.some_class_method() end
|
994
|
+
# def some_instance_method() end
|
995
|
+
# end
|
996
|
+
#
|
997
|
+
# *produces:*
|
998
|
+
#
|
999
|
+
# Adding :some_instance_method
|
1000
|
+
#
|
1001
|
+
def method_added: (Symbol meth) -> untyped
|
1002
|
+
|
1003
|
+
# <!--
|
1004
|
+
# rdoc-file=vm_method.c
|
1005
|
+
# - mod.method_defined?(symbol, inherit=true) -> true or false
|
1006
|
+
# - mod.method_defined?(string, inherit=true) -> true or false
|
1007
|
+
# -->
|
1008
|
+
# Returns `true` if the named method is defined by *mod*. If *inherit* is set,
|
1009
|
+
# the lookup will also search *mod*'s ancestors. Public and protected methods
|
1010
|
+
# are matched. String arguments are converted to symbols.
|
1011
|
+
#
|
1012
|
+
# module A
|
1013
|
+
# def method1() end
|
1014
|
+
# def protected_method1() end
|
1015
|
+
# protected :protected_method1
|
1016
|
+
# end
|
1017
|
+
# class B
|
1018
|
+
# def method2() end
|
1019
|
+
# def private_method2() end
|
1020
|
+
# private :private_method2
|
1021
|
+
# end
|
1022
|
+
# class C < B
|
1023
|
+
# include A
|
1024
|
+
# def method3() end
|
1025
|
+
# end
|
1026
|
+
#
|
1027
|
+
# A.method_defined? :method1 #=> true
|
1028
|
+
# C.method_defined? "method1" #=> true
|
1029
|
+
# C.method_defined? "method2" #=> true
|
1030
|
+
# C.method_defined? "method2", true #=> true
|
1031
|
+
# C.method_defined? "method2", false #=> false
|
1032
|
+
# C.method_defined? "method3" #=> true
|
1033
|
+
# C.method_defined? "protected_method1" #=> true
|
1034
|
+
# C.method_defined? "method4" #=> false
|
1035
|
+
# C.method_defined? "private_method2" #=> false
|
1036
|
+
#
|
1037
|
+
def method_defined?: (interned name, ?boolish inherit) -> bool
|
1038
|
+
|
1039
|
+
# <!--
|
1040
|
+
# rdoc-file=object.c
|
1041
|
+
# - method_removed(method_name)
|
1042
|
+
# -->
|
1043
|
+
# Invoked as a callback whenever an instance method is removed from the
|
1044
|
+
# receiver.
|
1045
|
+
#
|
1046
|
+
# module Chatty
|
1047
|
+
# def self.method_removed(method_name)
|
1048
|
+
# puts "Removing #{method_name.inspect}"
|
1049
|
+
# end
|
1050
|
+
# def self.some_class_method() end
|
1051
|
+
# def some_instance_method() end
|
1052
|
+
# class << self
|
1053
|
+
# remove_method :some_class_method
|
1054
|
+
# end
|
1055
|
+
# remove_method :some_instance_method
|
1056
|
+
# end
|
1057
|
+
#
|
1058
|
+
# *produces:*
|
1059
|
+
#
|
1060
|
+
# Removing :some_instance_method
|
1061
|
+
#
|
1062
|
+
def method_removed: (Symbol method_name) -> untyped
|
1063
|
+
|
1064
|
+
# <!--
|
1065
|
+
# rdoc-file=vm_eval.c
|
1066
|
+
# - mod.class_eval(string [, filename [, lineno]]) -> obj
|
1067
|
+
# - mod.class_eval {|mod| block } -> obj
|
1068
|
+
# - mod.module_eval(string [, filename [, lineno]]) -> obj
|
1069
|
+
# - mod.module_eval {|mod| block } -> obj
|
1070
|
+
# -->
|
1071
|
+
# Evaluates the string or block in the context of *mod*, except that when a
|
1072
|
+
# block is given, constant/class variable lookup is not affected. This can be
|
1073
|
+
# used to add methods to a class. `module_eval` returns the result of evaluating
|
1074
|
+
# its argument. The optional *filename* and *lineno* parameters set the text for
|
1075
|
+
# error messages.
|
1076
|
+
#
|
1077
|
+
# class Thing
|
1078
|
+
# end
|
1079
|
+
# a = %q{def hello() "Hello there!" end}
|
1080
|
+
# Thing.module_eval(a)
|
1081
|
+
# puts Thing.new.hello()
|
1082
|
+
# Thing.module_eval("invalid code", "dummy", 123)
|
1083
|
+
#
|
1084
|
+
# *produces:*
|
1085
|
+
#
|
1086
|
+
# Hello there!
|
1087
|
+
# dummy:123:in `module_eval': undefined local variable
|
1088
|
+
# or method `code' for Thing:Class
|
1089
|
+
#
|
1090
|
+
def module_eval: (String arg0, ?String filename, ?Integer lineno) -> untyped
|
1091
|
+
| [U] () { (self m) [self: self] -> U } -> U
|
1092
|
+
|
1093
|
+
# <!--
|
1094
|
+
# rdoc-file=vm_eval.c
|
1095
|
+
# - mod.module_exec(arg...) {|var...| block } -> obj
|
1096
|
+
# - mod.class_exec(arg...) {|var...| block } -> obj
|
1097
|
+
# -->
|
1098
|
+
# Evaluates the given block in the context of the class/module. The method
|
1099
|
+
# defined in the block will belong to the receiver. Any arguments passed to the
|
1100
|
+
# method will be passed to the block. This can be used if the block needs to
|
1101
|
+
# access instance variables.
|
1102
|
+
#
|
1103
|
+
# class Thing
|
1104
|
+
# end
|
1105
|
+
# Thing.class_exec{
|
1106
|
+
# def hello() "Hello there!" end
|
1107
|
+
# }
|
1108
|
+
# puts Thing.new.hello()
|
1109
|
+
#
|
1110
|
+
# *produces:*
|
1111
|
+
#
|
1112
|
+
# Hello there!
|
1113
|
+
#
|
1114
|
+
def module_exec: [U] (*untyped, **untyped) { (?) [self: self] -> U } -> U
|
1115
|
+
|
1116
|
+
# <!--
|
1117
|
+
# rdoc-file=vm_method.c
|
1118
|
+
# - module_function -> nil
|
1119
|
+
# - module_function(method_name) -> method_name
|
1120
|
+
# - module_function(method_name, method_name, ...) -> array
|
1121
|
+
# -->
|
1122
|
+
# Creates module functions for the named methods. These functions may be called
|
1123
|
+
# with the module as a receiver, and also become available as instance methods
|
1124
|
+
# to classes that mix in the module. Module functions are copies of the
|
1125
|
+
# original, and so may be changed independently. The instance-method versions
|
1126
|
+
# are made private. If used with no arguments, subsequently defined methods
|
1127
|
+
# become module functions. String arguments are converted to symbols. If a
|
1128
|
+
# single argument is passed, it is returned. If no argument is passed, nil is
|
1129
|
+
# returned. If multiple arguments are passed, the arguments are returned as an
|
1130
|
+
# array.
|
1131
|
+
#
|
1132
|
+
# module Mod
|
1133
|
+
# def one
|
1134
|
+
# "This is one"
|
1135
|
+
# end
|
1136
|
+
# module_function :one
|
1137
|
+
# end
|
1138
|
+
# class Cls
|
1139
|
+
# include Mod
|
1140
|
+
# def call_one
|
1141
|
+
# one
|
1142
|
+
# end
|
1143
|
+
# end
|
1144
|
+
# Mod.one #=> "This is one"
|
1145
|
+
# c = Cls.new
|
1146
|
+
# c.call_one #=> "This is one"
|
1147
|
+
# module Mod
|
1148
|
+
# def one
|
1149
|
+
# "This is the new one"
|
1150
|
+
# end
|
1151
|
+
# end
|
1152
|
+
# Mod.one #=> "This is one"
|
1153
|
+
# c.call_one #=> "This is the new one"
|
1154
|
+
#
|
1155
|
+
def module_function: () -> nil
|
1156
|
+
| (Symbol method_name) -> Symbol
|
1157
|
+
| (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
|
1158
|
+
| (string method_name) -> string
|
1159
|
+
| (interned, interned, *interned method_name) -> Array[interned]
|
1160
|
+
|
1161
|
+
# <!--
|
1162
|
+
# rdoc-file=object.c
|
1163
|
+
# - mod.name -> string or nil
|
1164
|
+
# -->
|
1165
|
+
# Returns the name of the module *mod*. Returns `nil` for anonymous modules.
|
1166
|
+
#
|
1167
|
+
def name: () -> String?
|
1168
|
+
|
1169
|
+
# <!--
|
1170
|
+
# rdoc-file=eval.c
|
1171
|
+
# - prepend(module, ...) -> self
|
1172
|
+
# -->
|
1173
|
+
# Invokes Module.prepend_features on each parameter in reverse order.
|
1174
|
+
#
|
1175
|
+
def prepend: (Module, *Module arg0) -> self
|
1176
|
+
|
1177
|
+
# <!--
|
1178
|
+
# rdoc-file=eval.c
|
1179
|
+
# - prepend_features(mod) -> mod
|
1180
|
+
# -->
|
1181
|
+
# When this module is prepended in another, Ruby calls #prepend_features in this
|
1182
|
+
# module, passing it the receiving module in *mod*. Ruby's default
|
1183
|
+
# implementation is to overlay the constants, methods, and module variables of
|
1184
|
+
# this module to *mod* if this module has not already been added to *mod* or one
|
1185
|
+
# of its ancestors. See also Module#prepend.
|
1186
|
+
#
|
1187
|
+
def prepend_features: (Module arg0) -> self
|
1188
|
+
|
1189
|
+
# <!--
|
1190
|
+
# rdoc-file=object.c
|
1191
|
+
# - prepended(othermod)
|
1192
|
+
# -->
|
1193
|
+
# The equivalent of `included`, but for prepended modules.
|
1194
|
+
#
|
1195
|
+
# module A
|
1196
|
+
# def self.prepended(mod)
|
1197
|
+
# puts "#{self} prepended to #{mod}"
|
1198
|
+
# end
|
1199
|
+
# end
|
1200
|
+
# module Enumerable
|
1201
|
+
# prepend A
|
1202
|
+
# end
|
1203
|
+
# # => prints "A prepended to Enumerable"
|
1204
|
+
#
|
1205
|
+
def prepended: (Module othermod) -> untyped
|
1206
|
+
|
1207
|
+
# <!--
|
1208
|
+
# rdoc-file=vm_method.c
|
1209
|
+
# - private -> nil
|
1210
|
+
# - private(method_name) -> method_name
|
1211
|
+
# - private(method_name, method_name, ...) -> array
|
1212
|
+
# - private(array) -> array
|
1213
|
+
# -->
|
1214
|
+
# With no arguments, sets the default visibility for subsequently defined
|
1215
|
+
# methods to private. With arguments, sets the named methods to have private
|
1216
|
+
# visibility. String arguments are converted to symbols. An Array of Symbols
|
1217
|
+
# and/or Strings is also accepted. If a single argument is passed, it is
|
1218
|
+
# returned. If no argument is passed, nil is returned. If multiple arguments are
|
1219
|
+
# passed, the arguments are returned as an array.
|
1220
|
+
#
|
1221
|
+
# module Mod
|
1222
|
+
# def a() end
|
1223
|
+
# def b() end
|
1224
|
+
# private
|
1225
|
+
# def c() end
|
1226
|
+
# private :a
|
1227
|
+
# end
|
1228
|
+
# Mod.private_instance_methods #=> [:a, :c]
|
1229
|
+
#
|
1230
|
+
# Note that to show a private method on RDoc, use `:doc:`.
|
1231
|
+
#
|
1232
|
+
def private: () -> nil
|
1233
|
+
| (Symbol method_name) -> Symbol
|
1234
|
+
| (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
|
1235
|
+
| (string method_name) -> string
|
1236
|
+
| (interned, interned, *interned method_name) -> Array[interned]
|
1237
|
+
| (Array[interned]) -> Array[interned]
|
1238
|
+
|
1239
|
+
# <!--
|
1240
|
+
# rdoc-file=vm_method.c
|
1241
|
+
# - mod.private_class_method(symbol, ...) -> mod
|
1242
|
+
# - mod.private_class_method(string, ...) -> mod
|
1243
|
+
# - mod.private_class_method(array) -> mod
|
1244
|
+
# -->
|
1245
|
+
# Makes existing class methods private. Often used to hide the default
|
1246
|
+
# constructor `new`.
|
1247
|
+
#
|
1248
|
+
# String arguments are converted to symbols. An Array of Symbols and/or Strings
|
1249
|
+
# is also accepted.
|
1250
|
+
#
|
1251
|
+
# class SimpleSingleton # Not thread safe
|
1252
|
+
# private_class_method :new
|
1253
|
+
# def SimpleSingleton.create(*args, &block)
|
1254
|
+
# @me = new(*args, &block) if ! @me
|
1255
|
+
# @me
|
1256
|
+
# end
|
1257
|
+
# end
|
1258
|
+
#
|
1259
|
+
def private_class_method: (*interned arg0) -> self
|
1260
|
+
| (Array[interned] arg0) -> self
|
1261
|
+
|
1262
|
+
# <!--
|
1263
|
+
# rdoc-file=object.c
|
1264
|
+
# - mod.private_constant(symbol, ...) => mod
|
1265
|
+
# -->
|
1266
|
+
# Makes a list of existing constants private.
|
1267
|
+
#
|
1268
|
+
def private_constant: (*interned arg0) -> self
|
1269
|
+
|
1270
|
+
# <!--
|
1271
|
+
# rdoc-file=object.c
|
1272
|
+
# - mod.private_instance_methods(include_super=true) -> array
|
1273
|
+
# -->
|
1274
|
+
# Returns a list of the private instance methods defined in *mod*. If the
|
1275
|
+
# optional parameter is `false`, the methods of any ancestors are not included.
|
1276
|
+
#
|
1277
|
+
# module Mod
|
1278
|
+
# def method1() end
|
1279
|
+
# private :method1
|
1280
|
+
# def method2() end
|
1281
|
+
# end
|
1282
|
+
# Mod.instance_methods #=> [:method2]
|
1283
|
+
# Mod.private_instance_methods #=> [:method1]
|
1284
|
+
#
|
1285
|
+
def private_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
1286
|
+
|
1287
|
+
# <!--
|
1288
|
+
# rdoc-file=vm_method.c
|
1289
|
+
# - mod.private_method_defined?(symbol, inherit=true) -> true or false
|
1290
|
+
# - mod.private_method_defined?(string, inherit=true) -> true or false
|
1291
|
+
# -->
|
1292
|
+
# Returns `true` if the named private method is defined by *mod*. If *inherit*
|
1293
|
+
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
1294
|
+
# converted to symbols.
|
1295
|
+
#
|
1296
|
+
# module A
|
1297
|
+
# def method1() end
|
1298
|
+
# end
|
1299
|
+
# class B
|
1300
|
+
# private
|
1301
|
+
# def method2() end
|
1302
|
+
# end
|
1303
|
+
# class C < B
|
1304
|
+
# include A
|
1305
|
+
# def method3() end
|
1306
|
+
# end
|
1307
|
+
#
|
1308
|
+
# A.method_defined? :method1 #=> true
|
1309
|
+
# C.private_method_defined? "method1" #=> false
|
1310
|
+
# C.private_method_defined? "method2" #=> true
|
1311
|
+
# C.private_method_defined? "method2", true #=> true
|
1312
|
+
# C.private_method_defined? "method2", false #=> false
|
1313
|
+
# C.method_defined? "method2" #=> false
|
1314
|
+
#
|
1315
|
+
def private_method_defined?: (interned name, ?boolish inherit) -> bool
|
1316
|
+
|
1317
|
+
# <!--
|
1318
|
+
# rdoc-file=vm_method.c
|
1319
|
+
# - protected -> nil
|
1320
|
+
# - protected(method_name) -> method_name
|
1321
|
+
# - protected(method_name, method_name, ...) -> array
|
1322
|
+
# - protected(array) -> array
|
1323
|
+
# -->
|
1324
|
+
# With no arguments, sets the default visibility for subsequently defined
|
1325
|
+
# methods to protected. With arguments, sets the named methods to have protected
|
1326
|
+
# visibility. String arguments are converted to symbols. An Array of Symbols
|
1327
|
+
# and/or Strings is also accepted. If a single argument is passed, it is
|
1328
|
+
# returned. If no argument is passed, nil is returned. If multiple arguments are
|
1329
|
+
# passed, the arguments are returned as an array.
|
1330
|
+
#
|
1331
|
+
# If a method has protected visibility, it is callable only where `self` of the
|
1332
|
+
# context is the same as the method. (method definition or instance_eval). This
|
1333
|
+
# behavior is different from Java's protected method. Usually `private` should
|
1334
|
+
# be used.
|
1335
|
+
#
|
1336
|
+
# Note that a protected method is slow because it can't use inline cache.
|
1337
|
+
#
|
1338
|
+
# To show a private method on RDoc, use `:doc:` instead of this.
|
1339
|
+
#
|
1340
|
+
def protected: () -> nil
|
1341
|
+
| (Symbol method_name) -> Symbol
|
1342
|
+
| (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
|
1343
|
+
| (string method_name) -> string
|
1344
|
+
| (interned, interned, *interned method_name) -> Array[interned]
|
1345
|
+
| (Array[interned]) -> Array[interned]
|
1346
|
+
|
1347
|
+
# <!--
|
1348
|
+
# rdoc-file=object.c
|
1349
|
+
# - mod.protected_instance_methods(include_super=true) -> array
|
1350
|
+
# -->
|
1351
|
+
# Returns a list of the protected instance methods defined in *mod*. If the
|
1352
|
+
# optional parameter is `false`, the methods of any ancestors are not included.
|
1353
|
+
#
|
1354
|
+
def protected_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
1355
|
+
|
1356
|
+
# <!--
|
1357
|
+
# rdoc-file=vm_method.c
|
1358
|
+
# - mod.protected_method_defined?(symbol, inherit=true) -> true or false
|
1359
|
+
# - mod.protected_method_defined?(string, inherit=true) -> true or false
|
1360
|
+
# -->
|
1361
|
+
# Returns `true` if the named protected method is defined *mod*. If *inherit*
|
1362
|
+
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
1363
|
+
# converted to symbols.
|
1364
|
+
#
|
1365
|
+
# module A
|
1366
|
+
# def method1() end
|
1367
|
+
# end
|
1368
|
+
# class B
|
1369
|
+
# protected
|
1370
|
+
# def method2() end
|
1371
|
+
# end
|
1372
|
+
# class C < B
|
1373
|
+
# include A
|
1374
|
+
# def method3() end
|
1375
|
+
# end
|
1376
|
+
#
|
1377
|
+
# A.method_defined? :method1 #=> true
|
1378
|
+
# C.protected_method_defined? "method1" #=> false
|
1379
|
+
# C.protected_method_defined? "method2" #=> true
|
1380
|
+
# C.protected_method_defined? "method2", true #=> true
|
1381
|
+
# C.protected_method_defined? "method2", false #=> false
|
1382
|
+
# C.method_defined? "method2" #=> true
|
1383
|
+
#
|
1384
|
+
def protected_method_defined?: (interned name, ?boolish inherit) -> bool
|
1385
|
+
|
1386
|
+
# <!--
|
1387
|
+
# rdoc-file=vm_method.c
|
1388
|
+
# - public -> nil
|
1389
|
+
# - public(method_name) -> method_name
|
1390
|
+
# - public(method_name, method_name, ...) -> array
|
1391
|
+
# - public(array) -> array
|
1392
|
+
# -->
|
1393
|
+
# With no arguments, sets the default visibility for subsequently defined
|
1394
|
+
# methods to public. With arguments, sets the named methods to have public
|
1395
|
+
# visibility. String arguments are converted to symbols. An Array of Symbols
|
1396
|
+
# and/or Strings is also accepted. If a single argument is passed, it is
|
1397
|
+
# returned. If no argument is passed, nil is returned. If multiple arguments are
|
1398
|
+
# passed, the arguments are returned as an array.
|
1399
|
+
#
|
1400
|
+
def public: () -> nil
|
1401
|
+
| (Symbol method_name) -> Symbol
|
1402
|
+
| (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
|
1403
|
+
| (string method_name) -> string
|
1404
|
+
| (interned, interned, *interned method_name) -> Array[interned]
|
1405
|
+
| (Array[interned]) -> Array[interned]
|
1406
|
+
|
1407
|
+
# <!--
|
1408
|
+
# rdoc-file=vm_method.c
|
1409
|
+
# - mod.public_class_method(symbol, ...) -> mod
|
1410
|
+
# - mod.public_class_method(string, ...) -> mod
|
1411
|
+
# - mod.public_class_method(array) -> mod
|
1412
|
+
# -->
|
1413
|
+
# Makes a list of existing class methods public.
|
1414
|
+
#
|
1415
|
+
# String arguments are converted to symbols. An Array of Symbols and/or Strings
|
1416
|
+
# is also accepted.
|
1417
|
+
#
|
1418
|
+
def public_class_method: (*interned arg0) -> self
|
1419
|
+
| (Array[interned] arg0) -> self
|
1420
|
+
|
1421
|
+
# <!--
|
1422
|
+
# rdoc-file=object.c
|
1423
|
+
# - mod.public_constant(symbol, ...) => mod
|
1424
|
+
# -->
|
1425
|
+
# Makes a list of existing constants public.
|
1426
|
+
#
|
1427
|
+
def public_constant: (*interned arg0) -> self
|
1428
|
+
|
1429
|
+
# <!--
|
1430
|
+
# rdoc-file=proc.c
|
1431
|
+
# - mod.public_instance_method(symbol) -> unbound_method
|
1432
|
+
# -->
|
1433
|
+
# Similar to *instance_method*, searches public method only.
|
1434
|
+
#
|
1435
|
+
def public_instance_method: (interned arg0) -> UnboundMethod
|
1436
|
+
|
1437
|
+
# <!--
|
1438
|
+
# rdoc-file=object.c
|
1439
|
+
# - mod.public_instance_methods(include_super=true) -> array
|
1440
|
+
# -->
|
1441
|
+
# Returns a list of the public instance methods defined in *mod*. If the
|
1442
|
+
# optional parameter is `false`, the methods of any ancestors are not included.
|
1443
|
+
#
|
1444
|
+
def public_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
1445
|
+
|
1446
|
+
# <!--
|
1447
|
+
# rdoc-file=vm_method.c
|
1448
|
+
# - mod.public_method_defined?(symbol, inherit=true) -> true or false
|
1449
|
+
# - mod.public_method_defined?(string, inherit=true) -> true or false
|
1450
|
+
# -->
|
1451
|
+
# Returns `true` if the named public method is defined by *mod*. If *inherit*
|
1452
|
+
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
1453
|
+
# converted to symbols.
|
1454
|
+
#
|
1455
|
+
# module A
|
1456
|
+
# def method1() end
|
1457
|
+
# end
|
1458
|
+
# class B
|
1459
|
+
# protected
|
1460
|
+
# def method2() end
|
1461
|
+
# end
|
1462
|
+
# class C < B
|
1463
|
+
# include A
|
1464
|
+
# def method3() end
|
1465
|
+
# end
|
1466
|
+
#
|
1467
|
+
# A.method_defined? :method1 #=> true
|
1468
|
+
# C.public_method_defined? "method1" #=> true
|
1469
|
+
# C.public_method_defined? "method1", true #=> true
|
1470
|
+
# C.public_method_defined? "method1", false #=> true
|
1471
|
+
# C.public_method_defined? "method2" #=> false
|
1472
|
+
# C.method_defined? "method2" #=> true
|
1473
|
+
#
|
1474
|
+
def public_method_defined?: (interned name, ?boolish inherit) -> bool
|
1475
|
+
|
1476
|
+
# <!--
|
1477
|
+
# rdoc-file=eval.c
|
1478
|
+
# - refine(mod) { block } -> module
|
1479
|
+
# -->
|
1480
|
+
# Refine *mod* in the receiver.
|
1481
|
+
#
|
1482
|
+
# Returns a module, where refined methods are defined.
|
1483
|
+
#
|
1484
|
+
def refine: (Module mod) { () [self: Refinement] -> void } -> Refinement
|
1485
|
+
|
1486
|
+
# <!--
|
1487
|
+
# rdoc-file=eval.c
|
1488
|
+
# - refinements -> array
|
1489
|
+
# -->
|
1490
|
+
# Returns an array of `Refinement` defined within the receiver.
|
1491
|
+
#
|
1492
|
+
# module A
|
1493
|
+
# refine Integer do
|
1494
|
+
# end
|
1495
|
+
#
|
1496
|
+
# refine String do
|
1497
|
+
# end
|
1498
|
+
# end
|
1499
|
+
#
|
1500
|
+
# p A.refinements
|
1501
|
+
#
|
1502
|
+
# *produces:*
|
1503
|
+
#
|
1504
|
+
# [#<refinement:Integer@A>, #<refinement:String@A>]
|
1505
|
+
#
|
1506
|
+
def refinements: () -> Array[Refinement]
|
1507
|
+
|
1508
|
+
# <!--
|
1509
|
+
# rdoc-file=object.c
|
1510
|
+
# - remove_class_variable(sym) -> obj
|
1511
|
+
# -->
|
1512
|
+
# Removes the named class variable from the receiver, returning that variable's
|
1513
|
+
# value.
|
1514
|
+
#
|
1515
|
+
# class Example
|
1516
|
+
# @@var = 99
|
1517
|
+
# puts remove_class_variable(:@@var)
|
1518
|
+
# p(defined? @@var)
|
1519
|
+
# end
|
1520
|
+
#
|
1521
|
+
# *produces:*
|
1522
|
+
#
|
1523
|
+
# 99
|
1524
|
+
# nil
|
1525
|
+
#
|
1526
|
+
def remove_class_variable: (interned arg0) -> untyped
|
1527
|
+
|
1528
|
+
# <!--
|
1529
|
+
# rdoc-file=object.c
|
1530
|
+
# - remove_const(sym) -> obj
|
1531
|
+
# -->
|
1532
|
+
# Removes the definition of the given constant, returning that constant's
|
1533
|
+
# previous value. If that constant referred to a module, this will not change
|
1534
|
+
# that module's name and can lead to confusion.
|
1535
|
+
#
|
1536
|
+
def remove_const: (interned arg0) -> untyped
|
1537
|
+
|
1538
|
+
# <!--
|
1539
|
+
# rdoc-file=vm_method.c
|
1540
|
+
# - remove_method(symbol) -> self
|
1541
|
+
# - remove_method(string) -> self
|
1542
|
+
# -->
|
1543
|
+
# Removes the method identified by *symbol* from the current class. For an
|
1544
|
+
# example, see Module#undef_method. String arguments are converted to symbols.
|
1545
|
+
#
|
1546
|
+
def remove_method: (*interned arg0) -> self
|
1547
|
+
|
1548
|
+
# <!--
|
1549
|
+
# rdoc-file=object.c
|
1550
|
+
# - mod.set_temporary_name(string) -> self
|
1551
|
+
# - mod.set_temporary_name(nil) -> self
|
1552
|
+
# -->
|
1553
|
+
# Sets the temporary name of the module. This name is reflected in introspection
|
1554
|
+
# of the module and the values that are related to it, such as instances,
|
1555
|
+
# constants, and methods.
|
1556
|
+
#
|
1557
|
+
# The name should be `nil` or a non-empty string that is not a valid constant
|
1558
|
+
# path (to avoid confusing between permanent and temporary names).
|
1559
|
+
#
|
1560
|
+
# The method can be useful to distinguish dynamically generated classes and
|
1561
|
+
# modules without assigning them to constants.
|
1562
|
+
#
|
1563
|
+
# If the module is given a permanent name by assigning it to a constant, the
|
1564
|
+
# temporary name is discarded. A temporary name can't be assigned to modules
|
1565
|
+
# that have a permanent name.
|
1566
|
+
#
|
1567
|
+
# If the given name is `nil`, the module becomes anonymous again.
|
1568
|
+
#
|
1569
|
+
# Example:
|
1570
|
+
#
|
1571
|
+
# m = Module.new # => #<Module:0x0000000102c68f38>
|
1572
|
+
# m.name #=> nil
|
1573
|
+
#
|
1574
|
+
# m.set_temporary_name("fake_name") # => fake_name
|
1575
|
+
# m.name #=> "fake_name"
|
1576
|
+
#
|
1577
|
+
# m.set_temporary_name(nil) # => #<Module:0x0000000102c68f38>
|
1578
|
+
# m.name #=> nil
|
1579
|
+
#
|
1580
|
+
# c = Class.new
|
1581
|
+
# c.set_temporary_name("MyClass(with description)")
|
1582
|
+
#
|
1583
|
+
# c.new # => #<MyClass(with description):0x0....>
|
1584
|
+
#
|
1585
|
+
# c::M = m
|
1586
|
+
# c::M.name #=> "MyClass(with description)::M"
|
1587
|
+
#
|
1588
|
+
# # Assigning to a constant replaces the name with a permanent one
|
1589
|
+
# C = c
|
1590
|
+
#
|
1591
|
+
# C.name #=> "C"
|
1592
|
+
# C::M.name #=> "C::M"
|
1593
|
+
# c.new # => #<C:0x0....>
|
1594
|
+
#
|
1595
|
+
def set_temporary_name: (string?) -> self
|
1596
|
+
|
1597
|
+
# <!--
|
1598
|
+
# rdoc-file=object.c
|
1599
|
+
# - mod.singleton_class? -> true or false
|
1600
|
+
# -->
|
1601
|
+
# Returns `true` if *mod* is a singleton class or `false` if it is an ordinary
|
1602
|
+
# class or module.
|
1603
|
+
#
|
1604
|
+
# class C
|
1605
|
+
# end
|
1606
|
+
# C.singleton_class? #=> false
|
1607
|
+
# C.singleton_class.singleton_class? #=> true
|
1608
|
+
#
|
1609
|
+
def singleton_class?: () -> bool
|
1610
|
+
|
1611
|
+
# <!--
|
1612
|
+
# rdoc-file=object.c
|
1613
|
+
# - mod.to_s -> string
|
1614
|
+
# -->
|
1615
|
+
# Returns a string representing this module or class. For basic classes and
|
1616
|
+
# modules, this is the name. For singletons, we show information on the thing
|
1617
|
+
# we're attached to as well.
|
1618
|
+
#
|
1619
|
+
def to_s: () -> String
|
1620
|
+
|
1621
|
+
# <!--
|
1622
|
+
# rdoc-file=vm_method.c
|
1623
|
+
# - undef_method(symbol) -> self
|
1624
|
+
# - undef_method(string) -> self
|
1625
|
+
# -->
|
1626
|
+
# Prevents the current class from responding to calls to the named method.
|
1627
|
+
# Contrast this with `remove_method`, which deletes the method from the
|
1628
|
+
# particular class; Ruby will still search superclasses and mixed-in modules for
|
1629
|
+
# a possible receiver. String arguments are converted to symbols.
|
1630
|
+
#
|
1631
|
+
# class Parent
|
1632
|
+
# def hello
|
1633
|
+
# puts "In parent"
|
1634
|
+
# end
|
1635
|
+
# end
|
1636
|
+
# class Child < Parent
|
1637
|
+
# def hello
|
1638
|
+
# puts "In child"
|
1639
|
+
# end
|
1640
|
+
# end
|
1641
|
+
#
|
1642
|
+
# c = Child.new
|
1643
|
+
# c.hello
|
1644
|
+
#
|
1645
|
+
# class Child
|
1646
|
+
# remove_method :hello # remove from child, still in parent
|
1647
|
+
# end
|
1648
|
+
# c.hello
|
1649
|
+
#
|
1650
|
+
# class Child
|
1651
|
+
# undef_method :hello # prevent any calls to 'hello'
|
1652
|
+
# end
|
1653
|
+
# c.hello
|
1654
|
+
#
|
1655
|
+
# *produces:*
|
1656
|
+
#
|
1657
|
+
# In child
|
1658
|
+
# In parent
|
1659
|
+
# prog.rb:23: undefined method 'hello' for #<Child:0x401b3bb4> (NoMethodError)
|
1660
|
+
#
|
1661
|
+
def undef_method: (*interned arg0) -> self
|
1662
|
+
|
1663
|
+
# <!--
|
1664
|
+
# rdoc-file=object.c
|
1665
|
+
# - mod.undefined_instance_methods -> array
|
1666
|
+
# -->
|
1667
|
+
# Returns a list of the undefined instance methods defined in *mod*. The
|
1668
|
+
# undefined methods of any ancestors are not included.
|
1669
|
+
#
|
1670
|
+
def undefined_instance_methods: () -> Array[Symbol]
|
1671
|
+
|
1672
|
+
# <!--
|
1673
|
+
# rdoc-file=eval.c
|
1674
|
+
# - using(module) -> self
|
1675
|
+
# -->
|
1676
|
+
# Import class refinements from *module* into the current class or module
|
1677
|
+
# definition.
|
1678
|
+
#
|
1679
|
+
def using: (Module arg0) -> self
|
1680
|
+
|
1681
|
+
# <!-- rdoc-file=object.c -->
|
1682
|
+
# Returns a string representing this module or class. For basic classes and
|
1683
|
+
# modules, this is the name. For singletons, we show information on the thing
|
1684
|
+
# we're attached to as well.
|
1685
|
+
#
|
1686
|
+
def inspect: () -> String
|
1687
|
+
|
1688
|
+
# <!--
|
1689
|
+
# rdoc-file=object.c
|
1690
|
+
# - attr(name, ...) -> array
|
1691
|
+
# - attr(name, true) -> array
|
1692
|
+
# - attr(name, false) -> array
|
1693
|
+
# -->
|
1694
|
+
# The first form is equivalent to #attr_reader. The second form is equivalent to
|
1695
|
+
# `attr_accessor(name)` but deprecated. The last form is equivalent to
|
1696
|
+
# `attr_reader(name)` but deprecated. Returns an array of defined method names
|
1697
|
+
# as symbols.
|
1698
|
+
#
|
1699
|
+
def attr: (*interned arg0) -> Array[Symbol]
|
1700
|
+
|
1701
|
+
# A previous incarnation of `interned` for backward-compatibility (see #1499)
|
1702
|
+
%a{steep:deprecated}
|
1703
|
+
type id = interned
|
1704
|
+
end
|