Class: Binary_tree::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/models/binary_tree/binary_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, color = RED) ⇒ Node

Returns a new instance of Node.



12
13
14
15
16
17
18
# File 'lib/models/binary_tree/binary_tree.rb', line 12

def initialize(value, color = RED)
    self.value = value
    self.left = nil
    self.right = nil
    self.color = color
    self.parent = nil
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



10
11
12
# File 'lib/models/binary_tree/binary_tree.rb', line 10

def color
  @color
end

#leftObject

Returns the value of attribute left.



10
11
12
# File 'lib/models/binary_tree/binary_tree.rb', line 10

def left
  @left
end

#parentObject

Returns the value of attribute parent.



10
11
12
# File 'lib/models/binary_tree/binary_tree.rb', line 10

def parent
  @parent
end

#rightObject

Returns the value of attribute right.



10
11
12
# File 'lib/models/binary_tree/binary_tree.rb', line 10

def right
  @right
end

#valueObject

Returns the value of attribute value.



10
11
12
# File 'lib/models/binary_tree/binary_tree.rb', line 10

def value
  @value
end