class DocxReport::Report
Attributes
fields[R]
Public Class Methods
new(template_path)
click to toggle source
# File lib/docx_report/report.rb, line 8 def initialize(template_path) @template_path = template_path @fields = [] @tables = [] end
Public Instance Methods
add_table(name, collection = nil, has_header = false) { |table| ... }
click to toggle source
# File lib/docx_report/report.rb, line 14 def add_table(name, collection = nil, has_header = false) raise 'duplicate table name' if @tables.any? { |t| t.name == name } table = Table.new name, has_header @tables << table yield table table.load_records collection if collection end
generate_docx(filename = nil, template_path = nil)
click to toggle source
# File lib/docx_report/report.rb, line 22 def generate_docx(filename = nil, template_path = nil) document = Document.new template_path || @template_path apply_changes document if filename.nil? document.save_to_memory else document.save_to_file filename end end
Private Instance Methods
apply_changes(document)
click to toggle source
# File lib/docx_report/report.rb, line 34 def apply_changes(document) parser = Parser.new document parser.fill_all_tables @tables parser.replace_all_fields @fields end