Class: Docxi::Word::Hyperlinks::Hyperlink

Inherits:
Object
  • Object
show all
Defined in:
lib/docxi/word/hyperlinks/hyperlink.rb

Defined Under Namespace

Classes: Hyperlink

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, options = {}) ⇒ Hyperlink

Returns a new instance of Hyperlink.



9
10
11
12
13
14
15
16
17
18
# File 'lib/docxi/word/hyperlinks/hyperlink.rb', line 9

def initialize(id,options={})
  @options = options
  @id = id

  if block_given?
    yield self
  else

  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/docxi/word/hyperlinks/hyperlink.rb', line 8

def id
  @id
end

#sequenceObject

Returns the value of attribute sequence.



8
9
10
# File 'lib/docxi/word/hyperlinks/hyperlink.rb', line 8

def sequence
  @sequence
end

Instance Method Details

#content_typeObject



25
26
27
# File 'lib/docxi/word/hyperlinks/hyperlink.rb', line 25

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


42
43
44
45
# File 'lib/docxi/word/hyperlinks/hyperlink.rb', line 42

def hyperlink(text,link)
  text = Hyperlink.new(text, link, id)
  @content << text
end

#render(zip) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/docxi/word/hyperlinks/hyperlink.rb', line 33

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

#set_sequence(sequence) ⇒ Object



20
21
22
23
# File 'lib/docxi/word/hyperlinks/hyperlink.rb', line 20

def set_sequence(sequence)
  @sequence = sequence
  self
end

#targetObject



29
30
31
# File 'lib/docxi/word/hyperlinks/hyperlink.rb', line 29

def target
  "document.xml"
end