Class: Docxi::Word::Document

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/docxi/word/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#br, #p, #table, #table_of_content, #text

Constructor Details

#initialize(options) ⇒ Document

Returns a new instance of Document.



9
10
11
12
# File 'lib/docxi/word/document.rb', line 9

def initialize(options)
  @options = options
  @content = []
end

Instance Attribute Details

#effectsObject

Returns the value of attribute effects.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def effects
  @effects
end

#endnotesObject

Returns the value of attribute endnotes.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def endnotes
  @endnotes
end

#fontsObject

Returns the value of attribute fonts.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def fonts
  @fonts
end

#footersObject

Returns the value of attribute footers.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def footers
  @footers
end

#footnotesObject

Returns the value of attribute footnotes.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def footnotes
  @footnotes
end

#headersObject

Returns the value of attribute headers.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def headers
  @headers
end

#numberingObject

Returns the value of attribute numbering.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def numbering
  @numbering
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def options
  @options
end

#relationshipsObject

Returns the value of attribute relationships.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def relationships
  @relationships
end

#setingsObject

Returns the value of attribute setings.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def setings
  @setings
end

#stylesObject

Returns the value of attribute styles.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def styles
  @styles
end

#themesObject

Returns the value of attribute themes.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def themes
  @themes
end

#web_settingsObject

Returns the value of attribute web_settings.



7
8
9
# File 'lib/docxi/word/document.rb', line 7

def web_settings
  @web_settings
end

Instance Method Details



21
22
23
24
25
26
27
# File 'lib/docxi/word/document.rb', line 21

def add_footer(footer, options={})
  footer.id = footers.sequence
  rel = relationships.add(footer.content_type, footer.target)
  footer.sequence = rel.id
  footers.add(footer)
  @footer = footer
end

#add_header(header, options = {}) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/docxi/word/document.rb', line 29

def add_header(header, options={})
  header.id = headers.sequence
  rel = relationships.add(header.content_type, header.target)
  header.sequence = rel.id
  headers.add(header)
  @header = header
end

#add_media(file, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/docxi/word/document.rb', line 14

def add_media(file, options={})
  media = Medias::Media.new(medias.sequence, file, options)
  rel = relationships.add(media.content_type, media.target)
  media.set_sequence(rel.id)
  medias.add(media)
end

#mediasObject



65
66
67
# File 'lib/docxi/word/document.rb', line 65

def medias
  @medias ||= Medias.new
end

#render(zip) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/docxi/word/document.rb', line 89

def render(zip)
  zip.put_next_entry('word/document.xml')
  zip.write(Docxi.to_xml(document))

  fonts.render(zip)
  settings.render(zip)
  styles.render(zip)
  effects.render(zip)
  numbering.render(zip)
  web_settings.render(zip)
  themes.render(zip)
  footnotes.render(zip)
  endnotes.render(zip)
  headers.render(zip)
  footers.render(zip)
  medias.render(zip)
  relationships.render(zip)
end

#settingsObject



41
42
43
# File 'lib/docxi/word/document.rb', line 41

def settings
  @settings ||= Settings.new
end