lib/todo_next/tree/factory.rb in todo_next-0.0.1 vs lib/todo_next/tree/factory.rb in todo_next-0.0.2
- old
+ new
@@ -1,10 +1,10 @@
require File.dirname(__FILE__) + '/node'
+require File.dirname(__FILE__) + '/nodes'
require File.dirname(__FILE__) + '/parents_list'
module TodoNext
-
class Tree
class Factory
def self.build(lines)
mark_the_leaves_and_the_branches(lines)
@@ -14,17 +14,19 @@
lines.each do |line|
curr_line_col = line.col_offset
parent = parents.get_for_item_at_column(curr_line_col) || tree
+ new_node = if line.example? then Tree::EX.new(line.text, parent)
+ elsif line.branch? then Tree::OL.new(line.text, parent)
+ else Tree::LI.new(line.text, parent)
+ end
+ parent.children << new_node
+
if line.branch?
- new_node = Tree::OL.new(line.text, parent)
parents.register_parent(new_node, :for_col => curr_line_col)
- else
- new_node = Tree::LI.new(line.text, parent)
end
- parent.children << new_node
end
tree
end
private
@@ -37,7 +39,6 @@
end
end
end
end
-
end
\ No newline at end of file