Class: Docxer::Word::Headers::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/docxer/word/headers/header.rb

Defined Under Namespace

Classes: Image

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Header

Returns a new instance of Header.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/docxer/word/headers/header.rb', line 9

def initialize(options={})
  @options = options
  @content = []
  @relationships = []

  if block_given?
    yield self
  else

  end
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



8
9
10
# File 'lib/docxer/word/headers/header.rb', line 8

def content
  @content
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/docxer/word/headers/header.rb', line 8

def id
  @id
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/docxer/word/headers/header.rb', line 8

def options
  @options
end

#relationships=(value) ⇒ Object

Sets the attribute relationships

Parameters:

  • value

    the value to set the attribute relationships to.



8
9
10
# File 'lib/docxer/word/headers/header.rb', line 8

def relationships=(value)
  @relationships = value
end

#sequenceObject

Returns the value of attribute sequence.



8
9
10
# File 'lib/docxer/word/headers/header.rb', line 8

def sequence
  @sequence
end

Instance Method Details

#content_typeObject



21
22
23
# File 'lib/docxer/word/headers/header.rb', line 21

def content_type
  "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
end

#image(image, options = {}) ⇒ Object



39
40
41
42
43
44
# File 'lib/docxer/word/headers/header.rb', line 39

def image(image, options={})
  img = Image.new(image, options)
  @content << img
  @relationships << image
  img
end

#render(zip) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/docxer/word/headers/header.rb', line 29

def render(zip)
  zip.put_next_entry("word/#{target}")
  zip.write(Docxer.to_xml(document))

  if !@relationships.empty?
    zip.put_next_entry("word/_rels/#{target}.rels")
    zip.write(Docxer.to_xml(relationships))
  end
end

#targetObject



25
26
27
# File 'lib/docxer/word/headers/header.rb', line 25

def target
  "header#{id}.xml"
end