Class: Rubyword::Element::Link
- Defined in:
- lib/rubyword/element/link.rb
Instance Attribute Summary collapse
-
#links ⇒ Object
Returns the value of attribute links.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Rubyword::Element::Base
Instance Attribute Details
#links ⇒ Object
Returns the value of attribute links.
5 6 7 |
# File 'lib/rubyword/element/link.rb', line 5 def links @links end |
Instance Method Details
#save(text, link, style) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rubyword/element/link.rb', line 6 def save(text, link, style) @links ||= Queue.new return if text.nil? @rubyword.rels_documents << { Id: "rId#{@rubyword.init_rid}", Type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', Target: link, TargetMode: 'External' } @links << { rId: @rubyword.init_rid, text: text, link: link } @rubyword.init_rid = @rubyword.init_rid + 1 end |
#write(section = nil, xml = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubyword/element/link.rb', line 19 def write(section=nil, xml=nil) @xml = xml link = self.links.pop @xml.send('w:p') { @xml.send('hyperlink', 'r:id' => "rId#{link[:rId]}", 'w:history' => '1') { @xml.send('w:r') { # TODO: add style @xml.send('w:rPr') @xml.send('w:t', {'xml:space' => 'preserve'}, link[:text]) } } } end |