Class: DocxGenerator::DSL::Document
- Inherits:
-
Object
- Object
- DocxGenerator::DSL::Document
- Defined in:
- lib/docx_generator/dsl/document.rb
Overview
Represent the docx document.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Filename of the document (without the docx extension).
Instance Method Summary collapse
-
#add(*objects) ⇒ DocxGenerator::DSL::Document
Add other objects to the document.
-
#initialize(filename) {|_self| ... } ⇒ Document
constructor
Create a new docx document.
-
#paragraph(options = {}) {|par| ... } ⇒ Object
Add a new paragraph to the document.
-
#save ⇒ Object
Save the docx document to the target location.
Constructor Details
#initialize(filename) {|_self| ... } ⇒ Document
Create a new docx document.
10 11 12 13 14 |
# File 'lib/docx_generator/dsl/document.rb', line 10 def initialize(filename, &block) @filename = filename + ".docx" @objects = [] # It contains all the DSL elements yield self if block end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Filename of the document (without the docx extension).
6 7 8 |
# File 'lib/docx_generator/dsl/document.rb', line 6 def filename @filename end |
Instance Method Details
#add(*objects) ⇒ DocxGenerator::DSL::Document
Add other objects to the document.
32 33 34 35 36 37 |
# File 'lib/docx_generator/dsl/document.rb', line 32 def add(*objects) objects.each do |object| @objects << object end self end |
#paragraph(options = {}) {|par| ... } ⇒ Object
Add a new paragraph to the document.
23 24 25 26 27 |
# File 'lib/docx_generator/dsl/document.rb', line 23 def paragraph( = {}, &block) par = DocxGenerator::DSL::Paragraph.new() yield par if block @objects << par end |
#save ⇒ Object
Save the docx document to the target location.
17 18 19 |
# File 'lib/docx_generator/dsl/document.rb', line 17 def save generate_archive(generate_content_types, generate_rels, generate_document) end |