るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.046秒)
トップページ > クエリ:Module[x] > クエリ:class[x] > クエリ:instance_method[x] > クラス:UnboundMethod[x]

別のキーワード

  1. argf.class each_line
  2. argf.class each
  3. argf.class lines
  4. argf.class to_a
  5. argf.class readlines

ライブラリ

キーワード

検索結果

UnboundMethod#owner -> Class | Module (253.0)

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

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

//emlist[例][ruby]{
Integer.instance_method(:to_s).owner # => Integer
Integer.instance_method(:to_c).owner # => Numeric
Integer.instance_method(:hash).owner # => Kernel
//}...

UnboundMethod#bind(obj) -> Method (37.0)

self を obj にバインドした Method オブジェクトを生成して返します。

...ます

//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class
Foo
def foo
"foo"
end
end

# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#foo>

# Foo のインスタンスをレシーバとする Method オ...
...Method
class
Bar < Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>


# モジュールのインスタンスメソッドの UnboundMethod の場合
module
Foo
def foo
"foo"
end
end

# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#f...
...oo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class
Bar
include Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}...
...oo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class
Bar
include Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}

@see UnboundMethod#bind_call...