Class: Goldendocx::Parts::App

Inherits:
Object
  • Object
show all
Includes:
Document
Defined in:
lib/goldendocx/parts/app.rb

Constant Summary collapse

TYPE =
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties'
XML_PATH =
'docProps/app.xml'
NAMESPACE =
'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'
CONTENT_TYPE =
'application/vnd.openxmlformats-officedocument.extended-properties+xml'

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Element

#build_element, #initialize, #namespace, #tag, #tag_name, #to_element, #to_xml

Methods included from HasChildren

#children, #read_child, #read_children

Methods included from HasAttributes

#assign_attributes, #attributes, #read_attributes

Class Method Details

.read_from(app_document) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/goldendocx/parts/app.rb', line 17

def read_from(app_document)
  new_instance = new

  app_document.children.map do |node|
    new_instance.properties[node.name.to_sym] = node.text
  end

  new_instance
end

Instance Method Details

#propertiesObject



41
42
43
# File 'lib/goldendocx/parts/app.rb', line 41

def properties
  @properties ||= { Application: "Goldendocx_#{Goldendocx::VERSION}" }
end

#to_document_xmlObject



33
34
35
36
37
38
39
# File 'lib/goldendocx/parts/app.rb', line 33

def to_document_xml
  super do |xml|
    properties.each do |name, value|
      xml << Goldendocx.xml_serializer.build_element(name).tap { |app| app << value }
    end
  end
end

#write_to(zos) ⇒ Object



28
29
30
31
# File 'lib/goldendocx/parts/app.rb', line 28

def write_to(zos)
  zos.put_next_entry XML_PATH
  zos.write to_document_xml
end