Class: OxmlMaker::Document
- Inherits:
-
Object
- Object
- OxmlMaker::Document
- Defined in:
- lib/oxml_maker/document.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(filename: nil, params: {}) {|_self| ... } ⇒ Document
constructor
A new instance of Document.
- #template ⇒ Object
Constructor Details
#initialize(filename: nil, params: {}) {|_self| ... } ⇒ Document
Returns a new instance of Document.
12 13 14 15 16 |
# File 'lib/oxml_maker/document.rb', line 12 def initialize(filename: nil, params: {}, &block) @filename = filename @params = params yield(self) if block_given? end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
10 11 12 |
# File 'lib/oxml_maker/document.rb', line 10 def filename @filename end |
#params ⇒ Object
Returns the value of attribute params.
9 10 11 |
# File 'lib/oxml_maker/document.rb', line 9 def params @params end |
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oxml_maker/document.rb', line 33 def create prepare_paths cleanup_temp_files ensure_directories write_document_xml zip_docx_folder convert_zip_to_docx copy_to_public cleanup_temp_files end |
#template ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/oxml_maker/document.rb', line 18 def template " <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n <w:document xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">\n <w:body>\n \#{generate_sections}\n <w:sectPr>\n <w:pgSz w:w='\#{params[:page_size][:width]}' w:h='\#{params[:page_size][:height]}'/>\n <w:pgMar w:top='\#{params[:page_margin][:top]}' w:right='\#{params[:page_margin][:right]}' w:bottom='\#{params[:page_margin][:bottom]}' w:left='\#{params[:page_margin][:left]}' w:header='\#{params[:page_margin][:header]}' w:footer='\#{params[:page_margin][:footer]}' w:gutter='\#{params[:page_margin][:gutter]}'/>\n </w:sectPr>\n </w:body>\n </w:document>\n XML\nend\n" |