class EPUB::OCF::PhysicalContainer::Zipruby

Public Instance Methods

open() { |self| ... } click to toggle source
# File lib/epub/ocf/physical_container/zipruby.rb, line 7
def open
  Zip::Archive.open @container_path do |archive|
    @monitor.synchronize do
      begin
        @archive = archive
        yield self
      rescue ::Zip::Error => error
        raise NoEntry.from_error(error)
      ensure
        @archive = nil
      end
    end
  end
end
read(path_name) click to toggle source
# File lib/epub/ocf/physical_container/zipruby.rb, line 22
def read(path_name)
  if @archive
    @archive.fopen(path_name) {|entry| entry.read}
  else
    open {|container| container.read(path_name)}
  end
rescue ::Zip::Error => error
  raise NoEntry.from_error(error)
ensure
  @archive = nil
end