core/module.rbs in rbs-3.0.0.dev.2 vs core/module.rbs in rbs-3.0.0.dev.3

- old
+ new

@@ -84,16 +84,44 @@ # [B, A] # def self.used_modules: () -> ::Array[Module] # <!-- + # rdoc-file=eval.c + # - used_refinements -> array + # --> + # Returns an array of all modules used in the current scope. The ordering of + # modules in the resulting array is not defined. + # + # module A + # refine Object do + # end + # end + # + # module B + # refine Object do + # end + # end + # + # using A + # using B + # p Module.used_refinements + # + # *produces:* + # + # [#<refinement:Object@B>, #<refinement:Object@A>] + # + def self.used_refinements: () -> Array[Refinement] + + # <!-- # rdoc-file=object.c # - mod < other -> true, false, or nil # --> - # Returns true if *mod* is a subclass of *other*. Returns `nil` if there's no - # relationship between the two. (Think of the relationship in terms of the class - # definition: "class A < B" implies "A < B".) + # Returns true if *mod* is a subclass of *other*. Returns `false` if *mod* is + # the same as *other* or *mod* is an ancestor of *other*. Returns `nil` if + # there's no relationship between the two. (Think of the relationship in terms + # of the class definition: "class A < B" implies "A < B".) # def <: (Module other) -> bool? # <!-- # rdoc-file=object.c @@ -167,13 +195,14 @@ # <!-- # rdoc-file=object.c # - mod > other -> true, false, or nil # --> - # Returns true if *mod* is an ancestor of *other*. Returns `nil` if there's no - # relationship between the two. (Think of the relationship in terms of the class - # definition: "class A < B" implies "B > A".) + # Returns true if *mod* is an ancestor of *other*. Returns `false` if *mod* is + # the same as *other* or *mod* is a descendant of *other*. Returns `nil` if + # there's no relationship between the two. (Think of the relationship in terms + # of the class definition: "class A < B" implies "B > A".) # def >: (Module other) -> bool? # <!-- # rdoc-file=object.c @@ -253,11 +282,11 @@ # module Mod # attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=] # end # Mod.instance_methods.sort #=> [:one, :one=, :two, :two=] # - def attr_accessor: (*Symbol | String arg0) -> NilClass + def attr_accessor: (*Symbol | String arg0) -> Array[Symbol] # <!-- # rdoc-file=object.c # - attr_reader(symbol, ...) -> array # - attr(symbol, ...) -> array @@ -267,36 +296,40 @@ # Creates instance variables and corresponding methods that return the value of # each instance variable. Equivalent to calling ```attr`*:name*'' on each name # in turn. String arguments are converted to symbols. Returns an array of # defined method names as symbols. # - def attr_reader: (*Symbol | String arg0) -> NilClass + def attr_reader: (*Symbol | String arg0) -> Array[Symbol] # <!-- # rdoc-file=object.c # - attr_writer(symbol, ...) -> array # - attr_writer(string, ...) -> array # --> # Creates an accessor method to allow assignment to the attribute # *symbol*`.id2name`. String arguments are converted to symbols. Returns an # array of defined method names as symbols. # - def attr_writer: (*Symbol | String arg0) -> NilClass + def attr_writer: (*Symbol | String arg0) -> Array[Symbol] # <!-- # rdoc-file=load.c - # - mod.autoload(module, filename) -> nil + # - mod.autoload(const, filename) -> nil # --> - # Registers *filename* to be loaded (using Kernel::require) the first time that - # *module* (which may be a String or a symbol) is accessed in the namespace of - # *mod*. + # Registers _filename_ to be loaded (using Kernel::require) + # the first time that _const_ (which may be a String or + # a symbol) is accessed in the namespace of _mod_. # - # module A - # end - # A.autoload(:B, "b") - # A::B.doit # autoloads "b" + # module A + # end + # A.autoload(:B, "b") + # A::B.doit # autoloads "b" # + # If *const* in *mod* is defined as autoload, the file name to be loaded is + # replaced with *filename*. If *const* is defined but not as autoload, does + # nothing. + # def autoload: (Symbol _module, String filename) -> NilClass # <!-- # rdoc-file=load.c # - mod.autoload?(name, inherit=true) -> String or nil @@ -436,10 +469,30 @@ # def class_variables: (?boolish inherit) -> ::Array[Symbol] # <!-- # rdoc-file=object.c + # - const_added(const_name) + # --> + # Invoked as a callback whenever a constant is assigned on the receiver + # + # module Chatty + # def self.const_added(const_name) + # super + # puts "Added #{const_name.inspect}" + # end + # FOO = 1 + # end + # + # *produces:* + # + # Added :FOO + # + def const_added: (Symbol) -> void + + # <!-- + # rdoc-file=object.c # - mod.const_defined?(sym, inherit=true) -> true or false # - mod.const_defined?(str, inherit=true) -> true or false # --> # Says whether *mod* or its ancestors have a constant with the given name: # @@ -909,10 +962,19 @@ # B.instance_methods(false) #=> [:method2] # B.instance_methods(true).include?(:method1) #=> true # C.instance_methods(false) #=> [:method3] # C.instance_methods.include?(:method2) #=> true # + # Note that method visibility changes in the current class, as well as aliases, + # are considered as methods of the current class by this method: + # + # class C < B + # alias method4 method2 + # protected :method2 + # end + # C.instance_methods(false).sort #=> [:method2, :method3, :method4] + # def instance_methods: (?boolish include_super) -> ::Array[Symbol] # <!-- # rdoc-file=object.c # - method_added(method_name) @@ -1402,10 +1464,32 @@ # Returns a module, where refined methods are defined. # def refine: (Module mod) { () -> void } -> Refinement # <!-- + # rdoc-file=eval.c + # - refinements -> array + # --> + # Returns an array of modules defined within the receiver. + # + # module A + # refine Integer do + # end + # + # refine String do + # end + # end + # + # p A.refinements + # + # *produces:* + # + # [#<refinement:Integer@A>, #<refinement:String@A>] + # + def refinements: () -> Array[Refinement] + + # <!-- # rdoc-file=object.c # - remove_class_variable(sym) -> obj # --> # Removes the named class variable from the receiver, returning that variable's # value. @@ -1506,9 +1590,18 @@ # In child # In parent # prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError) # def undef_method: (*Symbol | String arg0) -> self + + # <!-- + # rdoc-file=object.c + # - mod.undefined_instance_methods -> array + # --> + # Returns a list of the undefined instance methods defined in *mod*. The + # undefined methods of any ancestors are not included. + # + def undefined_instance_methods: () -> Array[Symbol] # <!-- # rdoc-file=eval.c # - using(module) -> self # -->