Class: ASTree
- Inherits:
-
Object
- Object
- ASTree
- Defined in:
- lib/astree.rb,
lib/astree/version.rb,
lib/astree/pretty_node.rb
Defined Under Namespace
Classes: PrettyNode
Constant Summary collapse
- SPACE_SIZE =
7- T_LINE =
'├─────'.freeze
- I_LINE =
'│'.freeze
- L_LINE =
'└─────'.freeze
- VERSION =
'1.1.1'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source_code) ⇒ ASTree
constructor
A new instance of ASTree.
- #to_s ⇒ Object
Constructor Details
#initialize(source_code) ⇒ ASTree
Returns a new instance of ASTree.
17 18 19 20 |
# File 'lib/astree.rb', line 17 def initialize(source_code) ast = RubyVM::AbstractSyntaxTree.parse(source_code) @buffer = traverse(ast) end |
Class Method Details
.parse(source_code) ⇒ Object
13 14 15 |
# File 'lib/astree.rb', line 13 def self.parse(source_code) new(source_code) end |
Instance Method Details
#to_s ⇒ Object
22 23 24 |
# File 'lib/astree.rb', line 22 def to_s @buffer end |