るりまサーチ

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

別のキーワード

  1. socket bind
  2. addrinfo bind
  3. udpsocket bind
  4. etc sc_2_c_bind
  5. resolv-replace bind

検索結果

<< 1 2 > >>

Binding#eval(expr, fname = __FILE__, lineno = 1) -> object (21151.0)

自身をコンテキストとし文字列 expr を Ruby プログラムとして評価しその結果を返します。 組み込み関数 Kernel.#eval を使って eval(expr, self, fname, lineno) とするのと同じです。

...コンテキストとし文字列 expr を
Ruby プログラムとして評価しその結果を返します。
組み込み関数 Kernel.#eval を使って
eval
(expr, self, fname, lineno) とするのと同じです。

@param expr 評価したい式を文字列で与えます。

@param fname フ...
...の先頭行の行番号が lineno であるかのように実行されます。

//emlist[例][ruby]{
def get_binding(str)
bind
ing
end
str = "hello"
p eval("str + ' Fred'") #=> "hello Fred"
p get_binding("bye").eval("str + ' Fred'") #=> "bye Fred"
//}

@see Kernel.#eval...

Kernel.#eval(expr, bind, fname = "(eval)", lineno = 1) -> object (18370.0)

文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。

...
Bind
ing オブジェクトを与えた場合、
そのオブジェクトを生成したコンテキストで文字列を評価します。

expr の中のローカル変数の扱いはブロックの場合と同じです。すなわち、eval
実行前に補足されていた変数は eval...
...替えることが
できます。

bind
によらずに特定のオブジェクトのコンテキストで expr を評価したい場合、
Module#module_eval, BasicObject#instance_eval が使えます。

@param expr 評価する文字列です。
@param bind 評価コンテキストです。
@p...
...ruby]{
a = nil
eval
('a = RUBY_RELEASE_DATE')
p a #=> "2007-03-13"

eval
('def fuga;p 777 end')
fuga #=> 777

eval
('raise RuntimeError', binding, 'XXX.rb', 4)
#=> XXX.rb:4: RuntimeError (RuntimeError)
# from ..:9
//}

@see Kernel.#binding,Module#module_eval,BasicObject#instance_eval,Object#metho...

Kernel.#eval(expr) -> object (18170.0)

文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。

...
Bind
ing オブジェクトを与えた場合、
そのオブジェクトを生成したコンテキストで文字列を評価します。

expr の中のローカル変数の扱いはブロックの場合と同じです。すなわち、eval
実行前に補足されていた変数は eval...
...替えることが
できます。

bind
によらずに特定のオブジェクトのコンテキストで expr を評価したい場合、
Module#module_eval, BasicObject#instance_eval が使えます。

@param expr 評価する文字列です。
@param bind 評価コンテキストです。
@p...
...ruby]{
a = nil
eval
('a = RUBY_RELEASE_DATE')
p a #=> "2007-03-13"

eval
('def fuga;p 777 end')
fuga #=> 777

eval
('raise RuntimeError', binding, 'XXX.rb', 4)
#=> XXX.rb:4: RuntimeError (RuntimeError)
# from ..:9
//}

@see Kernel.#binding,Module#module_eval,BasicObject#instance_eval,Object#metho...

Kernel.#binding -> Binding (6228.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...

Proc#binding -> Binding (6206.0)

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

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

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

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

絞り込み条件を変える

Binding (6006.0)

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

...トのクラスです。

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

Binding#local_variable_set(symbol, obj) (3036.0)

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

...by]{
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.local_variable_get(...
...# => NameError
end
//}

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

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

@see Binding#local_variable_get, Binding#local_variable_defined?...

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

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

...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#local_variable_get, Binding#loc...

Binding#local_variable_get(symbol) -> object (3006.0)

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

...例][ruby]{
def foo
a = 1
bind
ing.local_variable_get(:a) # => 1
bind
ing.local_variable_get(:b) # => NameError
end
//}

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

//emlist[][ruby]{
bind
ing.eval("#{symbol}")
//}

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