モジュール
- Base64 (11)
- Find (22)
- Math (22)
- ObjectSpace (11)
- Process (11)
-
Process
:: GID (22) -
Process
:: UID (22) - Readline (11)
-
WEBrick
:: HTTPAuth (11)
キーワード
- acos (11)
- asin (11)
-
basic
_ auth (11) - encode64 (11)
- find (22)
- getrlimit (11)
-
memsize
_ of _ all (11) - readline (11)
- switch (44)
検索結果
先頭5件
-
WEBrick
:: HTTPAuth . # basic _ auth(req , res , realm) {|user , pass| . . . } -> nil (13.0) -
Basic 認証を行うためのメソッドです。
...ck::HTTPStatus::Unauthorized 認証に失敗した場合に発生します。
require 'webrick'
srv.mount_proc('/basic_auth') {|req, res|
HTTPAuth.basic_auth(req, res, "WEBrick's realm") {|user, pass|
user == 'webrick' && pass == 'supersecretpassword'
}
res.body = "hoge"
}... -
Base64
. # encode64(bin) -> String (7.0) -
与えられたデータを Base64 エンコードした文字列を返します。
...字ごとに改行を追加します。
@param bin Base64 エンコードするデータを指定します。
require 'base64'
Base64.encode64("Now is the time for all good coders\nto learn Ruby")
# => Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
# UnVieQ==... -
Find
. # find(*dirs) -> Enumerator (7.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...@param dirs 探索するディレクトリを一つ以上指定します。
例:
require 'find'
Find.find('/tmp') {|f|
Find.prune if f == "/tmp/bar"
...
}
あるディレクトリ配下の探索を省略したい場合は上記のように、
Find.#prune を使用します。... -
Find
. # find(*dirs) {|file| . . . } -> nil (7.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...@param dirs 探索するディレクトリを一つ以上指定します。
例:
require 'find'
Find.find('/tmp') {|f|
Find.prune if f == "/tmp/bar"
...
}
あるディレクトリ配下の探索を省略したい場合は上記のように、
Find.#prune を使用します。... -
Find
. # find(*dirs , ignore _ error: true) -> Enumerator (7.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...索中に発生した例外を無視するかどうかを指定します。
例:
require 'find'
Find.find('/tmp') {|f|
Find.prune if f == "/tmp/bar"
...
}
あるディレクトリ配下の探索を省略したい場合は上記のように、
Find.#prune を使用します。こ... -
Find
. # find(*dirs , ignore _ error: true) {|file| . . . } -> nil (7.0) -
find(1) のように dir 配下のすべてのファイルや ディレクトリを一つずつ引数 file に渡してブロックを実行します。
...索中に発生した例外を無視するかどうかを指定します。
例:
require 'find'
Find.find('/tmp') {|f|
Find.prune if f == "/tmp/bar"
...
}
あるディレクトリ配下の探索を省略したい場合は上記のように、
Find.#prune を使用します。こ... -
Math
. # acos(x) -> Float (7.0) -
x の逆余弦関数(arccosine)の値をラジアンで返します。
...定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.acos(0) == Math::PI/2 # => true
//}
@see Math.#cos... -
Math
. # asin(x) -> Float (7.0) -
x の逆正弦関数(arcsine)の値をラジアンで返します。
...定した場合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
Math.asin(1) == Math::PI/2 # => true
//}
@see Math.#sin... -
ObjectSpace
. # memsize _ of _ all(klass = nil) -> Integer (7.0) -
すべての生存しているオブジェクトが消費しているメモリ使用量をバイト単位 で返します。
...。
//emlist[例][ruby]{
def memsize_of_all klass = false
total = 0
ObjectSpace.each_object{|e|
total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass)
}
total
end
//}
戻り値の内容は完全ではない事に注意してください。この内容はあくまで... -
Process
. # getrlimit(resource) -> [Integer] (7.0) -
カレントプロセスでのリソースの制限値を、整数の配列として返します。 返り値は、現在の制限値 cur_limit と、制限値として設定可能な最大値 max_limit の 配列 [cur_limit, max_limit] です。
...(バイト) (NetBSD, FreeBSD)
例:
include Process
p lim = getrlimit(RLIMIT_STACK) #=> [8388608, 18446744073709551615]
p lim.map{|i| i == RLIM_INFINITY ? "unlimited" : "#{i/(1024**2)}MB" } #=> ["8MB", "unlimited"]
@see Process.#setrlimit, getrlimit(2)... -
Process
:: GID . # switch -> Integer (7.0) -
実効グループ ID を一時的に変更するために使います。
...mplementedError メソッドが現在のプラットフォームで実装されていない場合に発生します。
include Process
# (r, e, s) == (500, 505, 505)
p [gid, egid] #=> [500, 505]
Process::GID.switch do
p [gid, egid] #=> [500, 500]
end
p [gid, egid]... -
Process
:: GID . # switch { . . . } -> object (7.0) -
実効グループ ID を一時的に変更するために使います。
...mplementedError メソッドが現在のプラットフォームで実装されていない場合に発生します。
include Process
# (r, e, s) == (500, 505, 505)
p [gid, egid] #=> [500, 505]
Process::GID.switch do
p [gid, egid] #=> [500, 500]
end
p [gid, egid]...