Module: Rubyword::Writer
- Included in:
- Document
- Defined in:
- lib/rubyword/writer.rb,
lib/rubyword/writer/part/toc.rb,
lib/rubyword/writer/part/base.rb,
lib/rubyword/writer/part/rels.rb,
lib/rubyword/writer/part/theme.rb,
lib/rubyword/writer/style/base.rb,
lib/rubyword/writer/style/word.rb,
lib/rubyword/writer/part/footer.rb,
lib/rubyword/writer/part/header.rb,
lib/rubyword/writer/part/styles.rb,
lib/rubyword/writer/part/document.rb,
lib/rubyword/writer/part/settings.rb,
lib/rubyword/writer/style/section.rb,
lib/rubyword/writer/part/numbering.rb,
lib/rubyword/writer/part/font_table.rb,
lib/rubyword/writer/style/paragraph.rb,
lib/rubyword/writer/part/web_settings.rb,
lib/rubyword/writer/part/content_types.rb,
lib/rubyword/writer/part/doc_props_app.rb,
lib/rubyword/writer/part/rels_document.rb,
lib/rubyword/writer/part/doc_props_core.rb,
lib/rubyword/writer/part/doc_props_custom.rb
Defined Under Namespace
Constant Summary collapse
- DocumentBaseFile =
word base file
{ 'ContentTypes' => '[Content_Types].xml', 'Rels' => '_rels/.rels', 'DocPropsApp' => 'docProps/app.xml', 'DocPropsCore' => 'docProps/core.xml', 'DocPropsCustom' => 'docProps/custom.xml', 'RelsDocument' => 'word/_rels/document.xml.rels', 'Document' => 'word/document.xml', 'Styles' => 'word/styles.xml', 'Numbering' => 'word/numbering.xml', 'Settings' => 'word/settings.xml', 'WebSettings' => 'word/webSettings.xml', 'FontTable' => 'word/fontTable.xml', 'Theme' => 'word/theme/theme1.xml' }.freeze
Instance Method Summary collapse
Instance Method Details
#save(filename = 'document.docx') ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubyword/writer.rb', line 38 def save(filename = 'document.docx') buffer = Zip::OutputStream.write_buffer do |zio| (zio) # write image self.images.each do |image| source = open(image[:path]).read zio.put_next_entry("word/media/#{image[:filename]}") zio.write(source) end DocumentBaseFile.each do |helper_method, entry| obj = eval "Part::#{helper_method}.new(self)" source = obj.write zio.put_next_entry(entry) zio.write(source) end end file = File.new(filename,'wb') file.write(buffer.string) file.close end |
#write_header_and_footer(zio) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rubyword/writer.rb', line 61 def (zio) header = self.header = self. if header elmFile = "word/header#{header[:id]}.xml" obj = Part::Header.new(self) source = obj.write zio.put_next_entry(elmFile) zio.write(source) end if elmFile = "word/footer#{[:id]}.xml" obj = Part::Footer.new(self) source = obj.write zio.put_next_entry(elmFile) zio.write(source) end end |