るりまサーチ

最速Rubyリファレンスマニュアル検索!
167件ヒット [1-100件を表示] (0.085秒)
トップページ > クエリ:_builtin[x] > クエリ:new[x] > クエリ:UnboundMethod[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

UnboundMethod (46042.0)

レシーバを持たないメソッドを表すクラスです。 呼び出すためにはレシーバにバインドする必要があります。

...nce_method や
Method#unbind により生成し、後で
UnboundMethod
#bind によりレシーバを
割り当てた Method オブジェクトを作ることができます。

//emlist[例: Method クラスの冒頭にある例を UnboundMethod で書くと以下のようになります。][ruby]{...
...スでなければならない)
p methods[1].bind(Foo.new).call # => "foo"
p methods[2].bind(Foo.new).call # => "bar"
p methods[3].bind(Foo.new).call # => "baz"
//}

//emlist[例: 以下はメソッドの再定義を UnboundMethod を使って行う方法です。普通は alias や s...
...uper を使います。][ruby]{
class Foo
def foo
p :foo
end
@@orig_foo = instance_method :foo
def foo
p :bar
@@orig_foo.bind(self).call
end
end

Foo.new.foo

# => :bar
# :foo
//}...

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

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

...スメソッドの UnboundMethod の場合
class Foo
def foo
"foo"
end
end

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

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

@see UnboundMethod#bind_call...

UnboundMethod#bind_call(recv, *args) -> object (29012.0)

self を recv に bind して args を引数として呼び出します。

...self を recv に bind して args を引数として呼び出します。

self.bind(recv).call(*args) と同じ意味です。

//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}

@see UnboundMethod#bind, Method#call...

UnboundMethod#bind_call(recv, *args) { ... } -> object (29012.0)

self を recv に bind して args を引数として呼び出します。

...self を recv に bind して args を引数として呼び出します。

self.bind(recv).call(*args) と同じ意味です。

//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}

@see UnboundMethod#bind, Method#call...

Method#unbind -> UnboundMethod (8135.0)

self のレシーバとの関連を取り除いた UnboundMethod オブ ジェクトを生成して返します。

...を取り除いた UnboundMethod オブ
ジェクトを生成して返します。

//emlist[例][ruby]{
class Foo
def foo
"foo"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
unbound_method = m.unbind # => #<UnboundMethod: Foo#foo>
unbound_method.bind(Foo.new) # => #<Method: Foo#...

絞り込み条件を変える

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

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

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

@param name メソッド名を Symbol または String で指定します。

@raise NameError self に存在しないメソッドを指定した場合に発生します。

@see Module#publ...
...d(: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!
//}...

Method#inspect -> String (8024.0)

self を読みやすい文字列として返します。

...#<Method: klass1(klass2)#method> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod
#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュール名です。

klass2 は、実際にそのメソッド...
...

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end

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

klass1 と klass2 が同じ場合は以下の形式になります。...
...#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod
#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュール名です。

klass2 は、実際にそのメソッド...
...st[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar(a, b)
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}

klass1 と klass2 が同じ場合は以下の...

Method#to_s -> String (8024.0)

self を読みやすい文字列として返します。

...#<Method: klass1(klass2)#method> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod
#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュール名です。

klass2 は、実際にそのメソッド...
...

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end

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

klass1 と klass2 が同じ場合は以下の形式になります。...
...#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod
#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュール名です。

klass2 は、実際にそのメソッド...
...st[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar(a, b)
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}

klass1 と klass2 が同じ場合は以下の...

Marshal.#dump(obj, limit = -1) -> String (8018.0)

obj を指定された出力先に再帰的に出力します。

...ついて
は、Module.new を参照。)
* システムがオブジェクトの状態を保持するもの。具体的には以下のイン
スタンス。Dir, File::Stat, IO とそのサブクラス
File, Socket など。
* MatchData, Data, Method, UnboundMethod,
Proc, Thread, ThreadG...
...を求めるブロックを持った Hash は
Proc を間接的に指していることになります。

//emlist[例][ruby]{
p Marshal.dump(Hash.new {})
# => -:1:in `dump': cannot dump hash with default proc (TypeError)
//}

マーシャルの動作を任意に定義することもできます。...

Marshal.#dump(obj, port, limit = -1) -> IO (8018.0)

obj を指定された出力先に再帰的に出力します。

...ついて
は、Module.new を参照。)
* システムがオブジェクトの状態を保持するもの。具体的には以下のイン
スタンス。Dir, File::Stat, IO とそのサブクラス
File, Socket など。
* MatchData, Data, Method, UnboundMethod,
Proc, Thread, ThreadG...
...を求めるブロックを持った Hash は
Proc を間接的に指していることになります。

//emlist[例][ruby]{
p Marshal.dump(Hash.new {})
# => -:1:in `dump': cannot dump hash with default proc (TypeError)
//}

マーシャルの動作を任意に定義することもできます。...

絞り込み条件を変える

Method#===(*args) -> object (8012.0)

メソッドオブジェクトに封入されているメソッドを起動します。

...連性はありません。


@param args self に渡される引数。

@see UnboundMethod#bind_call
@see spec/safelevel

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"...
...的な関連性はありません。


@param args self に渡される引数。

@see UnboundMethod#bind_call

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2)...
<< 1 2 > >>