るりまサーチ

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

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 4 ... > >>

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

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

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

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

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

@retu...
...数にブロックを実行し、最後にパイプ
を close します。この場合はブロックの最後の式の結果を返します。

require
'open3'

Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close...
...

require
'open3'

Open3.popen3({"foo" => "1", "bar" => "2"}, "env") {|i, o, e, t|
i.close
print o.read
}
#=> ...
foo=1
bar=2

Kernel.#spawnと同様に、引数リストの最後にオプションをハッシュ形式
で指定する事ができます。

例:

require
...

Benchmark.#bm(label_width = 0, *labels) {|rep| ... } -> [Benchmark::Tms] (19.0)

Benchmark.#benchmark メソッドの引数を簡略化したものです。

...します。
@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。

//emlist[][ruby]{
require
'benchmark'

n = 50000
Benchmark.bm do |x|
x.report { for i in 1..n; a = "1"; end }
x.report { n.times do ; a = "1"; end }
x.report { 1.upt...
...3333 0.000000 1.483333 ( 0.694605)
# 1.516667 0.000000 1.516667 ( 0.711077)
//}

以下のようにも書けます。

//emlist[][ruby]{
require
'benchmark'

n = 50000
Benchmark.bm(7) do |x|
x.report("for:") { for i in 1..n; a = "1"; end }
x.report("times:") { n.times do ; a = "1";...
....533333 0.016667 1.550000 ( 0.735473)
# upto: 1.500000 0.016667 1.516667 ( 0.711239)
//}

集計を付けた場合

//emlist[][ruby]{
require
'benchmark'

n = 50000
Benchmark.bm(7, ">total:", ">avg:") do |x|
tf = x.report("for:") { for i in 1..n; a = "1"; end }
tt = x.report("time...

FileUtils.#cp_lr(src, dest, noop: nil, verbose: nil, dereference_root: true, remove_destination: false) (19.0)

src へのハードリンク dest を作成します。 src がディレクトリの場合、再帰的にリンクします。 dest がディレクトリの場合、src へのハードリンク dest/src を作成します。

...ruby にインストールする例][ruby]{
require
'fileutils'
FileUtils.rm_r site_ruby + '/mylib', force: true
FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
//}

//emlist[様々なファイルを対象ディレクトリにリンクする例][ruby]{
require
'fileutils'
FileUtils.cp_lr %w(mail.rb fie...
...+ '/tmail'
FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
//}

//emlist[内容をリンクする例][ruby]{
require
'fileutils'
# ディレクトリそのものではなく、ディレクトリの内容をリンクしたい場合は、
# 以下のようにな...

LUSolve.#lusolve(a, b, ps, zero = 0.0) -> [BigDecimal] (19.0)

LU 分解を用いて、連立1次方程式 Ax = b の解 x を求めて返します。

...s LUSolve.#ludecomp の返り値を指定します。

@param zero 0.0 を表す値を指定します。

//emlist[][ruby]{
require
'bigdecimal'
require
'bigdecimal/util'
require
'bigdecimal/ludcmp'

include LUSolve

a = [['1.0', '2.0'], ['3.0', '1.0']].flatten.map(&:to_d)
# x = ['1.0', -1.0']
b = [...

Etc.#uname -> {Symbol => String} (13.0)

uname(2) で取得したシステム情報を Hash で返します。

...とも :sysname, :nodename, :release, :version, :machine の
5 つのキーを持つ Hash を返します。

//emlist[例][ruby]{
require
'etc'
require
'pp'

pp Etc.uname
# => {:sysname=>"Linux",
# :nodename=>"boron",
# :release=>"2.6.18-6-xen-686",
# :version=>"#1 SMP Thu Nov 5...

絞り込み条件を変える

FileUtils.#chmod(mode, list, options = {}) -> Array (13.0)

ファイル list のパーミッションを mode に変更します。

...て返します。

//emlist[][ruby]{
# Absolute mode
require
'fileutils'
FileUtils.chmod(0644, %w(my.rb your.rb his.rb her.rb))
FileUtils.chmod(0755, 'somecommand')
FileUtils.chmod(0755, '/usr/bin/ruby', verbose: true)
# Symbolic mode
require
'fileutils'
FileUtils.chmod("u=wr,go=rr", %w(my.rb your....

FileUtils.#chown_R(user, group, list, options = {}) -> Array (13.0)

list 以下のファイルの所有ユーザと所有グループを user と group へ再帰的に変更します。

...#options

@return list を配列として返します。

//emlist[][ruby]{
require
'fileutils'
FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true

require
'fileutils'
FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
FileUtils.ch...

FileUtils.#cp_r(src, dest, options = {}) -> () (13.0)

src を dest にコピーします。src がディレクトリであったら再帰的に コピーします。その際 dest がディレクトリなら dest/src にコピーします。

...#options

//emlist[][ruby]{
# installing ruby library "mylib" under the site_ruby
require
'fileutils'
FileUtils.rm_r(site_ruby + '/mylib', force: true)
FileUtils.cp_r('lib/', site_ruby + '/mylib')
# other sample
require
'fileutils'
FileUtils.cp_r(%w(mail.rb field.rb debug/), site_ruby + '/tmail')
Fi...

JSON.#dump(object, io = nil, limit = nil) -> String | IO (13.0)

与えられたオブジェクトを JSON 形式の文字列に変換してダンプします。

...ストの深さが limit を越えた場合に発生します。

//emlist[例][ruby]{
require
"json"

JSON.dump({ name: "tanaka", age: 19 }) # => "{\"name\":\"tanaka\",\"age\":19}"
//}

//emlist[例][ruby]{
require
"json"

File.open("test.txt", "w") do |f|
JSON.dump([[[[[[[[[[]]]]]]]]]], f, 10)...

Kernel.#open(name, mode = &#39;r&#39;, perm = nil, options = {}) -> StringIO | Tempfile | IO (13.0)

name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

...す。

Ruby2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。

require
'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via Kernel#open is deprecated, call URI.open di...
...Net::FTPError のサブクラスが発生します。詳しくは net/ftp
を参照して下さい。

例:

require
'open-uri'
sio = open('http://www.example.com') { |sio|
p sio.is_a?(OpenURI::Meta) # => true
p sio.content_type
puts sio.read
}...

絞り込み条件を変える

Kernel.#open(name, mode = &#39;r&#39;, perm = nil, options = {}) {|ouri| ...} -> object (13.0)

name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

...す。

Ruby2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。

require
'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via Kernel#open is deprecated, call URI.open di...
...Net::FTPError のサブクラスが発生します。詳しくは net/ftp
を参照して下さい。

例:

require
'open-uri'
sio = open('http://www.example.com') { |sio|
p sio.is_a?(OpenURI::Meta) # => true
p sio.content_type
puts sio.read
}...
<< < 1 2 3 4 ... > >>