Class: Walrus::WalrusGrammar::RubyDirective

Inherits:
Object
  • Object
show all
Defined in:
lib/walrus/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



23
24
25
26
27
28
29
# File 'lib/walrus/walrus_grammar/ruby_directive.rb', line 23

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