Class: EPUB::OCF::PhysicalContainer::Zipruby

Inherits:
EPUB::OCF::PhysicalContainer show all
Defined in:
lib/epub/ocf/physical_container/zipruby.rb

Instance Method Summary collapse

Methods inherited from EPUB::OCF::PhysicalContainer

adapter, adapter=, #initialize, open, read

Constructor Details

This class inherits a constructor from EPUB::OCF::PhysicalContainer

Instance Method Details

#openObject


20
21
22
23
24
25
26
27
28
29
# File 'lib/epub/ocf/physical_container/zipruby.rb', line 20

def open
  Zip::Archive.open @container_path do |archive|
    begin
      @archive = archive
      yield self
    ensure
      @archive = nil
    end
  end
end

#read(path_name) ⇒ Object


31
32
33
34
35
36
37
# File 'lib/epub/ocf/physical_container/zipruby.rb', line 31

def read(path_name)
  if @archive
    @archive.fopen(path_name) {|entry| entry.read}
  else
    open {|container| container.read(path_name)}
  end
end