るりまサーチ

最速Rubyリファレンスマニュアル検索!
33件ヒット [1-33件を表示] (0.042秒)
トップページ > クエリ:-[x] > クエリ:$1[x] > 種類:モジュール関数[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

モジュール

検索結果

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

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

...aller(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>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名,...
...+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

def foo
p parse_caller(caller.first)
end

def bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.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 information"]
//}...

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

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

...aller(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>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名,...
...+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

def foo
p parse_caller(caller.first)
end

def bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.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 information"]
//}...

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

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

...aller(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>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル名,...
...+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end

def foo
p parse_caller(caller.first)
end

def bar
foo
p parse_caller(caller.first)
end

bar
p parse_caller(caller.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 information"]
//}...