class BerkeleyLibrary::Util::ODS::XML::Manifest::Manifest

Constants

MANIFEST_VERSION
REQUIRED_NAMESPACES

Public Class Methods

new(doc:) click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 13
def initialize(doc:)
  super(:manifest, 'manifest', doc: doc)

  set_default_attributes!
  add_file_entry(self_file_entry)
end

Public Instance Methods

add_child(child) click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 30
def add_child(child)
  return add_file_entry(child) if child.is_a?(FileEntry)

  child.tap { |c| other_children << c }
end
add_entry_for(doc) click to toggle source

Adds a document to the manifest @param doc [XML::DocumentNode] the document to add

# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 26
def add_entry_for(doc)
  FileEntry.new(doc.path, manifest: self).tap { |e| add_file_entry(e) }
end
children() click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 36
def children
  [file_entries, other_children].flatten
end
version() click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 20
def version
  MANIFEST_VERSION
end

Private Instance Methods

add_file_entry(file_entry) click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 60
def add_file_entry(file_entry)
  file_entry.tap { |fe| file_entries << fe }
end
file_entries() click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 48
def file_entries
  @file_entries ||= []
end
other_children() click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 52
def other_children
  @other_children ||= []
end
required_namespaces() click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 56
def required_namespaces
  @required_namespaces ||= REQUIRED_NAMESPACES.map { |p| Namespace.for_prefix(p) }
end
self_file_entry() click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 42
def self_file_entry
  FileEntry.new('/', manifest: self).tap do |entry|
    entry.set_attribute('version', version)
  end
end
set_default_attributes!() click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/manifest.rb, line 64
def set_default_attributes!
  required_namespaces.each { |ns| set_attribute(:xmlns, ns.prefix, ns.uri) }
  set_attribute('version', version)
end