class DocxReport::ContentFile
Attributes
name[R]
new_rels[R]
rels_name[R]
rels_xml[R]
xml[R]
Public Class Methods
new(name, zip)
click to toggle source
# File lib/docx_report/content_file.rb, line 5 def initialize(name, zip) @name = name @xml = Nokogiri::XML(zip.read(name)) @rels_name = "#{name.sub '/', '/_rels/'}.rels" @new_rels = false @rels_xml = Nokogiri::XML(if zip.entries.any? { |r| r.name == @rels_name } zip.read(@rels_name) else new_rels_xml end) end
Public Instance Methods
new_rels_xml()
click to toggle source
# File lib/docx_report/content_file.rb, line 23 def new_rels_xml @new_rels = true '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships'\ 'xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'\ '</Relationships>' end
new_uniqe_id()
click to toggle source
# File lib/docx_report/content_file.rb, line 17 def new_uniqe_id (@rels_xml.xpath('//*[@Id]').map do |e| e[:Id][3..-1].to_i if e.name == 'Relationship' end.compact.max || 0) + 1 end
rels_has_items?()
click to toggle source
# File lib/docx_report/content_file.rb, line 30 def rels_has_items? @rels_xml.xpath('//*[@Id]').any? end