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,
lib/epub/ocf/physical_container/unpacked_directory.rb

Overview

@todo: Make thread save

Direct Known Subclasses

ArchiveZip, UnpackedDirectory, UnpackedURI, Zipruby

Defined Under Namespace

Classes: ArchiveZip, UnpackedDirectory, UnpackedURI, Zipruby

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container_path) ⇒ PhysicalContainer

Returns a new instance of PhysicalContainer.


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

def initialize(container_path)
  @container_path = container_path
end

Class Method Details

.adapterObject

Raises:

  • (NoMethodError)

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

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

.adapter=(adapter) ⇒ Object

Raises:

  • (NoMethodError)

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

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


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

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

.read(container_path, path_name) ⇒ Object


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

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