108件ヒット
[101-108件を表示]
(0.043秒)
別のキーワード
モジュール
- FileTest (24)
- Kernel (48)
-
OpenSSL
:: ASN1 (24) - Process (12)
キーワード
- caller (36)
-
set
_ trace _ func (12) - setgid? (12)
- setproctitle (12)
- setuid? (12)
検索結果
-
Kernel
. # caller(start , length) -> [String] | nil (43.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ange 取得したいスタックの範囲を示す 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
foo
end
bar......nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end......=> ["-", 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 information"]
//}...