Class: WikiChunk::WikiLink
- Inherits:
-
WikiReference
- Object
- Chunk::Abstract
- WikiReference
- WikiChunk::WikiLink
- Defined in:
- app/models/chunks/wiki.rb
Overview
A wiki link is the top-level class for links that refers to another wiki page.
Instance Attribute Summary collapse
-
#link_text ⇒ Object
readonly
Returns the value of attribute link_text.
-
#link_type ⇒ Object
readonly
Returns the value of attribute link_type.
Attributes inherited from WikiReference
Attributes inherited from Chunk::Abstract
#text, #unmask_mode, #unmask_text
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(match_data, content) ⇒ WikiLink
constructor
A new instance of WikiLink.
-
#refpage ⇒ Object
the referenced page.
- #textile_url? ⇒ Boolean
Methods inherited from Chunk::Abstract
#escaped?, #id, inherited, #mask, mask_re, mask_string, #rendered?, #revert, #unmask
Constructor Details
#initialize(match_data, content) ⇒ WikiLink
Returns a new instance of WikiLink.
30 31 32 33 |
# File 'app/models/chunks/wiki.rb', line 30 def initialize(match_data, content) super @link_type = :show end |
Instance Attribute Details
#link_text ⇒ Object (readonly)
Returns the value of attribute link_text.
28 29 30 |
# File 'app/models/chunks/wiki.rb', line 28 def link_text @link_text end |
#link_type ⇒ Object (readonly)
Returns the value of attribute link_type.
28 29 30 |
# File 'app/models/chunks/wiki.rb', line 28 def link_type @link_type end |
Class Method Details
.apply_to(content) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/chunks/wiki.rb', line 35 def self.apply_to(content) content.gsub!( self.pattern ) do |matched_text| chunk = self.new($~, content) if chunk.textile_url? # do not substitute matched_text else content.add_chunk(chunk) chunk.mask end end end |
Instance Method Details
#refpage ⇒ Object
the referenced page
49 50 51 |
# File 'app/models/chunks/wiki.rb', line 49 def refpage @content.web.pages[@page_name] end |
#textile_url? ⇒ Boolean
53 54 55 |
# File 'app/models/chunks/wiki.rb', line 53 def textile_url? not @textile_link_suffix.nil? end |