Class: Fold::Engine
- Inherits:
-
Object
- Object
- Fold::Engine
- Defined in:
- lib/fold/engine.rb
Instance Method Summary collapse
-
#initialize(source) ⇒ Engine
constructor
A new instance of Engine.
- #lines ⇒ Object
-
#precompiler_class ⇒ Object
*** me hard.
- #render(context) ⇒ Object
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
#lines ⇒ Object
7 8 9 |
# File 'lib/fold/engine.rb', line 7 def lines @source.split(/\n/).reject{|line| line.blank?} end |
#precompiler_class ⇒ Object
*** 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 |