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
        
          Get the Archivecomment as a String.
- 
        #each(*args, **options, &block)
        
          Iterate over the entries in this Archive, or, if called without a block, return a lazy iterator.
- 
        #each(*args, **options)
        
          Iterate over the entries in this Archive, or, if called without a block, return a lazy iterator.
- 
        #entries : Array(Zip::Entry)
        
          Return an array of entries in this Archive. 
- 
        #size(*args, **options, &block)
        
          Return the number of entries in this Archive.
- 
        #size(*args, **options)
        
          Return the number of entries in this Archive.
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 write it into memory io
io = MemoryIO.new
zip["bar.txt"].write(io)Get Zip::Entry by number.
Example:
# write contents of third entry from archive into memory io
io = MemoryIO.new
zip[2].write(io)Get Zip::Entry by number, or nil if it doesn't exist
Example:
# write contents of third entry from archive into memory io
if e = zip[2]?
  io = MemoryIO.new
  e.write(io)
endReturn Zip::Entry from path, or nil if it doesn't exist.
Example:
# write contents of "bar.txt" into memory io if it exists
if e = zip["bar.txt"]?
  io = MemoryIO.new
  e.write(io)
endGet the Archive comment as a String.
Example:
Zip.read("foo.zip") do |zip|
  # print archive comment
  puts "comment: #{zip.comment}"
endIterate over the entries in this Archive, or, if called without
a block, return a lazy iterator.
Example:
Zip.read("foo.zip") do |zip|
  zip.each do |e|
    type = e.dir? ? "directory" : "file"
    puts "#{e.path} is a #{type}"
  end
endIterate over the entries in this Archive, or, if called without
a block, return a lazy iterator.
Example:
Zip.read("foo.zip") do |zip|
  zip.each do |e|
    type = e.dir? ? "directory" : "file"
    puts "#{e.path} is a #{type}"
  end
endReturn an array of entries in this Archive.
Example:
Zip.read("foo.zip") do |zip|
  # get an array of entries in this archive
  entries = zip.entries
end