Class: Smartgen::Engine::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/smartgen/engines/base.rb

Overview

Base class for engines.

An engine process markup files, converting them to HTML.

Direct Known Subclasses

ERB, Markdown, Textile

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



12
13
14
# File 'lib/smartgen/engines/base.rb', line 12

def initialize
  self.pre_processors ||= []
end

Class Method Details

.register(processor) ⇒ Object

Registers a pre processor for this engine.



28
29
30
31
# File 'lib/smartgen/engines/base.rb', line 28

def register(processor)
  self.pre_processors ||= []
  self.pre_processors << processor
end

Instance Method Details

#process(body, metadata = Smartgen::ObjectHash.new) ⇒ Object

Process a file, calling each pre processor if any.



17
18
19
# File 'lib/smartgen/engines/base.rb', line 17

def process(body, =Smartgen::ObjectHash.new)
  parse(pre_process(body, ), )
end

#supported?(extension) ⇒ Boolean

Returns true if the given extension is supported by this engine.

Returns:

  • (Boolean)


22
23
24
# File 'lib/smartgen/engines/base.rb', line 22

def supported?(extension)
  extensions.include?(extension)
end