種類
- インスタンスメソッド (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件
-
TracePoint
# binding -> Binding | nil (14232.0) -
発生したイベントによって生成された Binding オブジェクトを返します。
...発生したイベントによって生成された Binding オブジェクトを返します。
C で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。
//emlist[例][ruby]{
d......ef foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}... -
Object
:: TOPLEVEL _ BINDING -> Binding (14226.0) -
トップレベルでの Binding オブジェクト。
...トップレベルでの Binding オブジェクト。
詳細は Binding を参照してください。... -
Proc
# binding -> Binding (14226.0) -
Proc オブジェクトが保持するコンテキストを Binding オブジェクトで返します。
...Proc オブジェクトが保持するコンテキストを
Binding オブジェクトで返します。
//emlist[例][ruby]{
def fred(param)
proc {}
end
sample_proc = fred(99)
eval("param", sample_proc.binding) # => 99
//}... -
TracePoint
# binding -> Binding (14226.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
//}... -
Kernel
. # set _ trace _ func(proc) -> Proc (8074.0) -
Ruby インタプリタのイベントをトレースする Proc オブジェクトとして 指定された proc を登録します。 nil を指定するとトレースがオフになります。
...。
=== ブロックパラメータの意味
渡す Proc オブジェクトのパラメータは
//emlist[][ruby]{
proc{|event, file, line, id, binding, klass| "..." }
//}
で、意味は以下の通りです。
: event
実行のタイプを表す、以下のいずれかの文字列。
//emlist{......び出されたメソッドを表す Symbol オブジェクト。
トップレベルでは nil。
//}
: binding
実行中のプログラムのコンテキストを表す Binding オブジェクト。
: klass
event に応じ、以下のものが渡されます。
第四ブロック引数......, #<Binding:0xf6ceb8>, Kernel]
# ["line", "..", 4, nil, #<Binding:0x10cbcd8>, nil]
# ["c-call", "..", 4, :inherited, #<Binding:0x10cba98>, Class]
# ["c-return", "..", 4, :inherited, #<Binding:0x10cb858>, Class]
# ["class", "..", 4, nil, #<Binding:0x10cb600>, nil]
# ["end", "..", 5, nil, #<Binding:0x... -
Thread
# set _ trace _ func(pr) -> Proc | nil (8074.0) -
スレッドにトレース用ハンドラを設定します。
..., "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Binding:0x00007fc8de886770>, Class]
# => ["c-return", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]......["end", "example.rb", 3, nil, #<Binding:0x00007fc8de88d6b0>, nil]
# => ["line", "example.rb", 4, nil, #<Binding:0x00007fc8de88c440>, nil]
# => ["c-call", "example.rb", 4, :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]......ample.rb", 5, nil, #<Binding:0x00007fc8de967b08>, nil]
# => ["c-call", "example.rb", 5, :current, #<Binding:0x00007fc8de967798>, Thread]
# => ["c-return", "example.rb", 5, :current, #<Binding:0x00007fc8de9673b0>, Thread]
# => ["c-call", "example.rb", 5, :set_trace_func, #<Binding:0x00007fc8de966fc8>... -
Thread
# add _ trace _ func(pr) -> Proc (8050.0) -
スレッドにトレース用ハンドラを追加します。
..., "example.rb", 4, nil, #<Binding:0x00007f98e107d0d8>, nil]
# => ["c-call", "example.rb", 4, :inherited, #<Binding:0x00007f98e1087448>, Class]
# => ["c-return", "example.rb", 4, :inherited, #<Binding:0x00007f98e1085d00>, Class]
# => ["class", "example.rb", 4, nil, #<Binding:0x00007f98e108f210>, nil]......["end", "example.rb", 5, nil, #<Binding:0x00007f98e108e5e0>, nil]
# => ["line", "example.rb", 6, nil, #<Binding:0x00007f98e108d4b0>, nil]
# => ["c-call", "example.rb", 6, :to_s, #<Binding:0x00007f98e1097aa0>, Integer]
# => ["c-return", "example.rb", 6, :to_s, #<Binding:0x00007f98e1095cc8>, Integer]... -
Kernel
. # eval(expr) -> object (8030.0) -
文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。
...文字列 expr を Ruby プログラムとして評価してその結果を返しま
す。第2引数に
Binding オブジェクトを与えた場合、
そのオブジェクトを生成したコンテキストで文字列を評価します。
expr の中のローカル変数の扱いはブロッ......val('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#method,Object#send... -
Kernel
. # eval(expr , bind , fname = "(eval)" , lineno = 1) -> object (8030.0) -
文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。
...文字列 expr を Ruby プログラムとして評価してその結果を返しま
す。第2引数に
Binding オブジェクトを与えた場合、
そのオブジェクトを生成したコンテキストで文字列を評価します。
expr の中のローカル変数の扱いはブロッ......val('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#method,Object#send... -
TracePoint
# self -> object (8020.0) -
イベントを発生させたオブジェクトを返します。
...イベントを発生させたオブジェクトを返します。
以下のようにする事で同じ値を取得できます。
//emlist[例][ruby]{
trace.binding.eval('self')
//}
@see TracePoint#binding......返します。
以下のようにする事で同じ値を取得できます。
なお、self メソッドは binding が nil になる :c_call および :c_return イベントに対しても正しく動作します。
//emlist[例][ruby]{
trace.binding.eval('self')
//}
@see TracePoint#binding... -
ObjectSpace
. # define _ finalizer(obj) {|id| . . . } -> Array (8008.0) -
obj が解放されるときに実行されるファイナライザ proc を 登録します。同じオブジェクトについて複数回呼ばれたときは置き換えで はなく追加登録されます。固定値 0 と proc を配列にして返します。
...いでしょう。
//emlist[例][ruby]{
class Baz
def initialize
ObjectSpace.define_finalizer self, eval(%q{
proc {
raise "baz" rescue puts $!
raise "baz2"
puts "baz3"
}
}, TOPLEVEL_BINDING)
end
end
Baz.new
GC.start
# => baz
//}
@see spec/rubycmd...