るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. _builtin p
  5. kernel p

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

TracePoint#binding -> Binding | nil (21237.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 (21231.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
//}...

Proc#binding -> Binding (21225.0)

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

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

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

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

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

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

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

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

@param fname ファイル名...
...expr が fname というファイル名にあるかのように実行されます。

@param lineno 行番号を整数で与えます。式 expr の先頭行の行番号が lineno であるかのように実行されます。

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

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

@see Kernel.#eval...

Binding#local_variable_set(symbol, obj) (9055.0)

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

...を設定します。

@param symbol ローカル変数名を Symbol オブジェクトで指定します。

@param obj 引数 symbol で指定したローカル変数に設定するオブジェクトを指定します。

//emlist[例][ruby]{
def foo
a = 1
bind = binding
bind.local_variable_...
...create new local variable `b'
# `b' exists only in binding
p
bind.local_variable_get(:a) # => 2
p
bind.local_variable_get(:b) # => 3
p
a # => 2
p
b # => NameError
end
//}

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

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

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

絞り込み条件を変える

Binding#source_location -> [String, Integer] (9013.0)

self の Ruby のソースファイル名と行番号を返します。

...self の Ruby のソースファイル名と行番号を返します。

d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。

//emlist[例][ruby]{
p
binding.source_location # => ["test.rb", 1]
//}...

IRB::Frame#top(n = 0) -> Binding (6202.0)

上から n 番目のコンテキストを取り出します。

...上から n 番目のコンテキストを取り出します。

@param n 取り出すコンテキストを Integer で指定します。n は 0 が最
上位になります。...

Kernel#xmp(exps, bind = nil) -> XMP (6119.0)

引数 exps で指定されたRuby のソースコードとその実行結果を、標準出力に行 ごとに交互に表示します。

...引数 exps で指定されたRuby のソースコードとその実行結果を、標準出力に行
ごとに交互に表示します。

@param exps 評価するRuby のソースコードを文字列で指定します。

@param bind Binding オブジェクトを指定します。省略した場...
...合は、最
後に実行した XMP#puts、Kernel#xmp
Binding
を使用します。まだ何も実行していない場合は
Object::TOPLEVEL_BINDING を使用します。...

Thread#report_on_exception -> bool (6107.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception #...
...rb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thr...
...ead:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...

Thread#report_on_exception=(newstate) (6107.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception #...
...rb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thr...
...ead:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...

絞り込み条件を変える

TracePoint#self -> object (3019.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...

Thread#set_trace_func(pr) -> Proc | nil (279.0)

スレッドにトレース用ハンドラを設定します。

...bda {|*arg| p arg }
th.join

# => ["line", "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,...
...il]
# => ["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>,...
...ine", "example.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:0x00007fc8...
<< 1 2 > >>