class Zip::Entry
- Zip::Entry
- Reference
- Object
Overview
File entry in Archive.
Use Zip.read() to read a Zip archive, then #[] to fetch a
specific archive entry.
Example:
# create MemoryIO
io = MemoryIO.new
# open "foo.zip"
Zip.read("foo.zip") do |zip|
# get "bar.txt" entry from "foo.zip"
e = zip["bar.txt"]
# read contents of "bar.txt" into io
e.read(io)
end
Included Modules
Defined in:
Class Method Summary
-
.new(io : Source)
Instantiate a new
Entryobject from the given IO.
Instance Method Summary
- #comment : String
- #compressed_size : UInt32
- #crc : UInt32
- #external_attr : UInt32
- #extras : Array(Zip::Extra)
- #flags : UInt16
- #internal_attr : UInt16
- #local_extras : Array(Extra)
- #method : Zip::CompressionMethod
- #path : String
- #pos : UInt32
-
#read(dst_io : IO) : UInt32
Write contents of
Entryinto givenIO. -
#size : UInt32
Return the uncompressed size of this entry in bytes.
- #time : Time
- #uncompressed_size : UInt32
- #version : UInt16
- #version_needed : UInt16
Class Method Detail
Instantiate a new Entry object from the given IO.
You should not need to call this method directly (use
Zip::Archive#[] instead).
Instance Method Detail
Returns an array of Extra attributes for this Entry.
Zip archives can (and do) have separate Extra attributes
associated with the file entry itself, and the file's entry in the
Central Directory.
The #extras method returns the Extra attributes from the
file's entry in the Central Directory, and this method returns the
Extra data from the file entry itself.
Example:
# open "./foo.zip"
Zip.read("./foo.zip") do |zip|
# get array of local extra attributes from "bar.txt"
extras = zip["bar.txt"].local_extras
endWrite contents of Entry into given IO.
Raises an Error if the file contents could not be read or if the
compression method is unsupported.
Example:
# open "output-bar.txt" for writing
File.open("output-bar.txt", "wb") do |io|
# open archive "./foo.zip"
Zip.read("foo.zip") do |zip|
# write contents of "bar.txt" to "output-bar.txt"
zip["foo.txt"].read(io)
end
endReturn the uncompressed size of this entry in bytes.
Example:
Zip.read("foo.zip") do |zip|
size = zip["bar.txt"].size
puts "bar.txt is #{size} bytes."
end