sexp

sexp(src, filename = '-', lineno = 1)
Class Public methods
EXPERIMENTAL

Parses src and create S-exp tree. Returns more readable tree rather than ::sexp_raw. This method is mainly for developer use.

require 'ripper'
require 'pp'

pp Ripper.sexp("def m(a) nil end")
  #=> [:program,
       [[:def,
        [:@ident, "m", [1, 4]],
        [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil, nil]],
        [:bodystmt, [[:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]]
doc_ruby_on_rails
2015-05-08 13:47:13
Comments
Leave a Comment

Please login to continue.