Class: JinyuDebugTools::CodeParser::CodeNode

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/code_parser.rb

Instance Method Summary collapse

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_indexObject



34
35
36
# File 'lib/utils/code_parser.rb', line 34

def get_index
  @index
end

#get_levelObject



30
31
32
# File 'lib/utils/code_parser.rb', line 30

def get_level
  @level
end

#get_nameObject



10
11
12
# File 'lib/utils/code_parser.rb', line 10

def get_name
  @name
end

#get_parentObject



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_hashObject



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_sObject



42
43
44
# File 'lib/utils/code_parser.rb', line 42

def to_s
  @name
end