Class: EPUB::OCF::PhysicalContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/epub/ocf/physical_container.rb,
lib/epub/ocf/physical_container/zipruby.rb,
lib/epub/ocf/physical_container/archive_zip.rb,
lib/epub/ocf/physical_container/unpacked_uri.rb

Direct Known Subclasses

ArchiveZip, UnpackedURI, Zipruby

Defined Under Namespace

Classes: ArchiveZip, UnpackedURI, Zipruby

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container_path) ⇒ PhysicalContainer

Returns a new instance of PhysicalContainer.


41
42
43
# File 'lib/epub/ocf/physical_container.rb', line 41

def initialize(container_path)
  @container_path = container_path
end

Class Method Details

.adapterObject

Raises:

  • (NoMethodError)

11
12
13
14
# File 'lib/epub/ocf/physical_container.rb', line 11

def adapter
  raise NoMethodError, "undefined method `#{__method__}' for #{self}" unless self == PhysicalContainer
  @adapter
end

.adapter=(adapter) ⇒ Object

Raises:

  • (NoMethodError)

16
17
18
19
20
# File 'lib/epub/ocf/physical_container.rb', line 16

def adapter=(adapter)
  raise NoMethodError, "undefined method `#{__method__}' for #{self}" unless self == PhysicalContainer
  @adapter = adapter.instance_of?(Class) ? adapter : const_get(adapter)
  adapter
end

.open(container_path) ⇒ Object


22
23
24
25
26
# File 'lib/epub/ocf/physical_container.rb', line 22

def open(container_path)
  _adapter.new(container_path).open do |container|
    yield container
  end
end

.read(container_path, path_name) ⇒ Object


28
29
30
31
32
# File 'lib/epub/ocf/physical_container.rb', line 28

def read(container_path, path_name)
  open(container_path) {|container|
    container.read(path_name)
  }
end