lib/todo_next/tree/node.rb in todo_next-0.0.1 vs lib/todo_next/tree/node.rb in todo_next-0.0.2

- old
+ new

@@ -1,25 +1,32 @@ module TodoNext - class Tree class Node + attr_accessor :text, :parent, :children def initialize(text, parent=nil) @text, @parent = text, parent @children = [] end - def terminal? - false + def terminal? ; false end + def example? ; false end + + def has_children? + !children.empty? end - end - class OL < Node ; end + def remove_from_parent_children + parent.children.delete_if do |child| + child==self + end + end - class LI < Node - def terminal? - true + def make_me_a_leaf + me_as_leaf = Tree::LI.new(text, parent) + idx = parent.children.find_index(self) + parent.children[idx] = me_as_leaf end + end end - -end \ No newline at end of file +end