Class: RubyDocx::Elements::Link
- Defined in:
- lib/ruby_docx/elements/link.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#href ⇒ Object
Returns the value of attribute href.
-
#html_content ⇒ Object
Returns the value of attribute html_content.
Attributes inherited from Element
Instance Method Summary collapse
Methods inherited from Element
#elements, #initialize, #inspect, #to_xml
Constructor Details
This class inherits a constructor from RubyDocx::Elements::Element
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/ruby_docx/elements/link.rb', line 3 def content @content end |
#href ⇒ Object
Returns the value of attribute href.
3 4 5 |
# File 'lib/ruby_docx/elements/link.rb', line 3 def href @href end |
#html_content ⇒ Object
Returns the value of attribute html_content.
3 4 5 |
# File 'lib/ruby_docx/elements/link.rb', line 3 def html_content @html_content end |
Instance Method Details
#element ⇒ Object
5 6 7 |
# File 'lib/ruby_docx/elements/link.rb', line 5 def element @element ||= @node.children.first end |
#replace(url) ⇒ Object
33 34 35 |
# File 'lib/ruby_docx/elements/link.rb', line 33 def replace(url) self.href = url end |
#to_html ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby_docx/elements/link.rb', line 37 def to_html if !self.href "#{self.html_content}" elsif self.href.to_s =~ /^http/ "<a href=\"#{self.href}\">#{self.html_content}</a>" else "<a href=\"##{self.href}\">#{self.html_content}</a>" end end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/ruby_docx/elements/link.rb', line 47 def to_s self.content.to_s end |