るりまサーチ

最速Rubyリファレンスマニュアル検索!
30件ヒット [1-30件を表示] (0.091秒)

別のキーワード

  1. _builtin call
  2. method call
  3. fiddle call
  4. continuation call
  5. formatter call

ライブラリ

クラス

キーワード

検索結果

Module#instance_method(name) -> UnboundMethod (18174.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...#public_instance_method, Object#method

//emlist[例][ruby]{
class Interpreter
def do_a() print "there, "; end
def do_d() print "Hello "; end
def do_e() print "!\n"; end
def do_v() print "Dave"; end
Dispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method(:do_d)...
...,
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
}
def interpret(string)
string.each_char {|b| Dispatcher[b].bind(self).call }
end

end


interpreter = Interpreter.new
interpreter.interpret('dave')
# => Hello there, Dave!
//}...

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

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

...ist[例][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#foo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class Bar
include Foo
end

p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}

@see UnboundMethod#bind_call...

Object#singleton_method(name) -> Method (37.0)

オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。

...v = n
end

def hello()
"Hello, @iv = #{@iv}"
end

end


k = Demo.new(99)
def k.hi
"Hi, @iv = #{@iv}"
end

m = k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) # => NameError
//}

@see Module#instance_method, Me...
...thod, BasicObject#__send__, Object#send, Kernel.#eval, Object#method...