別のキーワード
クラス
- Dir (48)
- File (12)
- IO (72)
-
Zlib
:: GzipWriter (24)
検索結果
先頭5件
-
Zlib
:: GzipWriter # close -> File (21182.0) -
フッターを書き出し、GzipWriter オブジェクトをクローズします。close と finish の違いは Zlib::GzipFile#close, Zlib::GzipFile#finish を 参照して下さい。
...フッターを書き出し、GzipWriter オブジェクトをクローズします。close と
finish の違いは Zlib::GzipFile#close, Zlib::GzipFile#finish を
参照して下さい。
注意: Ruby の finalizer の制約のため、GzipWriter オブジェクトは
必ずクローズしてく......。
require 'zlib'
def case_finish
filename='hoge1.gz'
gz = Zlib::GzipWriter.open(filename, 9)
gz.puts "hogehoge\n" * 100
f = gz.finish
p f.atime
# 例
#=> Sun Jul 06 15:43:57 +0900 2008
end
def case_close
filename='hoge1.gz'
gz = Zlib::GzipWriter.o......pen(filename, 9)
gz.puts "hogehoge\n" * 100
f = gz.close
begin
p f.atime
rescue IOError => err
puts err #=> closed stream
end
end
case_finish
case_close... -
IO
# close _ read -> nil (12272.0) -
読み込み用の IO を close します。主にパイプや読み書き両用に作成し た IO オブジェクトで使用します。
...を close します。主にパイプや読み書き両用に作成し
た IO オブジェクトで使用します。
既に close されていた場合には単に無視されます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
@raise Errno:......:EXXX close に失敗した場合に発生します。
//emlist[例][ruby]{
IO.popen("/bin/sh","r+") do |f|
f.close_read
# f.readlines # => IOError: not opened for reading
end
//}
@see IO#close, IO#closed?, IO#close_write... -
IO
# close _ write -> nil (12272.0) -
書き込み用の IO を close します。
...用の IO を close します。
既に close されていた場合には単に無視されます。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX close に失敗した場合に発生します。
//emlist[例][ruby]{
f = IO.po......pen("/bin/sh","r+") do |f|
f.close_write
# f.print "nowhere" # => IOError: not opened for writing
end
//}
@see IO#close, IO#closed?, IO#close_read... -
IO
# close _ read -> nil (12266.0) -
読み込み用の IO を close します。主にパイプや読み書き両用に作成し た IO オブジェクトで使用します。
... close します。主にパイプや読み書き両用に作成し
た IO オブジェクトで使用します。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
@raise Errno::EXXX close に失敗した場合に発生します。
//emlist[例][ru......by]{
IO.popen("/bin/sh","r+") do |f|
f.close_read
# f.readlines # => IOError: not opened for reading
end
//}
@see IO#close, IO#closed?, IO#close_write... -
IO
# close _ write -> nil (12266.0) -
書き込み用の IO を close します。
... close します。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX close に失敗した場合に発生します。
//emlist[例][ruby]{
f = IO.popen("/bin/sh","r+") do |f|
f.close_write
# f.print "nowhere" # => IOError: no......t opened for writing
end
//}
@see IO#close, IO#closed?, IO#close_read... -
Dir
# read -> String | nil (6131.0) -
ディレクトリストリームから次の要素を読み出して返します。最後の要素 まで読み出していれば nil を返します。
...を返します。
@raise Errno::EXXX ディレクトリの読み出しに失敗した場合に発生します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
require 'tmpdir'
Dir.mktmpdir do |tmpdir|
File.open("#{tmpdir}/test1.txt", "w") {......|f| f.puts("test1") }
File.open("#{tmpdir}/test2.txt", "w") { |f| f.puts("test2") }
Dir.open(tmpdir) do |d|
p d.read # => "."
p d.read # => ".."
p d.read # => "test1.txt"
p d.read # => "test2.txt"
p d.read # => nil
end
end
//}... -
Dir
# rewind -> self (6125.0) -
ディレクトリストリームの読み込み位置を先頭に移動させます。
...レクトリストリームの読み込み位置を先頭に移動させます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
d.rewind # => #<Dir:0x401b3fb0>
d.read # => "."
end
//}... -
Zlib
:: GzipWriter # finish -> File (6082.0) -
フッターを書き出し、GzipWriter オブジェクトをクローズします。close と finish の違いは Zlib::GzipFile#close, Zlib::GzipFile#finish を 参照して下さい。
...フッターを書き出し、GzipWriter オブジェクトをクローズします。close と
finish の違いは Zlib::GzipFile#close, Zlib::GzipFile#finish を
参照して下さい。
注意: Ruby の finalizer の制約のため、GzipWriter オブジェクトは
必ずクローズしてく......。
require 'zlib'
def case_finish
filename='hoge1.gz'
gz = Zlib::GzipWriter.open(filename, 9)
gz.puts "hogehoge\n" * 100
f = gz.finish
p f.atime
# 例
#=> Sun Jul 06 15:43:57 +0900 2008
end
def case_close
filename='hoge1.gz'
gz = Zlib::GzipWriter.o......pen(filename, 9)
gz.puts "hogehoge\n" * 100
f = gz.close
begin
p f.atime
rescue IOError => err
puts err #=> closed stream
end
end
case_finish
case_close... -
Dir
# pos=(pos) (3025.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
...ます。
pos は Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read #......=> "."
i = d.tell # => 12
d.read # => ".."
d.seek(i) # => #<Dir:0x401b3c40>
d.read # => ".."
end
//}... -
Dir
# seek(pos) -> self (3025.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
...ます。
pos は Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read #......=> "."
i = d.tell # => 12
d.read # => ".."
d.seek(i) # => #<Dir:0x401b3c40>
d.read # => ".."
end
//}... -
IO
# pid -> Integer | nil (131.0) -
自身が IO.popen で作られたIOポートなら、子プロセスのプロセス ID を 返します。それ以外は nil を返します。
...外は nil を返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
IO.popen("-") do |pipe|
if pipe
$stderr.puts "In parent, child pid is #{pipe.pid}" # => In parent, child pid is 16013
else
$stderr.puts "In child, pid is #{$$}"......# => In child, pid is 16013
end
end
//}...