るりまサーチ

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

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. _builtin $-i
  5. _builtin i

検索結果

<< 1 2 3 > >>

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

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

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

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

@param fname ファイル名...
...ram lineno 行番号を整数で与えます。式 expr の先頭行の行番号が lineno であるかのように実行されます。

//emlist[例][ruby]{
def get_binding(str)
binding

end
str = "hello"
p eval("str + ' Fred'") #=> "hello Fred"
p get_binding("bye").eval("str...
...+ ' Fred'") #=> "bye Fred"
//}

@see Kernel.#eval...

Kernel.#binding -> Binding (30658.0)

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

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

//emlist[例][ruby]{
def foo
a = 1
binding

end

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

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

Proc#binding -> Binding (30630.0)

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

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

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

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

irb (26174.0)

irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

...irb は Interactive Ruby の略です。
i
rb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

=== irb の使い方

Ruby さえ知っていれば irb を使うのは簡単です。
i
rb コマンドを実行すると、以下のようなプロン...
...--back-trace-limit n
バックトレース表示をバックトレースの頭から n、
うしろから n だけ行なう。デフォルト値は 16。
--context-mode n 新しいワークスペースを作成した時に関連する Binding...
....irbrc に記述すると、
i
rb コマンドのオプションを指定したのと同じ効果が得られます。

I
RB.conf[:AUTO_INDENT] = false
I
RB.conf[:BACK_TRACE_LIMIT] = 16
I
RB.conf[:DEBUG_LEVEL] = 1
I
RB.conf[:ECHO] = nil
I
RB.conf[:EVAL_HISTORY] = nil
I
RB.conf[:HISTORY_FILE] =...

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

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

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

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

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

@see Binding#loc...
...al_variable_get, Binding#local_variable_set...

絞り込み条件を変える

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

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

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

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

fname と lineno が与えられた場合には、ファイル
fname の行番号 lineno から文字列 expr が書かれているかのように
コンパイルされます。スタックトレースの表示などを差し替えることが
できます。

bind によらずに特定...
...価したい場合、
Module#module_eval, BasicObject#instance_eval が使えます。

@param expr 評価する文字列です。
@param bind 評価コンテキストです。
@param fname スタックトレースに表示するファイル名です。
@param lineno 文字列 expr が書かれて...

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

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

...mbol オブジェクトで指定します。

@raise NameError 引数 symbol で指定したローカル変数が未定義の場合に発生します。

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

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

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

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

Binding#local_variable_set(symbol, obj) (18136.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.lo...
...cal_variable_get(:b) # => 3
p a # => 2
p b # => NameError
end
//}

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

//emlist[][ruby]{
binding
.eval("#{sy...
...mbol} = #{obj}")
//}

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

Binding#local_variables -> [Symbol] (18118.0)

ローカル変数の一覧を Symbol の配列で返します。

...カル変数の一覧を Symbol の配列で返します。

//emlist[例][ruby]{
def foo
a = 1
2.times do |n|
binding
.local_variables #=> [:a, :n]
end
end
//}

このメソッドは以下のコードと同様の動作をします。

//emlist[][ruby]{
binding
.eval("local_variables")
//}...

Binding#receiver -> object (18112.0)

保持するコンテキスト内での self を返します。

...保持するコンテキスト内での self を返します。

このメソッドは以下のコードと同様の動作をします。

//emlist[][ruby]{
binding
.eval("self")
//}...

絞り込み条件を変える

<< 1 2 3 > >>