Class: WikiChunk::Word

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

Overview

This chunk matches a WikiWord. WikiWords can be escaped by prepending a ‘'. When this is the case, the escaped_text method will return the WikiWord instead of the usual nil. The page_name method returns the matched WikiWord.

Instance Attribute Summary collapse

Attributes inherited from Chunk::Abstract

#text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WikiLink

#mask, #regexp, #revert, #unmask

Methods inherited from Chunk::Abstract

#mask, #post_mask, #pre_mask, #revert, #unmask

Constructor Details

#initialize(match_data) ⇒ Word

Returns a new instance of Word.



44
45
46
47
48
# File 'app/models/chunks/wiki.rb', line 44

def initialize(match_data)
  super(match_data)
  @escape = match_data[1]
  @page_name = match_data[2]
end

Instance Attribute Details

#page_nameObject (readonly)

Returns the value of attribute page_name.



42
43
44
# File 'app/models/chunks/wiki.rb', line 42

def page_name
  @page_name
end

Class Method Details

.patternObject



38
39
40
# File 'app/models/chunks/wiki.rb', line 38

def self.pattern
  Regexp.new('(\\\\)?(' + WikiWords::WIKI_WORD_PATTERN + ')\b', 0, "utf-8")
end

Instance Method Details

#escaped_textObject



50
# File 'app/models/chunks/wiki.rb', line 50

def escaped_text() (@escape.nil? ? nil : page_name) end


51
# File 'app/models/chunks/wiki.rb', line 51

def link_text() WikiWords.separate(page_name) end