Class: Rubyword::Writer::Part::ContentTypes
- Defined in:
- lib/rubyword/writer/part/content_types.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Rubyword::Writer::Part::Base
Instance Method Details
#write ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubyword/writer/part/content_types.rb', line 6 def write openXMLPrefix = 'application/vnd.openxmlformats-'; wordMLPrefix = "#{openXMLPrefix}officedocument.wordprocessingml"; overrides = { '/docProps/core.xml' => "#{openXMLPrefix}package.core-properties+xml", '/docProps/app.xml' => "#{openXMLPrefix}officedocument.extended-properties+xml", '/docProps/custom.xml' => "#{openXMLPrefix}officedocument.custom-properties+xml", '/word/document.xml' => "#{wordMLPrefix}.document.main+xml", '/word/styles.xml' => "#{wordMLPrefix}.styles+xml", '/word/numbering.xml' => "#{wordMLPrefix}.numbering+xml", '/word/settings.xml' => "#{wordMLPrefix}.settings+xml", '/word/theme/theme1.xml' => "#{openXMLPrefix}officedocument.theme+xml", '/word/webSettings.xml' => "#{wordMLPrefix}.webSettings+xml", '/word/fontTable.xml' => "#{wordMLPrefix}.fontTable+xml" } @rubyword.content_types.each do |target| overrides.merge!(target) end builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml.Types(xmlns: 'http://schemas.openxmlformats.org/package/2006/content-types') do xml.Default(Extension: 'rels', ContentType: "application/vnd.openxmlformats-package.relationships+xml") xml.Default(Extension: 'xml', ContentType: 'application/xml') xml.Default(Extension: 'jpg', ContentType: 'image/jpeg') overrides.each do |part_name, content_type| xml.Override(PartName: part_name, ContentType: content_type) end end end builder.to_xml end |