class Compress::Zip::File
inherits Reference
¶
Provides random read access to zip file entries stores inside
a File
or an IO::Memory
.
Example¶
require "compress/zip"
Compress::Zip::File.open("./file.zip") do |file|
# Iterate through all entries printing their filename and contents
file.entries.each do |entry|
p entry.filename
entry.open do |io|
p io.gets_to_end
end
end
# Random access to entries by filename is also provided
entry = file["some_file.txt"]
entry.open do |io|
p io.gets_to_end
end
end
Class methods¶
.open(io : IO, sync_close = false
¶
(io : IO, sync_close = false
Opens a Zip::File
for reading from the given io, yields
it to the given block, and closes it at the end.
.open(filename : String
¶
(filename : String
Opens a Zip::File
for reading from the given filename, yields
it to the given block, and closes it at the end.
Methods¶
#[](filename : String) : Entry
¶
(filename : String) : Entry
Returns the entry that has the given filename, or
raises KeyError
if no such entry exists.
#[]?(filename : String) : Entry?
¶
(filename : String) : Entry?
Returns the entry that has the given filename, or
nil
if no such entry exists.