66件ヒット
[1-66件を表示]
(0.052秒)
クラス
-
File
:: Stat (11) - IO (11)
- String (11)
- SystemCallError (11)
- SystemExit (22)
検索結果
先頭5件
-
SystemCallError
# errno -> Integer | nil (3003.0) -
レシーバに対応するシステム依存のエラーコードを返します。
...escue Errno::ENOENT => err
p err.errno # => 2
p Errno::ENOENT::Errno # => 2
end
begin
raise SystemCallError, 'message'
rescue SystemCallError => err
p err.errno # => nil
end
なお、例外を発生させずにエラーコードを得... -
SystemExit
# status -> Integer (3003.0) -
例外オブジェクトに保存された終了ステータスを返します。
...します。
終了ステータスは Kernel.#exit や SystemExit.new などで設定されます。
例:
begin
exit 1
rescue SystemExit => err
p err.status # => 1
end
begin
raise SystemExit.new(1, "dummy exit")
rescue SystemExit => err
p err.status # => 1
end... -
SystemExit
# success? -> bool (3003.0) -
終了ステータスが正常終了を示す値ならば true を返します。
...値ならば true を返します。
大半のシステムでは、ステータス 0 が正常終了を表します。
例:
begin
exit true
rescue SystemExit => err
p err.success? # => true
end
begin
exit false
rescue SystemExit => err
p err.success? # => false
end... -
File
:: Stat # pipe? -> bool (9.0) -
無名パイプおよび名前つきパイプ(FIFO)の時に真を返します。
...無名パイプおよび名前つきパイプ(FIFO)の時に真を返します。
//emlist[][ruby]{
system("mkfifo /tmp/pipetest")
p File::Stat.new("/tmp/pipetest").pipe? #=> true
//}... -
IO
# close _ on _ exec=(bool) (9.0) -
自身に close-on-exec フラグを設定します。
...cntl(2)
@param bool 自身の close-on-exec フラグを true か false で指定します。
f = open("/dev/null")
f.close_on_exec = true
system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory
f.closed? #=> false
@see IO#close_on_ex... -
String
# sum(bits = 16) -> Integer (9.0) -
文字列の bits ビットのチェックサムを計算します。
...{
def sum(bits)
sum = 0
each_byte {|c| sum += c }
return 0 if sum == 0
sum & ((1 << bits) - 1)
end
//}
例えば以下のコードで UNIX System V の
sum(1) コマンドと同じ値が得られます。
//emlist[例][ruby]{
sum = 0
ARGF.each_line do |line|
sum += line.sum
end
sum %= 65...