Class: WikiSymbol

Inherits:
Chunk::Abstract show all
Defined in:
app/models/chunks/wiki_symbols.rb

Instance Attribute Summary collapse

Attributes inherited from Chunk::Abstract

#revision, #text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Chunk::Abstract

#mask, #post_mask, #pre_mask, #revert

Constructor Details

#initialize(match_data, revision) ⇒ WikiSymbol

Returns a new instance of WikiSymbol.



7
8
9
10
# File 'app/models/chunks/wiki_symbols.rb', line 7

def initialize(match_data, revision)
  super(match_data, revision)
  @symbol_code = match_data[1]
end

Instance Attribute Details

#symbol_codeObject

Returns the value of attribute symbol_code.



5
6
7
# File 'app/models/chunks/wiki_symbols.rb', line 5

def symbol_code
  @symbol_code
end

Class Method Details

.patternObject



3
# File 'app/models/chunks/wiki_symbols.rb', line 3

def self.pattern() /<:(.*?)>/ end

Instance Method Details

#unmask(content) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'app/models/chunks/wiki_symbols.rb', line 12

def unmask(content)
  tag = case symbol_code
    when 'cbx'  then '<input type="checkbox" disabled />'
    when 'cbxc' then '<input type="checkbox" disabled checked />'
    else symbol_code
  end

  return self if content.gsub!( Regexp.new(mask(content)), tag )
end