るりまサーチ

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

別のキーワード

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

検索結果

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (6325.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。

@param start 開始フレームの位置を数値で指定します。

@param length 取得するフレームの個数を指定します。

@pa...
...uby]{
def test1(start, length)
location
s = 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)
# =>...
...(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (6325.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。

@param start 開始フレームの位置を数値で指定します。

@param length 取得するフレームの個数を指定します。

@pa...
...uby]{
def test1(start, length)
location
s = 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)
# =>...
...(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

ObjectSpace.#allocation_sourcefile(object) -> String (6201.0)

objectの元となったソースファイル名を返します。

...uire 'objspace'

ObjectSpace::trace_object_allocations_start
obj = Object.new
puts "file:#{ObjectSpace::allocation_sourcefile(obj)}" # => file:test.rb
ObjectSpace::trace_object_allocations_stop
//}

@see ObjectSpace.#trace_object_allocations_start,
ObjectSpace.#trace_object_allocations_stop...

ObjectSpace.#allocation_sourceline(object) -> Integer (6201.0)

objectの元となったソースファイルの行番号を返します。

...y]{
require 'objspace'

ObjectSpace::trace_object_allocations_start
obj = Object.new
puts "line:#{ObjectSpace::allocation_sourceline(obj)}" # => line:4
ObjectSpace::trace_object_allocations_stop
//}

@see ObjectSpace.#trace_object_allocations_start,
ObjectSpace.#trace_object_allocations_stop...

ObjectSpace.#trace_object_allocations_start -> nil (6201.0)

オブジェクト割り当てのトレースを開始します。

...オブジェクト割り当てのトレースを開始します。

@see ObjectSpace.#trace_object_allocations_stop...

絞り込み条件を変える

ObjectSpace.#trace_object_allocations_stop -> nil (6201.0)

オブジェクト割り当てのトレースを終了します。

...オブジェクト割り当てのトレースを終了します。

トレースを終了する為には、ObjectSpace.#trace_object_allocations_startを呼んだ回数分だけこのメソッドを呼ぶ必要があります。

@see ObjectSpace.#trace_object_allocations_start...