Instantly share code, notes, and snippets.

Embed
What would you like to do?
#console
sudo gem install ruby_parser
#irb
require 'rubygems' ; require 'ruby_parser' ; require 'pp'
pp RubyParser.new.parse "class C
def meth(arg)
arg * 2
end
end"
#=>
s(:class,
:C,
nil,
s(:scope,
s(:defn,
:meth,
s(:args, :arg),
s(:scope,
s(:block,
s(:return, s(:call, s(:lvar, :arg), :*, s(:arglist, s(:lit, 2)))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment