6件ヒット
[1-6件を表示]
(0.049秒)
クラス
-
File
:: Stat (1) - IO (1)
- String (1)
- SystemCallError (1)
- SystemExit (2)
検索結果
先頭5件
-
SystemCallError
# errno -> Integer | nil (9010.0) -
レシーバに対応するシステム依存のエラーコードを返します。
レシーバに対応するシステム依存のエラーコードを返します。
エラーコードを渡さない形式で生成した場合は nil を返します。
begin
raise Errno::ENOENT
rescue Errno::ENOENT => err
p err.errno # => 2
p Errno::ENOENT::Errno # => 2
end
begin
raise SystemCallError, 'message'
rescue SystemCallError => err
p err.e... -
SystemExit
# status -> Integer (9010.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 (9010.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 (28.0) -
無名パイプおよび名前つきパイプ(FIFO)の時に真を返します。
無名パイプおよび名前つきパイプ(FIFO)の時に真を返します。
//emlist[][ruby]{
system("mkfifo /tmp/pipetest")
p File::Stat.new("/tmp/pipetest").pipe? #=> true
//} -
IO
# close _ on _ exec=(bool) (28.0) -
自身に close-on-exec フラグを設定します。
自身に close-on-exec フラグを設定します。
このフラグをセットすると exec(2) 時にそのファイルデスクリプタを
close します。
@see fcntl(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
... -
String
# sum(bits = 16) -> Integer (28.0) -
文字列の bits ビットのチェックサムを計算します。
文字列の bits ビットのチェックサムを計算します。
以下と同じです。
//emlist[][ruby]{
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 %= ...