Class: RubyTransform::Transformer

Inherits:
Object
  • Object
show all
Includes:
TransformerHelpers
Defined in:
lib/ruby_transform/transformer.rb

Overview

Takes a raw S-expression and transforms it (replaces the node with the return value of the process method). This is meant to be subclassed, and in the process method you should either return a transformed version of the node, or just call super which will leave the node in place and iterate through the children.

Instance Method Summary collapse

Methods included from TransformerHelpers

#sexp?

Instance Method Details

#transform(sexp) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/ruby_transform/transformer.rb', line 12

def transform(sexp)
  if sexp.is_a?(Sexp)
    Sexp.new(*([sexp.kind] + sexp.body.map {|c| transform(c) }))
  else
    sexp
  end
end