Class: Zippo::CentralDirectoryEntriesUnpacker

Inherits:
Object
  • Object
show all
Defined in:
lib/zippo/central_directory_entries_unpacker.rb

Overview

Unpacks an array of CdFileHeaders from an io stream

Instance Method Summary collapse

Constructor Details

#initialize(io, size, offset) ⇒ CentralDirectoryEntriesUnpacker

Returns a new instance of CentralDirectoryEntriesUnpacker.



8
9
10
11
12
13
# File 'lib/zippo/central_directory_entries_unpacker.rb', line 8

def initialize(io, size, offset)
  @io = io
  @size = size
  @offset = offset
  @end = @offset + @size
end

Instance Method Details

#unpackObject



15
16
17
18
19
20
21
22
# File 'lib/zippo/central_directory_entries_unpacker.rb', line 15

def unpack
  [].tap do |entries|
    @io.seek @offset
    while @io.pos < @end && (entry = CdFileHeader::Unpacker.new(@io).unpack)
      entries << entry
    end
  end
end