別のキーワード
種類
- インスタンスメソッド (77)
- モジュール関数 (55)
- 文書 (22)
ライブラリ
- ビルトイン (132)
クラス
- Thread (22)
-
Thread
:: Backtrace :: Location (55)
モジュール
- Kernel (55)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) - Ruby用語集 (11)
-
absolute
_ path (11) -
backtrace
_ locations (22) -
base
_ label (11) - caller (33)
- inspect (11)
- path (11)
-
to
_ s (11)
検索結果
先頭5件
-
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (18214.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... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (18214.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... -
Ruby用語集 (132.0)
-
Ruby用語集 A B C D E F G I J M N O R S Y
...l#percent
: 0 オリジン
: zero-based
番号が 0 から始まること。
例えば、
Array や Vector、Matrix などの要素の番号、
String における文字の位置、
といったものは 0 オリジンである。
: 1 オリジン
: one-based
番号が 1 から始ま......ログラミング言語。
型推論を持った静的型付け言語であり、処理系はコンパイラーである。
https://ja.crystal-lang.org/
: CSI 方式
CSI は Code Set Independent の頭字語。
プログラミング言語の処理系が文字列を扱う際のエンコー......時点において、そこに至るメソッド呼び出し元情報を遡るデータ。
バックトレースともいう。
Kernel.#caller_locations、Kernel.#caller で現時点までの
スタックトレースを得ることができる。
また、例外オブジェクトは例外... -
NEWS for Ruby 2
. 0 . 0 (120.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...は参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 1.9.3 以降の変更
=== 言語仕様の変更
* キーワード引数を追加しました......ルの配列作成のために追加しました。(%w, %W に似ています)
* デフォルトのソースエンコーディングを US-ASCII から UTF-8 に変更しました
* '_' で始まる使用されていない変数は警告しなくなりました
=== 組み込みクラスの更......在のソースファイル(__FILE__)のあるディレクトリ名を正規化された絶対パ スで返します。
* 追加: Kernel.#caller_locations フレーム情報の配列を返します
* 拡張: Kernel.#warn Kernel.#puts のように複数の引数を受け付けるようにな... -
Kernel
. # caller(range) -> [String] | nil (106.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...el.#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
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# [......ler.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug inform... -
Kernel
. # caller(start = 1) -> [String] | nil (106.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...el.#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
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# [......ler.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug inform... -
Kernel
. # caller(start , length) -> [String] | nil (106.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...el.#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
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# [......ler.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug inform... -
Thread
# backtrace _ locations(range) -> [Thread :: Backtrace :: Location] | nil (106.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...数を指定します。
@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。
Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }... -
Thread
# backtrace _ locations(start = 0 , length = nil) -> [Thread :: Backtrace :: Location] | nil (106.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...数を指定します。
@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。
Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }... -
Thread
:: Backtrace :: Location # absolute _ path -> String (106.0) -
self が表すフレームの絶対パスを返します。
...の絶対パスを返します。
//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.absolute_path
end
# => /path/to/foo.rb
# /path/to/foo.rb
# /path/to/foo.r...