Class: Rubyword::Document
- Inherits:
-
Object
- Object
- Rubyword::Document
- Includes:
- Writer
- Defined in:
- lib/rubyword/document.rb
Constant Summary
Constants included from Writer
Instance Attribute Summary collapse
-
#content_types ⇒ Object
Returns the value of attribute content_types.
-
#doc_info ⇒ Object
Returns the value of attribute doc_info.
-
#footer ⇒ Object
Returns the value of attribute footer.
-
#header ⇒ Object
Returns the value of attribute header.
-
#images ⇒ Object
Returns the value of attribute images.
-
#init_rid ⇒ Object
Returns the value of attribute init_rid.
-
#relation_rids ⇒ Object
Returns the value of attribute relation_rids.
-
#rels_documents ⇒ Object
Returns the value of attribute rels_documents.
-
#sections ⇒ Object
Returns the value of attribute sections.
-
#toc ⇒ Object
Returns the value of attribute toc.
Class Method Summary collapse
Instance Method Summary collapse
- #add_footer(text = nil, options = {}) ⇒ Object
- #add_header(text, options = {}) ⇒ Object
- #information(options = {}) ⇒ Object
-
#initialize(options = {}, &block) ⇒ Document
constructor
A new instance of Document.
- #section(style = nil, &block) ⇒ Object
- #title_directory(option = {}) ⇒ Object
Methods included from Writer
#save, #write_header_and_footer
Constructor Details
#initialize(options = {}, &block) ⇒ Document
Returns a new instance of Document.
17 18 19 20 21 22 23 24 |
# File 'lib/rubyword/document.rb', line 17 def initialize(={}, &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_types ⇒ Object
Returns the value of attribute content_types.
7 8 9 |
# File 'lib/rubyword/document.rb', line 7 def content_types @content_types end |
#doc_info ⇒ Object
Returns the value of attribute doc_info.
9 10 11 |
# File 'lib/rubyword/document.rb', line 9 def doc_info @doc_info end |
#footer ⇒ Object
Returns the value of attribute footer.
8 9 10 |
# File 'lib/rubyword/document.rb', line 8 def @footer end |
#header ⇒ Object
Returns the value of attribute header.
8 9 10 |
# File 'lib/rubyword/document.rb', line 8 def header @header end |
#images ⇒ Object
Returns the value of attribute images.
7 8 9 |
# File 'lib/rubyword/document.rb', line 7 def images @images end |
#init_rid ⇒ Object
Returns the value of attribute init_rid.
6 7 8 |
# File 'lib/rubyword/document.rb', line 6 def init_rid @init_rid end |
#relation_rids ⇒ Object
Returns the value of attribute relation_rids.
7 8 9 |
# File 'lib/rubyword/document.rb', line 7 def relation_rids @relation_rids end |
#rels_documents ⇒ Object
Returns the value of attribute rels_documents.
7 8 9 |
# File 'lib/rubyword/document.rb', line 7 def rels_documents @rels_documents end |
#sections ⇒ Object
Returns the value of attribute sections.
6 7 8 |
# File 'lib/rubyword/document.rb', line 6 def sections @sections end |
#toc ⇒ Object
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 |
# File 'lib/rubyword/document.rb', line 12 def self.generate(filename, = {}, &block) rubyword = new(, &block) rubyword.save(filename) end |
Instance Method Details
#add_footer(text = nil, options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rubyword/document.rb', line 56 def (text=nil, ={}) @footer = { id: 1, text: text, rid: self.init_rid, text_align: [:align] || 'center', nums_type: [:nums_type], type: 'footer' } self.content_types << { "/word/footer1.xml" => "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" } self.rels_documents << { Id: "rId#{self.init_rid}", Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", Target: "footer1.xml" } self.init_rid = self.init_rid + 1 end |
#add_header(text, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rubyword/document.rb', line 37 def add_header(text, ={}) @header = { id: 1, text: text, rid: self.init_rid, text_align: [:align] || 'center', type: 'header' } self.content_types << { "/word/header1.xml" => "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" } self.rels_documents << { Id: "rId#{self.init_rid}", Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", Target: "header1.xml" } self.init_rid = self.init_rid + 1 end |
#information(options = {}) ⇒ Object
76 77 78 |
# File 'lib/rubyword/document.rb', line 76 def information(={}) @doc_info = end |
#section(style = nil, &block) ⇒ Object
26 27 28 29 30 |
# File 'lib/rubyword/document.rb', line 26 def section(style=nil, &block) @section = Element::Section.new(@sections.count + 1, style, self) self.sections << @section @section.instance_eval(&block) if block_given? end |
#title_directory(option = {}) ⇒ Object
32 33 34 35 |
# File 'lib/rubyword/document.rb', line 32 def title_directory(option= {}) @toc.merge!(open: true) @toc.merge!(option) end |