class LibZip::OutputStream
A write handle on 1 entry, from LibZip::File#get_output_stream.
zip.get_output_stream("data.csv") do |out| out.write("a,b,c\n") out << "1,2,3\n" end
What you write is buffered in memory, and becomes an entry only on close, which the block form calls for you. A stream that isn’t closed, because the block failed or because the garbage collector took it, adds no entry. The entry is written to disk when the archive is closed.
Public Instance Methods
Source
# File doc/api.rb, line 488 def <<(string) end
Appends string and returns self, so writes chain.
out << "Hello, " << "world!\n"
Source
# File doc/api.rb, line 496 def close end
Adds the buffered bytes to the archive as the entry, and returns nil. LibZip::File#close writes the archive to disk.
Encryption is set up here, so a bad encryption setup shows up on close instead of on write.
Source
# File doc/api.rb, line 482 def write(string) end
Appends string to the buffer, and returns the number of bytes written. Binary data, NUL bytes included, is written as given.
Fails with LibZip::EntryError once the stream has been closed, or the archive has.