Class: Idml::Composition::ExportXml

Inherits:
Object
  • Object
show all
Defined in:
lib/idml/composition/export_xml.rb

Overview

Produce a flat XML string of the package's logical XML structure tree, with text content inlined from linked Stories. Mirrors SimpleIDML's IDMLPackage.export_xml.

Instance Method Summary collapse

Constructor Details

#initialize(package) ⇒ ExportXml

Returns a new instance of ExportXml.



9
10
11
# File 'lib/idml/composition/export_xml.rb', line 9

def initialize(package)
  @package = package
end

Instance Method Details

#call(at: nil) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



13
14
15
16
17
18
19
20
# File 'lib/idml/composition/export_xml.rb', line 13

def call(at: nil) # rubocop:disable Lint/UnusedMethodArgument
  backing = @package.backing_story
  return "" unless backing&.xml_story&.any?

  story_text_index = build_story_text_index
  nodes = backing.xml_story.flat_map(&:xml_element)
  nodes.map { |e| serialize(e, story_text_index) }.join("\n")
end