種類
- インスタンスメソッド (165)
- モジュール関数 (66)
- 文書 (29)
ライブラリ
- ビルトイン (186)
-
minitest
/ unit (1) - objspace (44)
クラス
- Binding (6)
- Exception (11)
- Method (21)
-
MiniTest
:: Unit (1) - Module (5)
- Proc (11)
- Thread (22)
-
Thread
:: Backtrace :: Location (77) - UnboundMethod (11)
モジュール
- Kernel (22)
- ObjectSpace (44)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
absolute
_ path (11) -
allocation
_ sourcefile (11) -
allocation
_ sourceline (11) -
backtrace
_ locations (33) -
base
_ label (11) -
caller
_ locations (22) -
const
_ source _ location (5) - inspect (16)
- label (11)
- lineno (11)
- path (11)
-
source
_ location (39) -
to
_ s (16) -
trace
_ object _ allocations _ start (11) -
trace
_ object _ allocations _ stop (11)
検索結果
先頭5件
- MiniTest
:: Unit # location(exception) -> String - Thread
# backtrace _ locations(range) -> [Thread :: Backtrace :: Location] | nil - Thread
# backtrace _ locations(start = 0 , length = nil) -> [Thread :: Backtrace :: Location] | nil - Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] - Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil
-
MiniTest
:: Unit # location(exception) -> String (27401.0) -
与えられた例外の発生した場所を返します。
与えられた例外の発生した場所を返します。 -
Thread
# backtrace _ locations(range) -> [Thread :: Backtrace :: Location] | nil (18724.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...トレースを Thread::Backtrace::Location の配
列で返します。
引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフ......@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。
Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrac......e_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}
@see Thread::Backtrace::Location... -
Thread
# backtrace _ locations(start = 0 , length = nil) -> [Thread :: Backtrace :: Location] | nil (18624.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...トレースを Thread::Backtrace::Location の配
列で返します。
引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフ......@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。
Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrac......e_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}
@see Thread::Backtrace::Location... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (18623.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...on#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if Date.n......0, month, -1).day == 31
raise "#{month} is not long month"
end
def get_exception
return begin
yield
rescue => e
e
end
end
e = get_exception { check_long_month(2) }
p e.backtrace_locations
# => ["test.rb:4:in `check_long_month'", "test.rb:15:in `block in <main>'", "test.rb:9:in `get......_exception'", "test.rb:15:in `<main>'"]
//}
@see Exception#backtrace... -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (18524.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...ムを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@param range 取得......示す Range オブジェクトを指定します。
//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)
t......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/t... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (18524.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...ムを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@param range 取得......示す Range オブジェクトを指定します。
//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)
t......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/t... -
Module
# const _ source _ location(name , inherited = true) -> [String , Integer] (18467.0) -
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
...
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義され......][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end
module M # line 6
C3 = 3
end
class B < A # line 10
include M
C4 = 4
end
class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end
p B.const_source_location('C4') # => ["test.rb",......p B.const_source_location('C3') # => ["test.rb", 7]
p B.const_source_location('C1') # => ["test.rb", 2]
p B.const_source_location('C3', false) # => nil -- include したモジュールは検索しない
p A.const_source_location('C2') # => ["test.rb", 16] -- 最... -
Proc
# source _ location -> [String , Integer] | nil (18431.0) -
ソースコードのファイル名と行番号を配列で返します。
... ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
//emlist[例][ruby]{
# /path/to/target.rb を実行
proc {}.source_location # => ["/path/to/target.rb", 1]
proc {}.source_location # => ["/path/to/target.rb", 2]
(eval "proc......{}").source_location # => ["(eval)", 1]
method(:p).to_proc.source_location # => nil
//}
@see Method#source_location... -
UnboundMethod
# source _ location -> [String , Integer] | nil (18425.0) -
ソースコードのファイル名と行番号を配列で返します。
...が ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
//emlist[例][ruby]{
require 'time'
Time.instance_method(:zone).source_location # => nil
Time.instance_method(:httpdate).source_location # => ["/Users/user/.rbenv/versions/2.4.3/lib/rub......y/2.4.0/time.rb", 654]
//}
@see Proc#source_location, Method#source_location... -
Method
# source _ location -> [String , Integer] | nil (18419.0) -
ソースコードのファイル名と行番号を配列で返します。
...ェクトが ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
@see Proc#source_location
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----
require '/tmp/foo'
m = Foo.new.method(:foo......) # => #<Method: Foo#foo>
m.source_location # => ["/tmp/foo.rb", 2]
method(:puts).source_location # => nil
//}... -
Binding
# source _ location -> [String , Integer] (18407.0) -
self の Ruby のソースファイル名と行番号を返します。
...self の Ruby のソースファイル名と行番号を返します。
d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。
//emlist[例][ruby]{
p binding.source_location # => ["test.rb", 1]
//}...