このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 3.1 リファレンスマニュアル

instance method Method#owner

owner -> Class | Module[permalink][rdoc][edit]

このメソッドが定義されている class か module を返します。

class Foo
  def foo(arg)
    "foo called with arg #{arg}"
  end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
p m.owner # => Foo

m = Foo.new.method(:puts) # => #<Method: Foo(Kernel)#puts>
p m.owner # => Kernel