Class: BerkeleyLibrary::Util::ODS::XML::Manifest::Manifest

Inherits:
ElementNode
  • Object
show all
Defined in:
lib/berkeley_library/util/ods/xml/manifest/manifest.rb

Constant Summary collapse

REQUIRED_NAMESPACES =
[:manifest].freeze
MANIFEST_VERSION =
'1.2'.freeze

Instance Attribute Summary

Attributes inherited from ElementNode

#doc, #element_name, #namespace

Instance Method Summary collapse

Methods inherited from ElementNode

#attributes, #clear_attribute, #create_element, #element, #ensure_element!, #prefix, #prefixed_attr_name, #set_attribute

Constructor Details

#initialize(doc:) ⇒ Manifest

Returns a new instance of Manifest.



13
14
15
16
17
18
# 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

Instance Method Details

#add_child(child) ⇒ Object



30
31
32
33
34
# 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) ⇒ Object

Adds a document to the manifest

Parameters:



26
27
28
# 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

#childrenObject



36
37
38
# File 'lib/berkeley_library/util/ods/xml/manifest/manifest.rb', line 36

def children
  [file_entries, other_children].flatten
end

#versionObject



20
21
22
# File 'lib/berkeley_library/util/ods/xml/manifest/manifest.rb', line 20

def version
  MANIFEST_VERSION
end