22件ヒット
[1-22件を表示]
(0.343秒)
種類
- クラス (11)
- インスタンスメソッド (11)
クラス
検索結果
-
Thread
:: Backtrace :: Location # to _ s -> String (18131.0) -
self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。
...すフレームを Kernel.#caller と同じ表現にした文字列を返し
ます。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.to_s
end
# => path/t... -
Thread
:: Backtrace :: Location (62.0) -
Ruby のフレームを表すクラスです。
...です。
Kernel.#caller_locations から生成されます。
//emlist[例1][ruby]{
# caller_locations.rb
def a(skip)
caller_locations(skip)
end
def b(skip)
a(skip)
end
def c(skip)
b(skip)
end
c(0..2).map do |call|
puts call.to_s
end
//}
例1の実行結果:
caller_locations.rb:2:in......`a'
caller_locations.rb:5:in `b'
caller_locations.rb:8:in `c'
//emlist[例2][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.to_s
end
//}
例2の実行結果:
ini...