Class: Rubyword::Document

Inherits:
Object
  • Object
show all
Includes:
Writer
Defined in:
lib/rubyword/document.rb

Constant Summary

Constants included from Writer

Writer::DocumentBaseFile

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Writer

#save, #write_header_and_footer

Constructor Details

#initialize(options = {}, &block) ⇒ Document

Returns a new instance of Document.



19
20
21
22
23
24
25
26
# File 'lib/rubyword/document.rb', line 19

def initialize(options={}, &block)
  @sections, @toc, @init_rid, @doc_info = [], {}, 7, {}
  @relation_rids = []
  @content_types = []
  @rels_documents = []
  @images = []
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#content_typesObject

Returns the value of attribute content_types.



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

def content_types
  @content_types
end

#doc_infoObject

Returns the value of attribute doc_info.



9
10
11
# File 'lib/rubyword/document.rb', line 9

def doc_info
  @doc_info
end

Returns the value of attribute footer.



8
9
10
# File 'lib/rubyword/document.rb', line 8

def footer
  @footer
end

#headerObject

Returns the value of attribute header.



8
9
10
# File 'lib/rubyword/document.rb', line 8

def header
  @header
end

#imagesObject

Returns the value of attribute images.



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

def images
  @images
end

#init_ridObject

Returns the value of attribute init_rid.



6
7
8
# File 'lib/rubyword/document.rb', line 6

def init_rid
  @init_rid
end

#relation_ridsObject

Returns the value of attribute relation_rids.



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

def relation_rids
  @relation_rids
end

#rels_documentsObject

Returns the value of attribute rels_documents.



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

def rels_documents
  @rels_documents
end

#sectionsObject

Returns the value of attribute sections.



6
7
8
# File 'lib/rubyword/document.rb', line 6

def sections
  @sections
end

#tocObject

Returns the value of attribute toc.



9
10
11
# File 'lib/rubyword/document.rb', line 9

def toc
  @toc
end

Class Method Details

.generate(filename, options = {}, &block) ⇒ Object



12
13
14
15
16
17
# File 'lib/rubyword/document.rb', line 12

def self.generate(filename, options = {}, &block)
  rubyword = new(options, &block)

  # module Write to create word document
  rubyword.save(filename)
end

Instance Method Details

#information(options = {}) ⇒ Object

initialize doc information



36
37
38
# File 'lib/rubyword/document.rb', line 36

def information(options={})
  @doc_info = options
end

#section(style = nil, &block) ⇒ Object



28
29
30
31
32
33
# File 'lib/rubyword/document.rb', line 28

def section(style=nil, &block)
  @section = Element::Section.new(@sections.count + 1, style, self)
  self.sections << @section
  @section.instance_eval(&block) if block_given?
  @section
end

#title_directory(option = {}) ⇒ Object

generate TOC



41
42
43
44
# File 'lib/rubyword/document.rb', line 41

def title_directory(option= {})
  @toc.merge!(open: true)
  @toc.merge!(option)
end