diff --git a/core/method.rbs b/core/method.rbs index cd97e9edd..da6f464de 100644 --- a/core/method.rbs +++ b/core/method.rbs @@ -22,9 +22,100 @@ # %w[2017-03-01 2017-03-02].collect(&Date.method(:parse)) # #=> [#, #] # -class Method < Object +class Method + # The return type from `#parameters` methods (such as those defined on `Method`, `Proc`, and `UnboundMethod`). type param_types = Array[[:req | :opt | :rest | :keyreq | :key | :keyrest | :block, Symbol] | [:rest | :keyrest | :nokey]] + # + # Two method objects are equal if they are bound to the same object and refer to + # the same method definition and the classes defining the methods are the same + # class or module. + # + def ==: (untyped other) -> bool + + # + # Two method objects are equal if they are bound to the same object and refer to + # the same method definition and the classes defining the methods are the same + # class or module. + # + alias eql? == + + # + # Returns a hash value corresponding to the method object. + # + # See also Object#hash. + # + def hash: () -> Integer + + def dup: () -> instance + + # + # Returns a human-readable description of the underlying method. + # + # "cat".method(:count).inspect #=> "#" + # (1..3).method(:map).inspect #=> "#" + # + # In the latter case, the method description includes the "owner" of the + # original method (`Enumerable` module, which is included into `Range`). + # + # `inspect` also provides, when possible, method argument names (call sequence) + # and source location. + # + # require 'net/http' + # Net::HTTP.method(:get).inspect + # #=> "#/lib/ruby/2.7.0/net/http.rb:457>" + # + # `...` in argument definition means argument is optional (has some default + # value). + # + # For methods defined in C (language core and extensions), location and argument + # names can't be extracted, and only generic information is provided in form of + # `*` (any number of arguments) or `_` (some positional argument). + # + # "cat".method(:count).inspect #=> "#" + # "cat".method(:+).inspect #=> "#"" + # + def inspect: () -> String + + # + # Returns a human-readable description of the underlying method. + # + # "cat".method(:count).inspect #=> "#" + # (1..3).method(:map).inspect #=> "#" + # + # In the latter case, the method description includes the "owner" of the + # original method (`Enumerable` module, which is included into `Range`). + # + # `inspect` also provides, when possible, method argument names (call sequence) + # and source location. + # + # require 'net/http' + # Net::HTTP.method(:get).inspect + # #=> "#/lib/ruby/2.7.0/net/http.rb:457>" + # + # `...` in argument definition means argument is optional (has some default + # value). + # + # For methods defined in C (language core and extensions), location and argument + # names can't be extracted, and only generic information is provided in form of + # `*` (any number of arguments) or `_` (some positional argument). + # + # "cat".method(:count).inspect #=> "#" + # "cat".method(:+).inspect #=> "#"" + # + alias to_s inspect + # # Invokes the *meth* with the specified arguments, returning the method's return @@ -90,7 +181,7 @@ class Method < Object # g = proc {|x| x + x } # p (f >> g).call(2) #=> 8 # - def >>: (Proc g) -> Proc + def >>: (Proc::_Callable g) -> Proc # # Invokes the *meth* with the specified arguments, returning the method's return @@ -161,7 +252,7 @@ class Method < Object # m.call # => "bar" # n = m.clone.call # => "bar" # - def clone: () -> Method + def clone: () -> instance #