Class: PPTX::OPC::Relationships

Inherits:
BasePart
  • Object
show all
Defined in:
lib/pptx/opc/relationships.rb

Constant Summary collapse

NS =
'http://schemas.openxmlformats.org/package/2006/relationships'

Instance Method Summary collapse

Methods inherited from BasePart

#content_type, #doc, #initialize, #marshal, #part_name, #template

Constructor Details

This class inherits a constructor from PPTX::OPC::BasePart

Instance Method Details

#add(relative_part_name, type) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pptx/opc/relationships.rb', line 15

def add(relative_part_name, type)
  ref_id = "rId#{SecureRandom.hex(10)}"

  relationship = Nokogiri::XML::Node.new('Relationship', doc)
  relationship['Id'] = ref_id
  relationship['Target'] = relative_part_name
  relationship['Type'] = type
  list_xml.add_child(relationship)

  ref_id
end

#base_xmlObject



8
9
10
11
12
13
# File 'lib/pptx/opc/relationships.rb', line 8

def base_xml
  '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    </Relationships>
  '''
end

#list_xmlObject



27
28
29
# File 'lib/pptx/opc/relationships.rb', line 27

def list_xml
  @list_xml ||= doc.xpath('r:Relationships', r: NS).first
end