Class: EPUB::OCF::PhysicalContainer::UnpackedURI

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

Instance Method Summary collapse

Methods inherited from EPUB::OCF::PhysicalContainer

adapter, adapter=, find_adapter, open, read

Constructor Details

#initialize(container_path) ⇒ UnpackedURI

Parameters:

  • container_path (URI, String)

    URI of EPUB container’s root directory. For exapmle, "http://example.net/path/to/book/", which should contain "http://example.net/path/to/book/META-INF/container.xml" as its container.xml file. Note that this should end with “/”(slash).



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

def initialize(container_path)
  super(URI(container_path))
end

Instance Method Details

#open {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



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

def open
  yield self
end

#read(path_name) ⇒ Object



20
21
22
23
24
# File 'lib/epub/ocf/physical_container/unpacked_uri.rb', line 20

def read(path_name)
  (@container_path + path_name).read
rescue ::OpenURI::HTTPError => error
  raise NoEntry.from_error(error)
end