Class: WikiChunk::WikiLink

Inherits:
WikiReference show all
Defined in:
app/models/chunks/wiki.rb

Overview

A wiki link is the top-level class for links that refers to another wiki page.

Direct Known Subclasses

Link, Word

Instance Attribute Summary collapse

Attributes inherited from WikiReference

#page_name

Attributes inherited from Chunk::Abstract

#text, #unmask_mode, #unmask_text

Class Method Summary collapse

Instance Method Summary collapse

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

Returns the value of attribute link_text.



28
29
30
# File 'app/models/chunks/wiki.rb', line 28

def link_text
  @link_text
end

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

#refpageObject

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

Returns:

  • (Boolean)


53
54
55
# File 'app/models/chunks/wiki.rb', line 53

def textile_url?
  not @textile_link_suffix.nil?
end