Class: TodoNext::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/todo_next/tree.rb,
lib/todo_next/tree/node.rb,
lib/todo_next/tree/nodes.rb,
lib/todo_next/tree/factory.rb,
lib/todo_next/tree/parents_list.rb,
lib/todo_next/tree/visitor/rspec_generator.rb

Defined Under Namespace

Modules: Visitor Classes: EX, Factory, LI, Node, OL, ParentsList

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTree

Returns a new instance of Tree.



11
12
13
# File 'lib/todo_next/tree.rb', line 11

def initialize
  @children = []
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



9
10
11
# File 'lib/todo_next/tree.rb', line 9

def children
  @children
end

Instance Method Details

#to_rspecObject



23
24
25
# File 'lib/todo_next/tree.rb', line 23

def to_rspec
  visit(TodoNext::Tree::Visitor::RspecGenerator.new).flatten.join("\n")
end

#visit(visitor) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/todo_next/tree.rb', line 15

def visit(visitor)
  result = []
  children.each do |node|
    result << visitor.visit(node, level=1, parent=self)
  end
  result
end