Class: ASTDistance::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ast_distance/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index:, type:) ⇒ Node



6
7
8
9
10
# File 'lib/ast_distance/node.rb', line 6

def initialize(index:, type:)
  @index = index
  @type = type
  @parent_index = nil
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



4
5
6
# File 'lib/ast_distance/node.rb', line 4

def index
  @index
end

#parent_indexObject

Returns the value of attribute parent_index.



3
4
5
# File 'lib/ast_distance/node.rb', line 3

def parent_index
  @parent_index
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/ast_distance/node.rb', line 4

def type
  @type
end

Instance Method Details

#root_node?Boolean



12
13
14
# File 'lib/ast_distance/node.rb', line 12

def root_node?
  parent_index.nil?
end