るりまサーチ

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

別のキーワード

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

クラス

モジュール

検索結果

<< 1 2 > >>

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

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

...みです。

@raise TypeError objがbindできないオブジェクトである場合に発生します

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

# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo...
...スをレシーバとする Method オブジェクトを生成
p m.bind(Foo.new) # => #<Method: Foo#foo>

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


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

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

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

@see UnboundMethod#bi...

TracePoint#binding -> Binding (29602.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...発生したイベントによって生成された Binding オブジェクトを返します。


//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}...

TracePoint#binding -> Binding | nil (29602.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...れた Binding オブジェクトを返します。

C で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:...
...call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}...

Kernel.#binding -> Binding (26602.0)

変数・メソッドなどの環境情報を含んだ Binding オブジェクトを 生成して返します。通常、Kernel.#eval の第二引数として使います。

...変数・メソッドなどの環境情報を含んだ Binding オブジェクトを
生成して返します。通常、Kernel.#eval の第二引数として使います。

//emlist[例][ruby]{
def foo
a = 1
bind
ing
end

eval("p a", foo) #=> 1
//}

@see Kernel.#eval,Object::TOPLEVEL_BINDING...

Object::TOPLEVEL_BINDING -> Binding (26602.0)

トップレベルでの Binding オブジェクト。

...トップレベルでの Binding オブジェクト。

詳細は Binding を参照してください。...

絞り込み条件を変える

Proc#binding -> Binding (26602.0)

Proc オブジェクトが保持するコンテキストを Binding オブジェクトで返します。

...Proc オブジェクトが保持するコンテキストを
Bind
ing オブジェクトで返します。

//emlist[例][ruby]{
def fred(param)
proc {}
end

sample_proc = fred(99)
eval("param", sample_proc.binding) # => 99
//}...

Binding (26002.0)

ローカル変数のテーブルと self、モジュールのネストなどの情報を保 持するオブジェクトのクラスです。

...トのクラスです。

組み込み関数 Kernel.#binding と Proc#binding によっ
てのみ生成され、Kernel.#eval の第 2 引数に使用します。
またトップレベルの Binding オブジェクトとして組み込み定数
Object::TOPLEVEL_BINDING が用意されています。...

Binding#local_variable_defined?(symbol) -> bool (23102.0)

引数 symbol で指定した名前のローカル変数が定義されている場合に true を、 そうでない場合に false を返します。

...//emlist[例][ruby]{
def foo
a = 1
bind
ing.local_variable_defined?(:a) # => true
bind
ing.local_variable_defined?(:b) # => false
end
//}

このメソッドは以下のコードの短縮形です。

//emlist[][ruby]{
bind
ing.eval("defined?(#{symbol}) == 'local-variable'")
//}

@see Binding#lo...
...cal_variable_get, Binding#local_variable_set...

UnboundMethod#bind_call(recv, *args) -> object (20238.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 (20238.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 (20208.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#foo>
//}...

Binding#local_variable_set(symbol, obj) (20132.0)

引数 symbol で指定した名前のローカル変数に引数 obj を設定します。

...//emlist[例][ruby]{
def foo
a = 1
bind
= binding
bind
.local_variable_set(:a, 2) # set existing local variable `a'
bind
.local_variable_set(:b, 3) # create new local variable `b'
# `b' exists only in binding
p bind.local_variable_get(:a) # => 2
p bind.loc...
...al_variable_get(:b) # => 3
p a # => 2
p b # => NameError
end
//}

このメソッドは以下のコード(ただし、obj が Ruby のコードで出力される場
合)と同様の動作をします。

//emlist[][ruby]{
bind
ing.eval("#{sym...
...bol} = #{obj}")
//}

@see Binding#local_variable_get, Binding#local_variable_defined?...
<< 1 2 > >>