るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. t61string new
  4. matrix t
  5. fiddle align_size_t

ライブラリ

クラス

検索結果

<< 1 2 > >>

TracePoint#binding -> Binding | nil (21237.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...れた Binding オブジェクトを返します。

C で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。

//emlist[例][ruby]{
def foo(ret)
ret
end
t
race = TracePoint.new(:...
...call) do |tp|
p tp.binding.local_variables # => [:ret]
end
t
race.enable
foo 1
//}...

TracePoint#binding -> Binding (21231.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...発生したイベントによって生成された Binding オブジェクトを返します。


//emlist[例][ruby]{
def foo(ret)
ret
end
t
race = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
t
race.enable
foo 1
//}...

Binding#local_variable_set(symbol, obj) (15149.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#local_variable_get(symbol) -> object (15143.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#source_location -> [String, Integer] (15129.0)

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

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

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

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

絞り込み条件を変える

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

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

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

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

@param...
...の先頭行の行番号が 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#receiver -> object (9113.0)

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

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

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

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

ERB#result(b=TOPLEVEL_BINDING) -> String (6230.0)

ERB を b の binding で実行し、結果の文字列を返します。

...B を b の binding で実行し、結果の文字列を返します。

@param b eRubyスクリプトが実行されるときのbinding

//emlist[例][ruby]{
require 'erb'
erb = ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
t
est1 = "foo"
t
est2 = "bar"
puts erb.result
# test foo
# test bar
//}...
...@see ERB#result_with_hash...

Thread#backtrace -> [String] | nil (6213.0)

スレッドの現在のバックトレースを返します。

...ist[例][ruby]{
class C1
def m1
sleep 5
end
def m2
m1
end
end

t
h = Thread.new {C1.new.m2; Thread.stop}
t
h.backtrace
# => [
# [0] "(irb):3:in `sleep'",
# [1] "(irb):3:in `m1'",
# [2] "(irb):6:in `m2'",
# [3] "(irb):10:in `block in irb_binding'"
# ]

t
h.kill
t
h....
...backtrace # => nil
//}...

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

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

...//emlist[例][ruby]{
t
h = Thread.new do
class Trace
end
2.to_s
T
hread.current.set_trace_func nil
3.to_s
end
t
h.set_trace_func lambda {|*arg| p arg }
t
h.join

# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Binding:0x000...
...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:0x00007fc8de88c44...
..., :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x00007fc8de967b08>, nil]
# => ["c-call", "example.rb", 5, :current, #<Binding:0x00007fc8de967798>, Thread]
# => ["c-return...

絞り込み条件を変える

<< 1 2 > >>