るりまサーチ (Ruby 2.5.0)

最速Rubyリファレンスマニュアル検索!
10件ヒット [1-10件を表示] (0.061秒)

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub

モジュール

キーワード

検索結果

Exception#backtrace -> [String] (54667.0)

バックトレース情報を返します。

バックトレース情報を返します。

デフォルトでは

* "#{sourcefile}:#{sourceline}:in `#{method}'"
(メソッド内の場合)
* "#{sourcefile}:#{sourceline}"
(トップレベルの場合)

という形式の String の配列です。

//emlist[例][ruby]{
def methd
raise
end

begin
methd
rescue => e
p e.backtrace
end

#=> ["filename.rb:2:in `methd'", "filename.rb:6...

Thread#backtrace -> [String] | nil (54649.0)

スレッドの現在のバックトレースを返します。

スレッドの現在のバックトレースを返します。

スレッドがすでに終了している場合は nil を返します。

//emlist[例][ruby]{
class C1
def m1
sleep 5
end
def m2
m1
end
end

th = Thread.new {C1.new.m2; Thread.stop}
th.backtrace
# => [
# [0] "(irb):3:in `sleep'",
# [1] "(irb):3:in `m1'",
# [2] "(irb):6:in `m2'",
# [3] ...

Exception#set_backtrace(errinfo) -> nil | String | [String] (19006.0)

バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。

バックトレース情報に errinfo を設定し、設定されたバックトレース
情報を返します。

@param errinfo nil、String あるいは String の配列のいずれかを指定します。

//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
end
rescue
$!.backtrace # => ["/path/to/test.rb:5:in `rescue in <main>'", "/path/to/test.rb:2:in `<main>'"]
$!.se...

Thread::Backtrace::Location#base_label -> String (9376.0)

self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。

self が表すフレームの基本ラベルを返します。通常、
Thread::Backtrace::Location#label から修飾を取り除いたもので構成
されます。

//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.base_label
end

# => init...

Thread::Backtrace::Location#inspect -> String (9358.0)

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文 字列に変換したオブジェクトを返します。

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文
字列に変換したオブジェクトを返します。

//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.inspect
end

# => "path/to/foo.rb:5:in ...

絞り込み条件を変える

Thread::Backtrace::Location#label -> String (9346.0)

self が表すフレームのラベルを返します。通常、メソッド名、クラス名、モ ジュール名などで構成されます。

self が表すフレームのラベルを返します。通常、メソッド名、クラス名、モ
ジュール名などで構成されます。

例: Thread::Backtrace::Location の例1を用いた例

//emlist[][ruby]{
loc = c(0..1).first
loc.label # => "a"
//}

@see Thread::Backtrace::Location#base_label

Thread::Backtrace::Location#path -> String (9346.0)

self が表すフレームのファイル名を返します。

self が表すフレームのファイル名を返します。

例: Thread::Backtrace::Location の例1を用いた例

//emlist[][ruby]{
loc = c(0..1).first
loc.path # => "caller_locations.rb"
//}

@see Thread::Backtrace::Location#absolute_path

Thread::Backtrace::Location#absolute_path -> String (9328.0)

self が表すフレームの絶対パスを返します。

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.rb
//}

@see...

Thread::Backtrace::Location#to_s -> String (9310.0)

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し
ます。

//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.to_s
end

# => path/to/foo.rb:5:in `initialize'
# path/to/foo...

Kernel$$@ -> [String] | nil (346.0)

最後に例外が発生した時のバックトレースを表す配列です。 Kernel.#raise によって設定されます。

最後に例外が発生した時のバックトレースを表す配列です。
Kernel.#raise によって設定されます。

配列の各要素はメソッドの呼び出し位置を示す文字列で形式は

"filename:line"

または

"filename:line:in `methodname'"

です。これは Kernel.#caller が返す値と同じ形式です。

$@ へ値を代入するときは、$! が nil であってはいけません。
$@ の値は、$!.backtrace の値と同じです。
また、$@ への代入は $!.set_backtrace 呼び出しと同じです。

文字列の配列でも nil で...

絞り込み条件を変える