category_tree.rb
def insert_child(name)
    # TODO: Do we need to check like <=> for category name (e.g. alphabetic)
    if self.left_child.nil?
      # Add to the left
      self.left_child = CatNode.new(name)
    elsif self.right_child.nil?
      # Add to the right
      self.right_child = CatNode.new(name)
    else
      # TODO: This seems odd that you don't insert farther down...need to revisit
      # already contains 2 children (L, R)
      raise ArgumentError.new('Parent categories full!')
    end
  end
# TODO: Unless I'm missing something, you only can add 2 child categories (L, R) to any given (parent) category
# Inserts a child node
Unless I'm missing something, you only can add 2 child categories (L, R) to any given (parent) category
Inserts a child node
Unless I ' m missing something you only can add 2 child categories ( L R ) to any given ( parent ) category Inserts a child node
def insert_child(name)
    if self.left_child.nil?
      self.left_child = CatNode.new(name)
    elsif self.right_child.nil?
      self.right_child = CatNode.new(name)
    else
      raise ArgumentError.new('Parent categories full!')
    end
  end
def insert_child ( name ) if self . left_child . nil? self . left_child = CatNode . new ( name ) elsif self . right_child . nil? self . right_child = CatNode . new ( name ) else raise ArgumentError . new ( 'Parent categories full!' ) end end
TODO: Unless I'm missing something, you only can add 2 child categories (L, R) to any given (parent) category
Inserts a child node
TODO : Unless I ' m missing something you only can add 2 child categories ( L R ) to any given ( parent ) category Inserts a child node
# TODO: Do we need to check like <=> for category name (e.g. alphabetic) # Add to the left # Add to the right # TODO: This seems odd that you don't insert farther down...need to revisit # already contains 2 children (L, R)
name