Class: Docxer::Word::Headers::Header
- Inherits:
-
Object
- Object
- Docxer::Word::Headers::Header
- Defined in:
- lib/docxer/word/headers/header.rb
Defined Under Namespace
Classes: Image
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#id ⇒ Object
Returns the value of attribute id.
-
#options ⇒ Object
Returns the value of attribute options.
-
#relationships ⇒ Object
writeonly
Sets the attribute relationships.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
Instance Method Summary collapse
- #content_type ⇒ Object
- #image(image, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Header
constructor
A new instance of Header.
- #render(zip) ⇒ Object
- #target ⇒ Object
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 = @content = [] @relationships = [] if block_given? yield self else end end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
8 9 10 |
# File 'lib/docxer/word/headers/header.rb', line 8 def content @content end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/docxer/word/headers/header.rb', line 8 def id @id end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/docxer/word/headers/header.rb', line 8 def @options end |
#relationships=(value) ⇒ Object
Sets the attribute relationships
8 9 10 |
# File 'lib/docxer/word/headers/header.rb', line 8 def relationships=(value) @relationships = value end |
#sequence ⇒ Object
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_type ⇒ Object
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, ={}) img = Image.new(image, ) @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 |
#target ⇒ Object
25 26 27 |
# File 'lib/docxer/word/headers/header.rb', line 25 def target "header#{id}.xml" end |