るりまサーチ

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

別のキーワード

  1. kernel $-l
  2. matrix l
  3. _builtin $-l
  4. lupdecomposition l
  5. l

検索結果

<< 1 2 > >>

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

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

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

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

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

@pa...
...

//emlist[例][ruby]{
def test1(start, length)
l
ocations = 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)
# => ["/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/test.rb:9:in `test2'", "/Users/user/test.rb:1...

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

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

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

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

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

@pa...
...

//emlist[例][ruby]{
def test1(start, length)
l
ocations = 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)
# => ["/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/test.rb:9:in `test2'", "/Users/user/test.rb:1...

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

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

...ない場合はnilを返します。

//emlist[例:test.rbというファイルで下記のスクリプトを実行した場合][ruby]{
require 'objspace'

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

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

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

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

...場合はnilを返します。

//emlist[例][ruby]{
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 { ... } (12201.0)

与えられたブロック内でオブジェクトのトレースを行います。 

...ジェクトのトレースを行います。 

//emlist[例][ruby]{
require 'objspace'

class C
include ObjectSpace

def foo
trace_object_allocations do
obj = Object.new
p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}"
end
end
end

C.new.foo #=> "objtrace....

絞り込み条件を変える

ObjectSpace.#trace_object_allocations_start -> nil (12201.0)

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

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

@see ObjectSpace.#trace_object_allocations_stop...

ObjectSpace.#trace_object_allocations_stop -> nil (12201.0)

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

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

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

@see ObjectSpace.#trace_object_allocations_start...

Kernel.#catch {|tag| .... } -> object (9101.0)

Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

...Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

ブロックの実行中に tag と同一のオブジェクトを引数とする Kernel.#throw が行われた
場合は、その throw の第二引数を戻り値として、ブロック...
...@return ブロックの返り値か、対応するthrowの第二引数を返り値として返します。

//emlist[例][ruby]{
result = catch do |tag|
for i in 1..2
for j in 1..2
for k in 1..2
throw tag, k
end
end
end
end

p result #=> 1
//}

@see Kernel.#throw...

Kernel.#catch(tag) {|tag| .... } -> object (9101.0)

Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

...Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

ブロックの実行中に tag と同一のオブジェクトを引数とする Kernel.#throw が行われた
場合は、その throw の第二引数を戻り値として、ブロック...
...@return ブロックの返り値か、対応するthrowの第二引数を返り値として返します。

//emlist[例][ruby]{
result = catch do |tag|
for i in 1..2
for j in 1..2
for k in 1..2
throw tag, k
end
end
end
end

p result #=> 1
//}

@see Kernel.#throw...

Open3.#pipeline_rw(*cmds) -> [IO, IO, [Thread]] (6113.0)

指定したコマンドのリストをパイプで繋いで順番に実行します。最初の コマンドの標準入力に書き込む事も最後のコマンドの標準出力を受けとる事も できます。

...リストを指定します。それぞれのコマンドは
以下のように String か Array で指定します。
commandline にはコマンド全体(例. "nroff -man")を表す
String を指定します。
options には Hash で指定します...
...cmdname にはコマンド名を表す String を指定します。
1、2、3 は shell 経由で実行されます。

(1) commandline
(2) [commandline, options]
(3) [env, commandline, options]
(4) [env, cmdname, arg1, arg2, ..., options]
(5) [env, [cmdname, argv0], arg1, ...,...
...Open3.pipeline_rw("sort", "cat -n") {|stdin, stdout, wait_thrs|
stdin.puts "foo"
stdin.puts "bar"
stdin.puts "baz"

# sortコマンドにEOFを送る。
stdin.close

# stdinに渡した文字列をsortコマンドが並べ替えたものに、catコマンド...

絞り込み条件を変える

<< 1 2 > >>