Class: EPUB::OCF::PhysicalContainer
- Inherits:
-
Object
- Object
- EPUB::OCF::PhysicalContainer
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
Defined Under Namespace
Classes: ArchiveZip, NoEntry, UnpackedDirectory, UnpackedURI, Zipruby
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of PhysicalContainer.
59
60
61
62
|
# File 'lib/epub/ocf/physical_container.rb', line 59
def initialize(container_path)
@container_path = container_path
@monitor = Monitor.new
end
|
Class Method Details
.adapter ⇒ Object
30
31
32
33
|
# File 'lib/epub/ocf/physical_container.rb', line 30
def adapter
raise NoMethodError, "undefined method `#{__method__}' for #{self}" unless self == PhysicalContainer
@adapter
end
|
.adapter=(adapter) ⇒ Object
35
36
37
38
|
# File 'lib/epub/ocf/physical_container.rb', line 35
def adapter=(adapter)
raise NoMethodError, "undefined method `#{__method__}' for #{self}" unless self == PhysicalContainer
@adapter = find_adapter(adapter)
end
|
.find_adapter(adapter) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/epub/ocf/physical_container.rb', line 22
def find_adapter(adapter)
return adapter if adapter.instance_of? Class
if adapter == :Zipruby && ! const_defined?(adapter)
require 'epub/ocf/physical_container/zipruby'
end
const_get adapter
end
|
.open(container_path) ⇒ Object
40
41
42
43
44
|
# File 'lib/epub/ocf/physical_container.rb', line 40
def open(container_path)
_adapter.new(container_path).open do |container|
yield container
end
end
|
.read(container_path, path_name) ⇒ Object
46
47
48
49
50
|
# File 'lib/epub/ocf/physical_container.rb', line 46
def read(container_path, path_name)
open(container_path) {|container|
container.read(path_name)
}
end
|