種類
- インスタンスメソッド (160)
- モジュール関数 (66)
- 定数 (11)
- クラス (11)
- 特異メソッド (11)
クラス
- Binding (78)
- Object (11)
- Proc (11)
-
RubyVM
:: InstructionSequence (11) - Thread (49)
- TracePoint (22)
モジュール
- Kernel (44)
- ObjectSpace (22)
キーワード
-
TOPLEVEL
_ BINDING (11) -
add
_ trace _ func (11) - backtrace (11)
- binding (33)
-
define
_ finalizer (22) - eval (33)
- irb (8)
-
local
_ variable _ defined? (11) -
local
_ variable _ get (11) -
local
_ variable _ set (11) -
local
_ variables (10) - of (11)
- receiver (10)
-
report
_ on _ exception (8) -
report
_ on _ exception= (8) - self (11)
-
set
_ trace _ func (22) -
source
_ location (6)
検索結果
先頭5件
-
Binding (46026.0)
-
ローカル変数のテーブルと self、モジュールのネストなどの情報を保 持するオブジェクトのクラスです。
...トのクラスです。
組み込み関数 Kernel.#binding と Proc#binding によっ
てのみ生成され、Kernel.#eval の第 2 引数に使用します。
またトップレベルの Binding オブジェクトとして組み込み定数
Object::TOPLEVEL_BINDING が用意されています。... -
Binding
# local _ variable _ defined?(symbol) -> bool (29032.0) -
引数 symbol で指定した名前のローカル変数が定義されている場合に true を、 そうでない場合に false を返します。
...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#local_variable_get, Binding#local... -
Binding
# local _ variable _ get(symbol) -> object (29032.0) -
引数 symbol で指定した名前のローカル変数に設定された値を返します。
...][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) (29032.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.l......# => NameError
end
//}
このメソッドは以下のコード(ただし、obj が Ruby のコードで出力される場
合)と同様の動作をします。
//emlist[][ruby]{
binding.eval("#{symbol} = #{obj}")
//}
@see Binding#local_variable_get, Binding#local_variable_defined?... -
Binding
# eval(expr , fname = _ _ FILE _ _ , lineno = 1) -> object (29020.0) -
自身をコンテキストとし文字列 expr を Ruby プログラムとして評価しその結果を返します。 組み込み関数 Kernel.#eval を使って eval(expr, self, fname, lineno) とするのと同じです。
...の先頭行の行番号が 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... -
Binding
# local _ variables -> [Symbol] (29014.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
# irb -> object (29008.0) -
REPLのセッションを開始します。
...REPLのセッションを開始します。
2.5.0 からは require 'irb' せずに直接 binding.irb を呼び出しても使えるようになりました。
@see irb... -
Binding
# receiver -> object (29008.0) -
保持するコンテキスト内での self を返します。
...保持するコンテキスト内での self を返します。
このメソッドは以下のコードと同様の動作をします。
//emlist[][ruby]{
binding.eval("self")
//}... -
Binding
# source _ location -> [String , Integer] (29008.0) -
self の Ruby のソースファイル名と行番号を返します。
...self の Ruby のソースファイル名と行番号を返します。
d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。
//emlist[例][ruby]{
p binding.source_location # => ["test.rb", 1]
//}... -
Kernel
. # binding -> Binding (14232.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...