summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/doc_props/core.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-04-01 00:35:26 +0900
committerRandy Morgan <[email protected]>2012-04-01 00:35:26 +0900
commit22a341841f191a5aa00e87b1f166b4f25cc67f0a (patch)
tree505f46708d5cac7d33d0dd6679c125e2eb819075 /lib/axlsx/doc_props/core.rb
parentbb2117ba17297e02a0fc6d5ad5a22462e72a9a79 (diff)
downloadcaxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.tar.gz
caxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.zip
part way through changing all serialization to use string concatenation prior to dropping Nokogiri dep in production.
Diffstat (limited to 'lib/axlsx/doc_props/core.rb')
-rw-r--r--lib/axlsx/doc_props/core.rb28
1 files changed, 11 insertions, 17 deletions
diff --git a/lib/axlsx/doc_props/core.rb b/lib/axlsx/doc_props/core.rb
index 96716a6b..7d9ba291 100644
--- a/lib/axlsx/doc_props/core.rb
+++ b/lib/axlsx/doc_props/core.rb
@@ -7,29 +7,23 @@ module Axlsx
# 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'
+ @creator = options[:creator] || 'axlsx'
end
- # Serializes the core object. The created dcterms item is set to the current time when this method is called.
+ # serializes the core.xml document
# @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(:save_with => 0)
+ def to_xml_string(str = '')
+ str << '<?xml version="1.0" encoding="UTF-8"?>'
+ str << '<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" '
+ str << 'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" '
+ str << 'xmlns:xsi="' << CORE_NS_XSI << '">'
+ str << '<dc:creator>' << self.creator << '</dc:creator>'
+ str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << Time.now.strftime('%Y-%m-%dT%H:%M:%S') << '</dcterms:created>'
+ str << '<cp:revision>0</cp:revision>'
end
end
end