Class: Walrus::Grammar::RubyDirective

Inherits:
Directive
  • Object
show all
Defined in:
lib/walrus/grammar/ruby_directive.rb

Instance Method Summary collapse

Instance Method Details

#compile(options = {}) ⇒ Object

TODO: could make a #rubyecho method that did an “accumulate do” instead of instance_eval



30
31
32
33
34
35
36
37
38
# File 'lib/walrus/grammar/ruby_directive.rb', line 30

def compile options = {}
  # possible problem here is that the compiler will indent each line for
  # us, possibly breaking here docs etc
  # seeing as it is going to be indented anyway, I add some additional
  # indenting here for pretty printing purposes
  compiled = "instance_eval do # Ruby directive\n"
  @content.to_s.each { |line| compiled << '  ' + line }
  compiled << "end\n"
end