Class: PowerPointer::Relationships
- Inherits:
-
Object
- Object
- PowerPointer::Relationships
- Defined in:
- lib/powerpointer/relationships.rb
Instance Method Summary collapse
- #add(id, type, target) ⇒ Object
- #export_xml(folder, package) ⇒ Object
- #get_filename ⇒ Object
-
#initialize(filename) ⇒ Relationships
constructor
A new instance of Relationships.
Constructor Details
#initialize(filename) ⇒ Relationships
Returns a new instance of Relationships.
3 4 5 6 |
# File 'lib/powerpointer/relationships.rb', line 3 def initialize(filename) @filename = filename @relationships = [] end |
Instance Method Details
#add(id, type, target) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/powerpointer/relationships.rb', line 8 def add(id, type, target) relationship = { :id => id, :type => type, :target => target } @relationships << relationship end |
#export_xml(folder, package) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/powerpointer/relationships.rb', line 21 def export_xml(folder, package) # Export me export = ExportFile.new(folder + "_rels/", @filename + ".rels") export << XML_HEADER.dup export << "<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">" @relationships.each do |relationship| export << "<Relationship Id=\"#{relationship[:id]}\" Type=\"#{relationship[:type]}\" Target=\"#{relationship[:target]}\" />" end export << "</Relationships>" package.add export # Add references to me package.add_content_type ContentTypes::Override.new(export.get_full_path, "application/vnd.openxmlformats-package.relationships+xml") end |
#get_filename ⇒ Object
17 18 19 |
# File 'lib/powerpointer/relationships.rb', line 17 def get_filename @filename end |