Class: Wiki::Api::PageLink
- Inherits:
-
Object
- Object
- Wiki::Api::PageLink
- Defined in:
- lib/wiki/api/page_link.rb
Overview
Link on a wiki page (a href=xxx)
Instance Attribute Summary collapse
-
#element ⇒ Object
Returns the value of attribute element.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(options = {}) ⇒ PageLink
constructor
A new instance of PageLink.
- #title ⇒ Object
- #to_text ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PageLink
Returns a new instance of PageLink.
9 10 11 12 |
# File 'lib/wiki/api/page_link.rb', line 9 def initialize( = {}) self.element = [:element] if .include?(:element) self.parent = [:parent] if .include?(:parent) end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
7 8 9 |
# File 'lib/wiki/api/page_link.rb', line 7 def element @element end |
#parent ⇒ Object
Returns the value of attribute parent.
7 8 9 |
# File 'lib/wiki/api/page_link.rb', line 7 def parent @parent end |
Instance Method Details
#html ⇒ Object
32 33 34 |
# File 'lib/wiki/api/page_link.rb', line 32 def html "<a href=\"#{uri}\" alt=\"#{title}\">#{title}</a>" end |
#title ⇒ Object
25 26 27 28 29 30 |
# File 'lib/wiki/api/page_link.rb', line 25 def title # skip links with no title return '' if element.attributes['title'].nil? element.attributes['title'].value end |
#to_text ⇒ Object
14 15 16 |
# File 'lib/wiki/api/page_link.rb', line 14 def to_text Wiki::Api::Util.element_to_text(element) end |
#uri ⇒ Object
18 19 20 21 22 23 |
# File 'lib/wiki/api/page_link.rb', line 18 def uri # lookup the root parent, and get connector info host = Wiki::Api::Util.parent_root(self).connect.uri href_value = element.attributes['href'].value URI.parse("#{host}#{href_value}") end |