Class: Fold::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/fold/engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Engine

Returns a new instance of Engine.



3
4
5
# File 'lib/fold/engine.rb', line 3

def initialize source
  @source= source
end

Instance Method Details

#linesObject



7
8
9
# File 'lib/fold/engine.rb', line 7

def lines
  @source.split(/\n/).reject{|line| line.blank?}
end

#precompiler_classObject

*** me hard



19
20
21
# File 'lib/fold/engine.rb', line 19

def precompiler_class
  @precompiler||= instance_eval "#{self.class.to_s.split(/::/).first}::Precompiler"
end

#render(context) ⇒ Object



11
12
13
14
15
16
# File 'lib/fold/engine.rb', line 11

def render context
  precompiler = precompiler_class.new
  precompiler.fold(lines).children.map do |child| 
    child.render(precompiler)
  end
end