Class: EPUB::OCF::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/epub/maker/ocf.rb

Instance Method Summary collapse

Instance Method Details

#make_rootfile(full_path: nil, media_type: EPUB::MediaType::ROOTFILE) {|Rootfile| ... } ⇒ Object

Parameters:

  • full_path (Hash) (defaults to: nil)

    a customizable set of options

  • media_type (Hash) (defaults to: EPUB::MediaType::ROOTFILE)

    a customizable set of options

Options Hash (full_path:):

  • full (String|nil)

    path to package document file in container such like “OPS/content.opf”

Options Hash (media_type:):

  • media (String)

    type

Yields:

  • (Rootfile)

    rootfile



48
49
50
51
52
53
# File 'lib/epub/maker/ocf.rb', line 48

def make_rootfile(full_path: nil, media_type: EPUB::MediaType::ROOTFILE)
  rootfile = Rootfile.new(full_path, media_type)
  @rootfiles << rootfile
  yield rootfile if block_given?
  rootfile
end

#to_xml(options = {:encoding => 'UTF-8'}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/epub/maker/ocf.rb', line 32

def to_xml(options={:encoding => 'UTF-8'})
  Nokogiri::XML::Builder.new(options) {|xml|
    xml.container('xmlns' => EPUB::NAMESPACES['ocf'], 'version' => '1.0') {
      xml.rootfiles {
        rootfiles.each do |rootfile|
          xml.rootfile('full-path' => rootfile.full_path,
                       'media-type' => rootfile.media_type)
        end
      }
    }
  }.to_xml
end