class Xlsxrb::Ooxml::ZipReader
Reads ZIP archives using only stdlib (zlib). Scans local file headers sequentially — works with non-seekable IO.
Constants
- LOCAL_HEADER_SIG
- MAX_UNCOMPRESSED_SIZE
Attributes
max_uncompressed_size
[RW]
untyped
Public Class Methods
(untyped io, ?max_uncompressed_size: Integer) → void
Source
# File lib/xlsxrb/ooxml/zip_reader.rb, line 35 def initialize(io, max_uncompressed_size: MAX_UNCOMPRESSED_SIZE) @io = io @max_uncompressed_size = max_uncompressed_size @entries = nil end
(untyped source, ?max_uncompressed_size: Integer) ?{ (ZipReader) → untyped } → (ZipReader | untyped)
Source
# File lib/xlsxrb/ooxml/zip_reader.rb, line 20 def self.open(source, max_uncompressed_size: MAX_UNCOMPRESSED_SIZE) io = source.is_a?(String) ? File.open(source, "rb") : source reader = new(io, max_uncompressed_size: max_uncompressed_size) if block_given? begin yield reader ensure io.close if source.is_a?(String) end else reader end end
Opens a ZIP from a file path or IO and yields the reader.
Public Instance Methods
() ?{ (?) → untyped } → untyped
Source
# File lib/xlsxrb/ooxml/zip_reader.rb, line 54 def each_entry(&block) return enum_for(:each_entry) unless block entries.each_pair(&block) end
Yields (entry_name, data_string) for each file in the archive.
() → untyped
Source
# File lib/xlsxrb/ooxml/zip_reader.rb, line 42 def read_all result = {} each_entry { |name, data| result[name] = data } result end
Returns a Hash { entry_name => raw_bytes } for all entries.
(untyped name) → untyped
Source
# File lib/xlsxrb/ooxml/zip_reader.rb, line 49 def read_entry(name) entries[name] end
Returns raw bytes for a single entry, or nil if not found.