ライブラリ
- ビルトイン (56)
- abbrev (12)
- base64 (36)
- benchmark (60)
- bigdecimal (24)
-
bigdecimal
/ math (24) - cmath (12)
- digest (12)
- erb (60)
- etc (84)
- fiddle (36)
- fileutils (367)
- find (24)
- json (132)
- kconv (12)
- objspace (48)
- open-uri (16)
- open3 (168)
- openssl (12)
- pp (4)
- readline (12)
- shellwords (48)
- syslog (180)
- timeout (21)
-
webrick
/ htmlutils (12) -
webrick
/ httpauth (12) -
webrick
/ httpstatus (12) -
webrick
/ httputils (12) -
webrick
/ utils (24) -
win32
/ resolv (24)
クラス
-
Win32
:: Resolv (24)
モジュール
- Abbrev (12)
- Base64 (36)
- Benchmark (60)
- BigMath (24)
- CMath (12)
- Digest (12)
-
ERB
:: DefMethod (12) -
ERB
:: Util (48) - Etc (84)
- Fiddle (36)
- FileUtils (367)
- Find (24)
- JSON (132)
- Kconv (12)
- Kernel (100)
- ObjectSpace (48)
- Open3 (168)
-
OpenSSL
:: ASN1 (12) - Readline (12)
- Shellwords (48)
- Syslog (156)
-
Syslog
:: Macros (24) - Timeout (21)
-
WEBrick
:: HTMLUtils (12) -
WEBrick
:: HTTPAuth (12) -
WEBrick
:: HTTPStatus (12) -
WEBrick
:: HTTPUtils (12) -
WEBrick
:: Utils (24)
キーワード
- BigDecimal (24)
-
LOG
_ MASK (12) -
LOG
_ UPTO (12) - abbrev (12)
-
allocation
_ sourcefile (12) -
allocation
_ sourceline (12) - atan (12)
- autoload (12)
-
basic
_ auth (12) - benchmark (12)
- bm (12)
- bmbm (12)
- capture2 (12)
- capture2e (12)
- capture3 (12)
- cd (24)
- chdir (24)
- chmod (12)
-
chmod
_ R (12) - chown (12)
-
chown
_ R (12) - close (12)
- confstr (12)
- copy (12)
- cp (12)
-
cp
_ lr (7) -
cp
_ r (12) - decode (12)
- decode64 (12)
-
def
_ erb _ method (12) - dlunwrap (12)
- dlwrap (12)
- dump (12)
- encode64 (12)
- escape (12)
- facility (12)
-
fast
_ generate (12) -
fast
_ unparse (12) - find (24)
- free (12)
- generate (12)
-
get
_ hosts _ path (12) -
get
_ resolv _ info (12) - getlogin (12)
- getservername (12)
- h (12)
- hexencode (12)
-
html
_ escape (12) - ident (12)
- identical? (12)
- info (12)
- install (12)
- isjis (12)
- link (12)
- ln (12)
-
ln
_ s (12) - load (24)
- makedirs (12)
- mask (12)
- measure (12)
-
memsize
_ of (12) -
mime
_ type (12) - mkdir (12)
-
mkdir
_ p (12) - mkpath (12)
- move (12)
- mv (12)
- notice (12)
- nprocessors (12)
- open (40)
- open! (12)
- opened? (12)
- parse (12)
- parse! (12)
- pipeline (12)
-
pipeline
_ r (24) -
pipeline
_ rw (24) -
pipeline
_ start (24) -
pipeline
_ w (24) - popen3 (24)
- pp (12)
-
pretty
_ generate (12) -
pretty
_ unparse (12) -
random
_ string (12) - readline (12)
- realtime (12)
-
reason
_ phrase (12) - remove (12)
-
remove
_ entry (12) - reopen (12)
-
require
_ relative (12) - restore (12)
- rm (12)
-
rm
_ r (12) - rmdir (12)
- shellescape (12)
- shelljoin (12)
- shellsplit (12)
- shellwords (12)
- sin (12)
- sin! (6)
- symlink (12)
- sysconf (12)
- sysconfdir (12)
- systmpdir (12)
- tan! (6)
- timeout (21)
- touch (12)
-
trace
_ object _ allocations (12) - u (12)
- uname (12)
- unparse (12)
- uptodate? (12)
-
url
_ encode (12) -
urlsafe
_ encode64 (12) - warning (12)
検索結果
先頭5件
- Kernel
. # require(feature) -> bool - Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] - Kernel
. # require _ relative(relative _ feature) -> bool - Open3
. # popen3(*cmd) -> [IO , IO , IO , Thread] - Open3
. # popen3(*cmd) {|stdin , stdout , stderr , wait _ thr| . . . } -> ()
-
Kernel
. # require(feature) -> bool (21126.0) -
Ruby ライブラリ feature をロードします。拡張子補完を行い、 同じファイルの複数回ロードはしません。
...(/prime/).size # => 0
require "prime" # => true
$LOADED_FEATURES.grep(/prime/).size # => 1
require "prime" # => false
begin
require "invalid"
rescue LoadError => e
e.message # => "cannot load such file -- invalid"
end
//}
@see Kernel.#load,Kernel.#autoload,Kernel.#require_relative... -
Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] (9249.0) -
Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。
...Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。
基本的には以下のように使います。
ブロックが Benchmark::Tms オブジェクトの配列を返した場合は、
それらの数値も追加の行に表示......ます。
@param caption レポートの一行目に表示する文字列を指定します。
@param label_width ラベルの幅を指定します。
@param fmtstr フォーマット文字列を指定します。
この引数を省略すると Benchmark::FORMAT が使......@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。
=== フォーマット文字列
フォーマット文字列として以下が使用できます。
: %u
user CPU time で置き換えられます。Benchmark::Tms#utime
: %y
system C... -
Kernel
. # require _ relative(relative _ feature) -> bool (9148.0) -
現在のファイルからの相対パスで require します。
...現在のファイルからの相対パスで require します。
require File.expand_path(relative_feature, File.dirname(__FILE__))
とほぼ同じです。
Kernel.#eval などで文字列を評価した場合に、そこから
require_relative を呼出すと必ず失敗します。
@param r......elative_feature ファイル名の文字列です。
@raise LoadError ロードに失敗した場合に発生します。
@see Kernel.#require
=== require と load のスコープ
ローカル変数はファイル間では共有されません。ですので、
ロードしたライブラリのロ......扱い方はKernel.#loadでも同様です。
//emlist[例][ruby]{
# ---------- some.rb -----------
$a = 1
@a = 1
A = 1
a = 1
# ---------- end some.rb -------
require 'some'
p $a #=> 1
p @a #=> 1
p A #=> 1
p a # undefined local variable or method `a' for #<Object:0x294f9ec @a=1> (NameError)
//}... -
Open3
. # popen3(*cmd) -> [IO , IO , IO , Thread] (9137.0) -
外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。
...を待つためのスレッドを 4 要素の
配列で返します。
require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")
@param cmd 実行するコマンドを指定します。
@return ブロックを指定した場合はブロックの最後に評価さ......を返します。
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.read
}
#=> "stdout\n"
"stderr\n"
stdin への入力が終......lose か close_write
で閉じるべきです。
[UNIX系OS固有の注意] Open3 で作成した子プロセスは
wait(2) しなくてもゾンビになりません。
引数 cmd はそのまま Kernel.#spawn に渡されます。
Kernel.#spawnと同様に、引数リストの最初に環境変... -
Open3
. # popen3(*cmd) {|stdin , stdout , stderr , wait _ thr| . . . } -> () (9137.0) -
外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。
...を待つためのスレッドを 4 要素の
配列で返します。
require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")
@param cmd 実行するコマンドを指定します。
@return ブロックを指定した場合はブロックの最後に評価さ......を返します。
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.read
}
#=> "stdout\n"
"stderr\n"
stdin への入力が終......lose か close_write
で閉じるべきです。
[UNIX系OS固有の注意] Open3 で作成した子プロセスは
wait(2) しなくてもゾンビになりません。
引数 cmd はそのまま Kernel.#spawn に渡されます。
Kernel.#spawnと同様に、引数リストの最初に環境変... -
Readline
. # readline(prompt = "" , add _ hist = false) -> String | nil (9137.0) -
prompt を出力し、ユーザからのキー入力を待ちます。 エンターキーの押下などでユーザが文字列を入力し終えると、 入力した文字列を返します。 このとき、add_hist が true であれば、入力した文字列を入力履歴に追加します。 何も入力していない状態で EOF(UNIX では ^D) を入力するなどで、 ユーザからの入力がない場合は nil を返します。
...ば、入力した文字列を入力履歴に追加します。
何も入力していない状態で EOF(UNIX では ^D) を入力するなどで、
ユーザからの入力がない場合は nil を返します。
本メソッドはスレッドに対応しています。
入力待ち状態のと......でない、かつ、標準入力をクローズしている
(isatty(2) の errno が EBADF である。) 場合に発生します。
例:
require "readline"
input = Readline.readline
(プロンプトなどは表示せずに、入力待ちの状態になります。
こ......す。)
abc
p input # => "abc"
input = Readline.readline("> ")
(">"を表示し、入力待ちの状態になります。
ここでは「ls」を入力後、エンターキーを押したと想定します。)
> ls
p input # => "ls"
input = Readline.readline("> ", true)
(">"... -
Find
. # find(*dirs) -> Enumerator (9107.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...find(1) のように dir 配下のすべてのファイルや
ディレクトリを一つずつ引数 file に渡してブロックを実行します。
ディレクトリのシンボリックリンクは辿りません。
また file に渡される順序は不定です。
ブロックを省略......Enumerator を返します。
@param dirs 探索するディレクトリを一つ以上指定します。
例:
require 'find'
Find.find('/tmp') {|f|
Find.prune if f == "/tmp/bar"
...
}
あるディレクトリ配下の探索を省略したい場合は上記のように、
Find......une を使用します。この例では "/tmp/bar"
配下のファイルやディレクトリを探索しません。prune の代わりに
d:spec/control#next を使用した場合、"/tmp/bar" 自体をスキップする
だけで、その配下の探索は続行されます。
@see find(1), Find... -
Find
. # find(*dirs) {|file| . . . } -> nil (9107.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...find(1) のように dir 配下のすべてのファイルや
ディレクトリを一つずつ引数 file に渡してブロックを実行します。
ディレクトリのシンボリックリンクは辿りません。
また file に渡される順序は不定です。
ブロックを省略......Enumerator を返します。
@param dirs 探索するディレクトリを一つ以上指定します。
例:
require 'find'
Find.find('/tmp') {|f|
Find.prune if f == "/tmp/bar"
...
}
あるディレクトリ配下の探索を省略したい場合は上記のように、
Find......une を使用します。この例では "/tmp/bar"
配下のファイルやディレクトリを探索しません。prune の代わりに
d:spec/control#next を使用した場合、"/tmp/bar" 自体をスキップする
だけで、その配下の探索は続行されます。
@see find(1), Find... -
Find
. # find(*dirs , ignore _ error: true) -> Enumerator (9107.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...find(1) のように dir 配下のすべてのファイルや
ディレクトリを一つずつ引数 file に渡してブロックを実行します。
ディレクトリのシンボリックリンクは辿りません。
また file に渡される順序は不定です。
ブロックを省略......た場合は Enumerator を返します。
@param dirs 探索するディレクトリを一つ以上指定します。
@param ignore_error 探索中に発生した例外を無視するかどうかを指定します。
例:
require 'find'
Find.find('/tmp') {|f|
Find.prune if f == "/tmp......Find.#prune を使用します。この例では "/tmp/bar"
配下のファイルやディレクトリを探索しません。prune の代わりに
d:spec/control#next を使用した場合、"/tmp/bar" 自体をスキップする
だけで、その配下の探索は続行されます。
@see find(... -
Find
. # find(*dirs , ignore _ error: true) {|file| . . . } -> nil (9107.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...find(1) のように dir 配下のすべてのファイルや
ディレクトリを一つずつ引数 file に渡してブロックを実行します。
ディレクトリのシンボリックリンクは辿りません。
また file に渡される順序は不定です。
ブロックを省略......た場合は Enumerator を返します。
@param dirs 探索するディレクトリを一つ以上指定します。
@param ignore_error 探索中に発生した例外を無視するかどうかを指定します。
例:
require 'find'
Find.find('/tmp') {|f|
Find.prune if f == "/tmp......Find.#prune を使用します。この例では "/tmp/bar"
配下のファイルやディレクトリを探索しません。prune の代わりに
d:spec/control#next を使用した場合、"/tmp/bar" 自体をスキップする
だけで、その配下の探索は続行されます。
@see find(... -
FileUtils
. # install(src , dest , options = {}) -> () (6207.0) -
src と dest の内容が違うときだけ src を dest にコピーします。
...ィレクトリです。
@param options :preserve, :noop, :verbose, :mode が指定できます。
c:FileUtils#options
//emlist[][ruby]{
require 'fileutils'
FileUtils.install('ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true)
FileUtils.install('lib.rb', '/usr/local/lib/ruby/s......トリです。
@param options :preserve, :noop, :verbose, :mode, :owner, :group が指定できます。
c:FileUtils#options
//emlist[][ruby]{
require 'fileutils'
FileUtils.install('ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true)
FileUtils.install('lib.rb', '/usr/local/lib...