ライブラリ
- ビルトイン (297)
- fiddle (33)
-
minitest
/ unit (1)
クラス
-
Fiddle
:: Closure :: BlockCaller (22) - SystemCallError (55)
- Thread (22)
-
Thread
:: Backtrace :: Location (55)
モジュール
- Kernel (143)
-
MiniTest
:: Assertions (1)
キーワード
-
$ @ (11) - === (11)
- BlockCaller (11)
- Location (11)
- Ruby用語集 (11)
- SystemCallError (11)
-
absolute
_ path (11) -
backtrace
_ locations (22) -
base
_ label (11) - call (11)
-
caller
_ locations (22) - errno (11)
- fail (33)
- inspect (11)
- new (44)
- path (11)
- raise (33)
-
rb
_ f _ caller (11) -
set
_ trace _ func (11) - skip (1)
-
to
_ s (11) - 制御構造 (11)
検索結果
先頭5件
-
Kernel
. # caller(range) -> [String] | nil (24299.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ます。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得......囲を示す 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
#=> ["-:2:in `foo'", "-:10:in `bar'",......[]
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]... -
Kernel
. # caller(start = 1) -> [String] | nil (24299.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ます。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得......囲を示す 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
#=> ["-:2:in `foo'", "-:10:in `bar'",......[]
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]... -
Kernel
. # caller(start , length) -> [String] | nil (24299.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ます。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得......囲を示す 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
#=> ["-:2:in `foo'", "-:10:in `bar'",......[]
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]... -
Fiddle
:: Closure :: BlockCaller (15000.0) -
Ruby のブロックをラップしたコールバック関数を表すクラスです。
...。
require 'fiddle'
include Fiddle
libc = Fiddle.dlopen("/lib/libc.so.6")
qs = Fiddle::Function.new(libc["qsort"],
[TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP],
TYPE_VOID)
compare = Fiddle::Closure::BlockCaller.new(TYPE_INT, [TYPE_......# このブロックには DL::CPtr オブジェクトが渡される。
# そのポインタが指す先は比較している文字なので、
# DL::CPtr#to_s で1文字の文字列に変換している
x.to_s(1) <=> y.to_s(1)
}
s = "7x0cba(Uq)"
qs.call(s, s.size, 1, compare)
p... -
static VALUE rb
_ f _ caller(int argc , VALUE *argv) (12300.0) -
-
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (12220.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@pa......す。
//emlist[例][ruby]{
def 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/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.r... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (12220.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@pa......す。
//emlist[例][ruby]{
def 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/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.r... -
Fiddle
:: Closure :: BlockCaller # call(*args) -> object (12100.0) -
wrap しているブロックを呼び出します。
wrap しているブロックを呼び出します。
そのブロックの返り値がこのメソッドの返り値となります。
@param args 引数 -
SystemCallError (12000.0)
-
Ruby の実装に用いられているシステムコールまたは一部の C 言語関数が失敗した時に発生する例外です。 システムコールの失敗した原因を表すエラーコードを保持します。
...例外です。
システムコールの失敗した原因を表すエラーコードを保持します。
多くの場合、実際には SystemCallError そのものではなく
サブクラスである Errno::EXXX (XXX はエラーコードの値によって異なる。
システム定義のエ... -
Fiddle
:: Closure :: BlockCaller . new(ret , args , abi=Fiddle :: Function :: DEFAULT) { . . . } -> Fiddle :: Closure :: BlockCaller (9400.0) -
Ruby のブロックを呼び出す Fiddle::Closure オブジェクトを返します。
...Ruby のブロックを呼び出す Fiddle::Closure オブジェクトを返します。
args、ret で関数の引数と返り値の型を指定します。
指定は Fiddle::Function.new と同様なので、そちら
を参照してください。
@param ret 返り値の型
@param args 引数...