Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/melbourne.rb
Instance Method Summary collapse
-
#to_ast(name = '(eval)', line = 1) ⇒ Object
Creates an AST for a
Stringcontaining Ruby source code.
Instance Method Details
#to_ast(name = '(eval)', line = 1) ⇒ Object
Creates an AST for a String containing Ruby source code.
Example
'class Test; end'.to_ast # => <AST::Class:0x1017800f8...
Arguments
-
name: the name of the source (this is usuall the name of the file the code was read from); defaults to(eval) -
line: the starting line (if it’s not 1 for some reason); defaults to1
23 24 25 |
# File 'lib/melbourne.rb', line 23 def to_ast(name = '(eval)', line = 1) Melbourne::Parser.parse_string(self, name, line) end |