Class: Docxer::Relationships

Inherits:
Object
  • Object
show all
Defined in:
lib/docxer/relationships.rb,
lib/docxer/relationships/relationship.rb

Defined Under Namespace

Classes: Relationship

Constant Summary collapse

@@prefix =
'rId'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRelationships

Returns a new instance of Relationships.



9
10
11
12
13
14
15
# File 'lib/docxer/relationships.rb', line 9

def initialize
  @relationships = []
  @counter = 0
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", "word/document.xml")
  add("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties", "docProps/core.xml")
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", "docProps/app.xml")
end

Instance Attribute Details

#relationshipsObject

Returns the value of attribute relationships.



7
8
9
# File 'lib/docxer/relationships.rb', line 7

def relationships
  @relationships
end

Instance Method Details

#add(type, target) ⇒ Object



17
18
19
20
21
# File 'lib/docxer/relationships.rb', line 17

def add(type, target)
  relationship = create_relationship(sequence, type, target)
  @relationships << relationship if relationship
  relationship
end

#render(zip) ⇒ Object



23
24
25
26
# File 'lib/docxer/relationships.rb', line 23

def render(zip)
  zip.put_next_entry('_rels/.rels')
  zip.write(Docxer.to_xml(document))
end