Class: ODF::Hyperlink

Inherits:
ParagraphContainer show all
Defined in:
lib/odf/hyperlink.rb

Instance Method Summary collapse

Methods inherited from ParagraphContainer

#<<, #content_parts, #content_parts_xml, #link, #method_missing, #span, #tab

Methods inherited from Container

contains, create

Constructor Details

#initialize(first, second = {}) ⇒ Hyperlink

Returns a new instance of Hyperlink.



25
26
27
28
29
30
31
32
# File 'lib/odf/hyperlink.rb', line 25

def initialize(first, second = {})
  if second.instance_of?(Hash) && second.empty?
    @href = first
  else
    span(first)
    @href = second.instance_of?(Hash) ? second[:href] : second
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ODF::ParagraphContainer

Instance Method Details

#xmlObject



34
35
36
37
38
# File 'lib/odf/hyperlink.rb', line 34

def xml
  Builder::XmlMarkup.new.text:a, 'xlink:href' => @href do |a|
    a << content_parts_xml
  end
end