class Proc
Public Instance Methods
to_ast()
click to toggle source
@return [Parser::AST::Node] Proc
AST
# File lib/proc_to_ast.rb, line 84 def to_ast filename, linenum = source_location parser = ProcToAst::Parser.new parser.parse(filename, linenum) end
to_raw_source(highlight: false)
click to toggle source
# File lib/proc_to_ast.rb, line 101 def to_raw_source(highlight: false) source = to_ast.loc.expression.source if highlight CodeRay.scan(source, :ruby).terminal else source end end
to_source(highlight: false)
click to toggle source
@param highlight [Boolean] enable output highlight @return [String] proc source code
# File lib/proc_to_ast.rb, line 92 def to_source(highlight: false) source = Unparser.unparse(to_ast) if highlight CodeRay.scan(source, :ruby).terminal else source end end