Class: Docxer::Properties::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/docxer/properties/core.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Core

Returns a new instance of Core.



7
8
9
# File 'lib/docxer/properties/core.rb', line 7

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/docxer/properties/core.rb', line 5

def options
  @options
end

Instance Method Details

#documentObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/docxer/properties/core.rb', line 11

def document
  Nokogiri::XML::Builder.with(Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')) do |xml|
    xml.coreProperties('xmlns:cp' => 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:dcterms' => 'http://purl.org/dc/terms/', 'xmlns:dcmitype' => 'http://purl.org/dc/dcmitype/', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do
      xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix=="cp" }
      # xml['dc'].title options[:title]
      xml['dc'].creator do
        options[:creator]
      end
      xml['cp'].lastModifiedBy do
        options[:creator]
      end
      xml['cp'].revision 1
      xml['dcterms'].created(Time.now.strftime('%Y-%m-%dT%H:%M:%SZ'), 'xsi:type' => 'dcterms:W3CDTF')
      xml['dcterms'].modified(Time.now.strftime('%Y-%m-%dT%H:%M:%SZ'), 'xsi:type' => 'dcterms:W3CDTF')
    end
  end
end