Class: TodoNext::Tree
- Inherits:
-
Object
- Object
- TodoNext::Tree
- 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
-
#children ⇒ Object
Returns the value of attribute children.
Instance Method Summary collapse
-
#initialize ⇒ Tree
constructor
A new instance of Tree.
- #to_rspec ⇒ Object
- #visit(visitor) ⇒ Object
Constructor Details
#initialize ⇒ Tree
Returns a new instance of Tree.
11 12 13 |
# File 'lib/todo_next/tree.rb', line 11 def initialize @children = [] end |
Instance Attribute Details
#children ⇒ Object
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_rspec ⇒ Object
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 |