るりまサーチ

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

別のキーワード

  1. open3 popen2e
  2. socket af_e164
  3. matrix det_e
  4. open3 capture2e
  5. matrix rank_e

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 > >>

DRb.#thread -> Thread|nil (24403.0)

プライマリサーバが動作しているスレッドを返します。

...プライマリサーバが動作しているスレッドを返します。

プライマリサーバが存在しない場合は nil を返します。

@see DRb.#primary_server...

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (9225.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)
e
nd

def test2(start, length)
test1(start, length)
e
nd

def test3(start, length)
test2(s...
...t, length)
e
nd

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....

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (9225.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)
e
nd

def test2(start, length)
test1(start, length)
e
nd

def test3(start, length)
test2(s...
...t, length)
e
nd

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....

Open3.#popen3(*cmd) -> [IO, IO, IO, Thread] (9220.0)

外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。

...を待つためのスレッドを 4 要素の
配列で返します。

require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")

@param cmd 実行するコマンドを指定します。

@return ブロックを指定した場合はブロックの最後に評価さ...
...se します。この場合はブロックの最後の式の結果を返します。

require 'open3'

Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close # または close_write
p stdout.read
p stderr.rea...
...\n"
"stderr\n"


stdin への入力が終わったらできる限り早く close か close_write
で閉じるべきです。

[UNIX系OS固有の注意] Open3 で作成した子プロセスは
wait(2) しなくてもゾンビになりません。

引数 cmd はそのまま Kernel.#spawn に...

Open3.#popen2e(*cmd) -> [IO, IO, Thread] (9204.0)

cmdで指定されたコマンドを実行し、そのプロセスの標準入力・標準出力と標準 エラーにパイプをつなぎます。Open3.popen3に似ていますが、標準出力と標準 エラーが1つの変数で扱われます。

...標準出力と標準
エラーにパイプをつなぎます。Open3.popen3に似ていますが、標準出力と標準
エラーが1つの変数で扱われます。

@param cmd 実行するコマンドを指定します。

@return ブロックを指定した場合はブロックの最後に評...
...準出力と標準エラーに
接続されたパイプと実行したプロセスを待つためのスレッドを返しま
す。

Open3.#popen3と同様に引数に環境変数とオプションを指定してコマンド
を実行する事ができます。

@see Open3.#popen3...

絞り込み条件を変える

Open3.#popen2(*cmd) -> [IO, IO, Thread] (9202.0)

cmdで指定されたコマンドを実行し、そのプロセスの標準入力・標準出力にパイ プをつなぎます。Open3.popen3に似ていますが、標準エラーを扱いません。

...そのプロセスの標準入力・標準出力にパイ
プをつなぎます。Open3.popen3に似ていますが、標準エラーを扱いません。

@param cmd 実行するコマンドを指定します。

@return ブロックを指定した場合はブロックの最後に評価された値...
...場合は標準入力、標準出力に接続されたパ
イプと実行したプロセスを待つためのスレッドを返します。

Open3.#popen3と同様に引数に環境変数とオプションを指定してコマンド
を実行する事ができます。

@see Open3.#popen3...

Open3.#popen3(*cmd) {|stdin, stdout, stderr, wait_thr| ... } -> () (9120.0)

外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。

...を待つためのスレッドを 4 要素の
配列で返します。

require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")

@param cmd 実行するコマンドを指定します。

@return ブロックを指定した場合はブロックの最後に評価さ...
...se します。この場合はブロックの最後の式の結果を返します。

require 'open3'

Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close # または close_write
p stdout.read
p stderr.rea...
...\n"
"stderr\n"


stdin への入力が終わったらできる限り早く close か close_write
で閉じるべきです。

[UNIX系OS固有の注意] Open3 で作成した子プロセスは
wait(2) しなくてもゾンビになりません。

引数 cmd はそのまま Kernel.#spawn に...

ObjectSpace.#count_tdata_objects(result_hash = nil) -> Hash (9107.0)

T_DATA の種類ごとにオブジェクトの数を格納したハッシュを返します。

...m result_hash 戻り値のためのハッシュを指定します。省略した場合は新
しくハッシュを作成します。result_hash の内容は上書き
されます。プローブ効果を避けるために使用します。

@raise TypeError resul...
...向けのものです。

//emlist[例][ruby]{
ObjectSpace.count_tdata_objects
# => {RubyVM::InstructionSequence=>504, :parser=>5, :barrier=>6,
# :mutex=>6, Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99,
# ThreadGroup=>1, Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1,
# Random=>1, ARGF....
...class=>1, Data=>1, :autoload=>3, Time=>2}
//}

現在のバージョンでは、戻り値のキーはクラスオブジェクトかシンボルのオブ
ジェクトです。

普通の参照可能なオブジェクトの場合、キーはクラスオブジェクトです。それ
以外の内部的...

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (9107.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...を sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。

e
xception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec が...
...はいります。

また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。

@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.

例 長い...
...アウト
require 'timeout'

def calc_pi(min)
loop do
x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
e
nd
e
nd

t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
e
nd

printf...
...

また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。

@param sec タイムアウトする時間を秒数で指定します.
@param exception_class タイムアウトした時、発生させる例外を指定します.
@param message エラーメ...
..."execution expired" になります.

例 長い計算のタイムアウト
require 'timeout'

def calc_pi(min)
loop do
x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
e
nd
e
nd

t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){...
<< 1 2 3 > >>