Class: Rabbit::Parser::RD::Ext::Base

Inherits:
Object
  • Object
show all
Extended by:
ERB::Util
Includes:
ERB::Util, Element
Defined in:
lib/rabbit/parser/rd/ext/base.rb

Direct Known Subclasses

BlockVerbatim, InlineVerbatim, Refer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_extension(name) ⇒ Object



21
22
23
# File 'lib/rabbit/parser/rd/ext/base.rb', line 21

def add_extension(name)
  extensions.push(name)
end

.extensionsObject



25
26
27
# File 'lib/rabbit/parser/rd/ext/base.rb', line 25

def extensions
  self::EXTENSIONS
end

.inherited(klass) ⇒ Object



17
18
19
# File 'lib/rabbit/parser/rd/ext/base.rb', line 17

def inherited(klass)
  klass.const_set("EXTENSIONS", [])
end

.method_added(name) ⇒ Object



29
30
31
32
33
# File 'lib/rabbit/parser/rd/ext/base.rb', line 29

def method_added(name)
  if /^ext_/ =~ name.to_s
    add_extension(name.to_s)
  end
end

Instance Method Details

#apply(label, source, content, visitor) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rabbit/parser/rd/ext/base.rb', line 36

def apply(label, source, content, visitor)
  result = nil
  extensions.find do |entry|
    begin
      result = __send__(entry, label, source, content, visitor)
    rescue NameError
      visitor.logger.error($!)
      raise
    end
  end
  result
end

#extensionsObject



49
50
51
# File 'lib/rabbit/parser/rd/ext/base.rb', line 49

def extensions
  self.class.extensions
end