Module: Pubgen::OPF
- Defined in:
- lib/pubgen/opf.rb
Defined Under Namespace
Modules: OPFImpl
Class Method Summary collapse
-
.generate(yaml, uuid) ⇒ Object
Generates the OPF XML.
-
.ncx_path ⇒ Object
Returns the NCX file path.
-
.valid_manifest_element?(e) ⇒ Boolean
Checks if element is sub directories and relative paths form.
Class Method Details
.generate(yaml, uuid) ⇒ Object
Generates the OPF XML.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pubgen/opf.rb', line 11 def self.generate(yaml, uuid) cover_id, manifest_xml, file2id = OPFImpl.get_cover_id_and_manifest_xml(yaml['guide']['cover-image'], yaml['manifest']) header = <<EOF <?xml version='1.0' encoding='utf-8'?> <package xmlns="http://www.idpf.org/2007/opf" version="2.0" \ unique-identifier="uuid_id"> EOF header << OPFImpl.(yaml['metadata'], uuid, cover_id) << manifest_xml << OPFImpl.get_spine_xml(yaml['spine'], file2id) << OPFImpl.get_guide_xml(yaml['guide'], file2id) << '</package>' end |
.ncx_path ⇒ Object
Returns the NCX file path.
6 7 8 |
# File 'lib/pubgen/opf.rb', line 6 def self.ncx_path 'toc.ncx' end |
.valid_manifest_element?(e) ⇒ Boolean
Checks if element is sub directories and relative paths form
28 29 30 |
# File 'lib/pubgen/opf.rb', line 28 def self.valid_manifest_element?(e) e[0..2] != "../" && e[0] != "/" end |