Class: JinyuDebugTools::CodeParser::CodeNode
- Inherits:
-
Object
- Object
- JinyuDebugTools::CodeParser::CodeNode
- Defined in:
- lib/utils/code_parser.rb
Instance Method Summary collapse
- #append_child(child_node) ⇒ Object
- #delete_child(child_node) ⇒ Object
- #get_index ⇒ Object
- #get_level ⇒ Object
- #get_name ⇒ Object
- #get_parent ⇒ Object
-
#initialize(name) ⇒ CodeNode
constructor
A new instance of CodeNode.
- #set_index(list_index) ⇒ Object
- #set_level(level) ⇒ Object
- #set_parent(parent_node) ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ CodeNode
Returns a new instance of CodeNode.
5 6 7 8 |
# File 'lib/utils/code_parser.rb', line 5 def initialize(name) @name = name @children = [] end |
Instance Method Details
#append_child(child_node) ⇒ Object
22 23 24 |
# File 'lib/utils/code_parser.rb', line 22 def append_child(child_node) @children << child_node end |
#delete_child(child_node) ⇒ Object
52 53 54 |
# File 'lib/utils/code_parser.rb', line 52 def delete_child(child_node) @children.delete(child_node) end |
#get_index ⇒ Object
34 35 36 |
# File 'lib/utils/code_parser.rb', line 34 def get_index @index end |
#get_level ⇒ Object
30 31 32 |
# File 'lib/utils/code_parser.rb', line 30 def get_level @level end |
#get_name ⇒ Object
10 11 12 |
# File 'lib/utils/code_parser.rb', line 10 def get_name @name end |
#get_parent ⇒ Object
14 15 16 |
# File 'lib/utils/code_parser.rb', line 14 def get_parent @parent end |
#set_index(list_index) ⇒ Object
38 39 40 |
# File 'lib/utils/code_parser.rb', line 38 def set_index(list_index) @index = list_index end |
#set_level(level) ⇒ Object
26 27 28 |
# File 'lib/utils/code_parser.rb', line 26 def set_level(level) @level = level end |
#set_parent(parent_node) ⇒ Object
18 19 20 |
# File 'lib/utils/code_parser.rb', line 18 def set_parent(parent_node) @parent = parent_node end |
#to_hash ⇒ Object
46 47 48 49 50 |
# File 'lib/utils/code_parser.rb', line 46 def to_hash children = @children.map(&:to_hash) children = nil if children.empty? {@name => children} end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/utils/code_parser.rb', line 42 def to_s @name end |