class Zip::Archive
- Zip::Archive
- Reference
- Object
Overview
Input archive.
Use Zip.read()
instead of instantiating this class directly.
Included Modules
- Enumerable(Entry)
- Iterable
Defined in:
Class Method Summary
-
.new(io : Source)
Create new Zip::Archive from input Zip::Source.
Instance Method Summary
-
#[](path : String) : Entry
Get Zip::Entry by path.
-
#[](id : Int) : Entry
Get Zip::Entry by number.
-
#[]?(id : Int) : Entry | Nil
Get Zip::Entry by number, or nil if it doesn't exist
-
#[]?(path : String) : Entry | Nil
Return Zip::Entry from path, or nil if it doesn't exist.
- #comment : String
- #each(*args, **options, &block)
- #each(*args, **options)
- #entries : Array(Zip::Entry)
- #size(*args, **options, &block)
- #size(*args, **options)
Class Method Detail
Create new Zip::Archive from input Zip::Source.
Use Zip.read()
instead of calling this method directly.
Instance Method Detail
Get Zip::Entry by path.
Example:
# get bar.txt and read it into memory io
io = MemoryIO.new
zip["bar.txt"].read(io)
Get Zip::Entry by number.
Example:
# read third entry from archive into memory io
io = MemoryIO.new
zip[2].read(io)
Get Zip::Entry by number, or nil if it doesn't exist
Example:
# read third entry from archive into memory io
if e = zip[2]?
io = MemoryIO.new
e.read(io)
end
Return Zip::Entry from path, or nil if it doesn't exist.
Example:
# read bar.txt into memory io if it exists
if e = zip["bar.txt"]?
io = MemoryIO.new
e.read(io)
end