Skip to content

Instantly share code, notes, and snippets.

Created May 31, 2013 12:39
Show Gist options
  • Save anonymous/5684725 to your computer and use it in GitHub Desktop.
Save anonymous/5684725 to your computer and use it in GitHub Desktop.
require 'parser/runner'
module Parser
class Runner::RubyParse < Parser::Runner
class PrawnProcessor < Parser::AST::Processor
def on_send(node)
p node.to_s
node.children.each do |child_node|
p child_node.class
p child_node.type
end
end
def on_if(node)
p "Nice, an if node\n"
end
end
private
def runner_name
'ruby-parse'
end
def process(buffer)
ast = @parser.parse(buffer)
PrawnProcessor.new.process(ast)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment