Sha256: 09c7a341b6a683da2a80132a51bcf29b49d5f637d6f8ab0f2acffc6ea34c74e0

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

module Axlsx
  # The core object for the package.
  # @note Packages manage their own core object.
  # @see Package#core
  class Core
    # The author of the document. By default this is 'axlsx'
    # @return [String]
    attr_accessor :creator
    
    # Creates a new Core object.
    # @option options [String] creator
    def initialize(options={})
      @creator = options[:creator] || 'axlsx'      
    end

    # Serializes the core object. The created dcterms item is set to the current time when this method is called.
    # @return [String]
    def to_xml()
      builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
        xml.send('cp:coreProperties', 
                 :"xmlns:cp" => CORE_NS, 
                 :'xmlns:dc' => CORE_NS_DC, 
                 :'xmlns:dcmitype'=>CORE_NS_DCMIT, 
                 :'xmlns:dcterms'=>CORE_NS_DCT, 
                 :'xmlns:xsi'=>CORE_NS_XSI) {
          xml['dc'].creator self.creator
          xml['dcterms'].created Time.now.strftime('%Y-%m-%dT%H:%M:%S'), :'xsi:type'=>"dcterms:W3CDTF"
          xml['cp'].revision 0
        }
      end  
      builder.to_xml
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
axlsx-1.0.15 lib/axlsx/doc_props/core.rb
axlsx-1.0.14 lib/axlsx/doc_props/core.rb
axlsx-1.0.13 lib/axlsx/doc_props/core.rb
axlsx-1.0.11 lib/axlsx/doc_props/core.rb
axlsx-1.0.10 lib/axlsx/doc_props/core.rb
axlsx-1.0.10a lib/axlsx/doc_props/core.rb
axlsx-1.0.9 lib/axlsx/doc_props/core.rb
axlsx-1.0.8 lib/axlsx/doc_props/core.rb
axlsx-1.0.7 lib/axlsx/doc_props/core.rb
axlsx-1.0.6 lib/axlsx/doc_props/core.rb
axlsx-1.0.5 lib/axlsx/doc_props/core.rb
axlsx-1.0.4 lib/axlsx/doc_props/core.rb
axlsx-1.0.3 lib/axlsx/doc_props/core.rb
axlsx-1.0.1 lib/axlsx/doc_props/core.rb
axlsx-1.0.0 lib/axlsx/doc_props/core.rb