るりまサーチ

最速Rubyリファレンスマニュアル検索!
731件ヒット [701-731件を表示] (0.093秒)
トップページ > クエリ:d[x] > クエリ:to_i[x]

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

モジュール

キーワード

検索結果

<< < ... 6 7 8 >>

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

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

...

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

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

d
ef bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<ma...
...す。

//emlist[例][ruby]{
d
ef parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

d
ef foo
p parse_caller(caller.first)
end

d
ef bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.firs...
...=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

d
ef debug(*args)
p [caller.first, *args] if $DEBUG
end

d
ebug "debug information"

#=> ["-:7", "debug information"]
//}...

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

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

...

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

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

d
ef bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<ma...
...す。

//emlist[例][ruby]{
d
ef parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

d
ef foo
p parse_caller(caller.first)
end

d
ef bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.firs...
...=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

d
ef debug(*args)
p [caller.first, *args] if $DEBUG
end

d
ebug "debug information"

#=> ["-:7", "debug information"]
//}...

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

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

...

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

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

d
ef bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<ma...
...す。

//emlist[例][ruby]{
d
ef parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

d
ef foo
p parse_caller(caller.first)
end

d
ef bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.firs...
...=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。

//emlist[例][ruby]{
$DEBUG = true

d
ef debug(*args)
p [caller.first, *args] if $DEBUG
end

d
ebug "debug information"

#=> ["-:7", "debug information"]
//}...
<< < ... 6 7 8 >>