Module: Pentest::RubyParser
- Defined in:
- lib/pentest/ruby_parser.rb
Class Method Summary collapse
-
.get_sexp(method) ⇒ Object
Get S-expression of specified method.
Class Method Details
.get_sexp(method) ⇒ Object
Get S-expression of specified method. Return nil if something went wrong.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pentest/ruby_parser.rb', line 7 def get_sexp(method) file, loc = method.source_location ast = ::RubyParser.new.parse File.read(file), file ast.each do |exp| next unless Sexp === exp next unless exp[0] == :defn if exp.line == loc return exp end end nil end |