Class: DocxManipulator::Content
- Inherits:
-
Object
- Object
- DocxManipulator::Content
- Defined in:
- lib/docx_manipulator/content.rb
Instance Attribute Summary collapse
-
#writes_to_file ⇒ Object
readonly
Returns the value of attribute writes_to_file.
Instance Method Summary collapse
-
#initialize(path, new_content, options = {}) ⇒ Content
constructor
A new instance of Content.
- #process(output) ⇒ Object
Constructor Details
#initialize(path, new_content, options = {}) ⇒ Content
Returns a new instance of Content.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/docx_manipulator/content.rb', line 7 def initialize(path, new_content, = {}) @writes_to_file = path @new_content = if new_content.kind_of?(File) new_content.read else new_content end if .include?(:xslt) xslt = Nokogiri::XSLT.parse([:xslt]) data = Nokogiri::XML.parse(@new_content) @new_content = xslt.transform(data).to_s end end |
Instance Attribute Details
#writes_to_file ⇒ Object (readonly)
Returns the value of attribute writes_to_file.
5 6 7 |
# File 'lib/docx_manipulator/content.rb', line 5 def writes_to_file @writes_to_file end |
Instance Method Details
#process(output) ⇒ Object
21 22 23 24 |
# File 'lib/docx_manipulator/content.rb', line 21 def process(output) output.put_next_entry @writes_to_file output.write @new_content end |