るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

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

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

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

...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 19:54:42 UTC 2009",
# :machine=>"i686"}
//}...

Kernel.#load(file, priv = false) -> true (131.0)

Ruby プログラム file をロードして実行します。再ロード可能です。

...rnel.#require

=== require と load の違い

Kernel.#require は同じファイルは一度だけしかロードしませんが、
Kernel.#load は無条件にロードします。
また、require は拡張子.rb や .so を自動的に補完しますが、
load は行いません。
require
...

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

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

...パイプと実行したプロセスを待つためのスレッドを 4 要素の
配列で返します。

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

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

@return ブロックを指定した場合...
...数にブロックを実行し、最後にパイプ
を 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
...

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

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

...パイプと実行したプロセスを待つためのスレッドを 4 要素の
配列で返します。

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

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

@return ブロックを指定した場合...
...数にブロックを実行し、最後にパイプ
を 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
...

Kernel.#autoload(const_name, feature) -> nil (129.0)

定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

...定数 const_name を最初に参照した時に feature を
Kernel.#require するように設定します。

const_name には、 "::" 演算子を含めることはできません。
ネストした定数を指定する方法は Module#autoload を参照してください。

const_name が aut...
...します。
@param feature require と同様な方法で autoload する対象を指定します。
@raise LoadError featureのロードに失敗すると発生します。

//emlist[][ruby]{
# ------- /tmp/foo.rb ---------
class Bar
end
# ----- end of /tmp/foo.rb ----

autoload :Bar, '/tmp/foo'
p...
...Bar #=> Bar
//}

@see Kernel.#autoload?,Module#autoload,Kernel.#require...

絞り込み条件を変える

WEBrick::HTTPUtils.#mime_type(filename, mime_tab) -> String (129.0)

ファイル名 filename の拡張子をもとにその MIME タイプを指定された mime_tab から探して文字列として返します。MIME タイプが見つからない場合は "application/octet-stream" を返します。

...見つからない場合は "application/octet-stream"
を返します。

@param filename ファイル名を文字列で指定します。

@param mime_tab 拡張子をキー、MIME タイプを値とするハッシュを指定します。

require
'webrick'
include WEBrick::HTTPUtils
p mime_...
...type('index.html', DefaultMimeTypes) #=> "text/html"
p mime_type('index.html.ja', DefaultMimeTypes) #=> "text/html"
p mime_type('index.hoge', DefaultMimeTypes) #=> "application/octet-stream"...

Open3.#pipeline(*cmds) -> [Process::Status] (125.0)

指定したコマンドのリストをパイプで繋いで順番に実行します。

...のコマンドは
以下のように String か Array で指定します。
commandline にはコマンド全体(例. "nroff -man")を表す
String を指定します。
options には Hash で指定します。
env には環境変数を H...
...す。

例1:

require
"open3"

fname = "/usr/share/man/man1/ruby.1.gz"
p Open3.pipeline(["zcat", fname], "nroff -man", "less")
#=> [#<Process::Status: pid 11817 exit 0>,
# #<Process::Status: pid 11820 exit 0>,
# #<Process::Status: pid 11828 exit 0>]

例2:

require
"open3"...

Benchmark.#bm(label_width = 0, *labels) {|rep| ... } -> [Benchmark::Tms] (119.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...

CMath.#exp(z) -> Float | Complex (119.0)

z の指数関数(Math::E の z 乗)の値を返します。

...@raise TypeError z に数値以外を指定した場合に発生します。

//emlist[例][ruby]{
require
"cmath"
CMath.exp(Complex(0, 0))# => (1.0+0.0i)
CMath.exp(Complex(0, Math::PI)) # => (-1.0+1.2246063538223773e-16i)
CMath.exp(Complex(0, Math::PI / 2.0)) # => (6.123031769111886e-17+1.0i)
//}...

CMath.#log(z) -> Float | Complex (119.0)

z の対数を返します。

...aram b 底を指定します。省略した場合は自然対数を計算します。

@raise TypeError 引数のどちらかに数値以外を指定した場合に発生します。

//emlist[例][ruby]{
require
"cmath"
CMath.log(Complex(0, 0)) # => -Infinity+0.0i
CMath.log(0) # => -Infinity
//}...

絞り込み条件を変える

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