class DocxReport::Hyperlink
Attributes
file[RW]
id[RW]
target[RW]
Public Class Methods
new(target, file, id = nil)
click to toggle source
# File lib/docx_report/hyperlink.rb, line 5 def initialize(target, file, id = nil) @target = target @file = file if id.nil? generate_id else @id = id file.rels_xml.xpath("//*[@Id='#{id}']").first[:Target] = target end end
Private Instance Methods
generate_id()
click to toggle source
# File lib/docx_report/hyperlink.rb, line 18 def generate_id @id = "rId#{file.new_uniqe_id}" file.rels_xml.children.first << hyperlink_rels end
hyperlink_rels()
click to toggle source
# File lib/docx_report/hyperlink.rb, line 23 def hyperlink_rels Nokogiri::XML( format('<Relationship Id="%s" Type="http://schemas.openxmlformats'\ '.org/officeDocument/2006/relationships/hyperlink" Target="%s" '\ 'TargetMode="External"/>', @id, @target)).children.first end