Class: DocxManipulator::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/docx_manipulator/content.rb

Instance Method Summary collapse

Instance Method Details

#process(output) ⇒ Object



22
23
24
25
# File 'lib/docx_manipulator/content.rb', line 22

def process(output)
  output.put_next_entry 'word/document.xml'
  output.write @new_content
end

#set(new_content, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/docx_manipulator/content.rb', line 5

def set(new_content, options = {})
  @new_content = if new_content.kind_of?(File)
                   new_content.read
                 else
                   new_content
                 end
  if options.include?(:xslt)
    xslt = Nokogiri::XSLT.parse(options[:xslt])
    data = Nokogiri::XML.parse(@new_content)
    @new_content = xslt.transform(data).to_s
  end
end

#writes_to_filesObject



18
19
20
# File 'lib/docx_manipulator/content.rb', line 18

def writes_to_files
  ['word/document.xml']
end