るりまサーチ

最速Rubyリファレンスマニュアル検索!
121件ヒット [1-100件を表示] (0.034秒)
トップページ > クエリ:kernel[x] > クエリ:caller_locations[x]

別のキーワード

  1. kernel caller
  2. _builtin caller
  3. _builtin caller_locations
  4. caller _builtin

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (27120.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...f test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def test2(start, length)
test1(start, length)
end

def test3(start, length)
test2(start, length)
end

caller_locations
# => []
test3(1, nil)
# => ["/Users...
...(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (27120.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...f test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def test2(start, length)
test1(start, length)
end

def test3(start, length)
test2(start, length)
end

caller_locations
# => []
test3(1, nil)
# => ["/Users...
...(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

Kernel.#caller(range) -> [String] | nil (9024.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
f...

Kernel.#caller(start = 1) -> [String] | nil (9024.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
f...

Kernel.#caller(start, length) -> [String] | nil (9024.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
f...

絞り込み条件を変える

NEWS for Ruby 2.0.0 (108.0)

NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...ts

* Kernel
* 追加: Kernel.#Hash という変換メソッド。Kernel.#Array, Kernel.#Float に似ています
* 追加: Kernel.#__dir__ 現在のソースファイル(__FILE__)のあるディレクトリ名を正規化された絶対パ スで返します。
* 追加: Kernel.#calle...
...r_locations フレーム情報の配列を返します
* 拡張: Kernel.#warn Kernel.#puts のように複数の引数を受け付けるようになりました
* 拡張: Kernel.#caller 第2引数で取得するスタックのサイズを指定できるようになりました
* 拡張:...
...加: Thread#backtrace_locations Kernel#caller_locations に似た情報を返します
* 新規クラス: Thread::Backtrace::Location to hold backtrace location
information. These are returned by Thread#backtrace_locations and
Kernel
#caller_locations
* 非互換: Thread#join, Thr...

Thread::Backtrace::Location (48.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...

Ruby用語集 (42.0)

Ruby用語集 A B C D E F G I J M N O R S Y

...る時点において、そこに至るメソッド呼び出し元情報を遡るデータ。
バックトレースともいう。

Kernel
.#caller_locationsKernel.#caller で現時点までの
スタックトレースを得ることができる。

また、例外オブジェクトは例...
...脱出
: non-local exit
Ruby においては、例外の発生もしくは Kernel.#throw によって
処理の実行が中断されること。
例外の場合は begin/rescue によって、throw の場合は
Kernel
.#catch によって捕捉されるまで、制御構造やメソッド...
...by、
Enumerable#max_by などのように、要素に対する「評価関数」
としてブロックを要求するメソッドもある。
Kernel
.#open メソッドは、ブロックを与えて呼び出した場合、
ファイルをオープンしてブロックを評価し、ファイ...

Thread::Backtrace::Location#to_s -> String (22.0)

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。

...self が表すフレームを 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...

Thread#backtrace_locations(range) -> [Thread::Backtrace::Location] | nil (12.0)

スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。

...の個数を指定します。

@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。

Kernel
.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。

//emlist[例][ruby]{
thread = Thread.new { slee...

絞り込み条件を変える

<< 1 2 > >>