213件ヒット
[1-100件を表示]
(0.181秒)
クラス
- Binding (63)
- ERB (24)
-
IRB
:: Frame (36) - Thread (54)
- TracePoint (24)
- Tracer (12)
キーワード
-
add
_ trace _ func (12) - backtrace (12)
- bottom (12)
- eval (12)
- irb (9)
-
local
_ variable _ get (12) -
local
_ variable _ set (12) - receiver (11)
-
report
_ on _ exception (9) -
report
_ on _ exception= (9) - result (12)
- run (12)
- self (12)
-
set
_ trace _ func (12) -
source
_ location (7) - top (12)
-
trace
_ func (24)
検索結果
先頭5件
-
TracePoint
# binding -> Binding | nil (21231.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
//}... -
TracePoint
# binding -> Binding (21225.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
//}... -
Binding
# local _ variable _ get(symbol) -> object (15131.0) -
引数 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_variab... -
Binding
# local _ variable _ set(symbol , obj) (15131.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......l_variable_get(:b) # => 3
p a # => 2
p b # => NameError
end
//}
このメソッドは以下のコード(ただし、obj が Ruby のコードで出力される場
合)と同様の動作をします。
//emlist[][ruby]{
binding.eval("#{symb......ol} = #{obj}")
//}
@see Binding#local_variable_get, Binding#local_variable_defined?... -
Binding
# source _ location -> [String , Integer] (15107.0) -
self の Ruby のソースファイル名と行番号を返します。
...self の Ruby のソースファイル名と行番号を返します。
d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。
//emlist[例][ruby]{
p binding.source_location # => ["test.rb", 1]
//}... -
Tracer
# trace _ func(event , file , line , id , binding , klass , *) -> object | nil (9202.0) -
@todo
...@todo... -
Binding
# eval(expr , fname = _ _ FILE _ _ , lineno = 1) -> object (9119.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
# irb -> object (9107.0) -
REPLのセッションを開始します。
...REPLのセッションを開始します。
2.5.0 からは require 'irb' せずに直接 binding.irb を呼び出しても使えるようになりました。
@see irb... -
Binding
# receiver -> object (9107.0) -
保持するコンテキスト内での self を返します。
...保持するコンテキスト内での self を返します。
このメソッドは以下のコードと同様の動作をします。
//emlist[][ruby]{
binding.eval("self")
//}... -
IRB
:: Frame # trace _ func(event , file , line , id , binding) -> Binding (6303.0) -
ライブラリ内部で使用します。
ライブラリ内部で使用します。 -
ERB
# result(b=TOPLEVEL _ BINDING) -> String (6224.0) -
ERB を b の binding で実行し、結果の文字列を返します。
...B を b の binding で実行し、結果の文字列を返します。
@param b eRubyスクリプトが実行されるときのbinding
//emlist[例][ruby]{
require 'erb'
erb = ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
test1 = "foo"
test2 = "bar"
puts erb.result
# test foo
# test bar
//}......@see ERB#result_with_hash...