Class: Proc
- Inherits:
-
Object
- Object
- Proc
- Defined in:
- lib/proc_to_ast/parser_gem.rb
Instance Method Summary collapse
-
#to_ast ⇒ Parser::AST::Node
Proc AST.
- #to_raw_source(highlight: false) ⇒ Object
-
#to_source(highlight: false) ⇒ String
Proc source code.
Instance Method Details
#to_ast ⇒ Parser::AST::Node
Returns Proc AST.
93 94 95 96 97 |
# File 'lib/proc_to_ast/parser_gem.rb', line 93 def to_ast filename, linenum = source_location parser = ProcToAst::Parser.new parser.parse(filename, linenum) end |
#to_raw_source(highlight: false) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/proc_to_ast/parser_gem.rb', line 110 def to_raw_source(highlight: false) source = to_ast.loc.expression.source.force_encoding("UTF-8") if highlight ProcToAst::Parser.highlight(source) else source end end |
#to_source(highlight: false) ⇒ String
Returns proc source code.
101 102 103 104 105 106 107 108 |
# File 'lib/proc_to_ast/parser_gem.rb', line 101 def to_source(highlight: false) source = Unparser.unparse(to_ast) if highlight ProcToAst::Parser.highlight(source) else source end end |