Class: Docxer::ContentTypes

Inherits:
Object
  • Object
show all
Defined in:
lib/docxer/content_types.rb,
lib/docxer/content_types/default.rb,
lib/docxer/content_types/override.rb

Defined Under Namespace

Classes: Default, Override

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContentTypes

Returns a new instance of ContentTypes.



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

def initialize
  @content_types = []
  add(:default, "rels", "application/vnd.openxmlformats-package.relationships+xml")
  add(:default, "xml", "application/xml")
  add(:default, "png", "image/png")
  add(:override, "/word/document.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml")
  add(:override, "/word/styles.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml")
  add(:override, "/word/stylesWithEffects.xml", "application/vnd.ms-word.stylesWithEffects+xml")
  add(:override, "/word/settings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml")
  add(:override, "/word/webSettings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml")
  add(:override, "/word/fontTable.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml")
  add(:override, "/word/theme/theme1.xml", "application/vnd.openxmlformats-officedocument.theme+xml")
  add(:override, "/docProps/core.xml", "application/vnd.openxmlformats-package.core-properties+xml")
  add(:override, "/docProps/app.xml", "application/vnd.openxmlformats-officedocument.extended-properties+xml")
  add(:override, "/word/numbering.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml")
  add(:override, "/word/footnotes.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml")
  add(:override, "/word/endnotes.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml")
  add(:override, "/word/footer1.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")
  add(:override, "/word/header1.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml")
end

Instance Attribute Details

#content_typesObject

Returns the value of attribute content_types.



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

def content_types
  @content_types
end

Instance Method Details

#add(type, attr, content) ⇒ Object



30
31
32
33
34
# File 'lib/docxer/content_types.rb', line 30

def add(type, attr, content)
  content_type = create_content_type(type, attr, content)
  @content_types << content_type if content_type
  content_type
end

#render(zip) ⇒ Object



36
37
38
39
# File 'lib/docxer/content_types.rb', line 36

def render(zip)
  zip.put_next_entry('[Content_Types].xml')
  zip.write(Docxer.to_xml(document))
end