Class: FamilyTree::Node

Inherits:
Object
  • Object
show all
Includes:
TreeGraph, TreeHtml
Defined in:
lib/family_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Node

Returns a new instance of Node.



15
16
17
18
# File 'lib/family_tree.rb', line 15

def initialize(klass)
  @klass = klass
  @descendants = []
end

Instance Attribute Details

#descendantsObject (readonly)

Returns the value of attribute descendants.



10
11
12
# File 'lib/family_tree.rb', line 10

def descendants
  @descendants
end

#klassObject (readonly) Also known as: label_for_tree_graph, label_for_tree_html

Returns the value of attribute klass.



10
11
12
# File 'lib/family_tree.rb', line 10

def klass
  @klass
end

Instance Method Details

#sorted_childrenObject Also known as: children_for_tree_html, children_for_tree_graph



20
21
22
# File 'lib/family_tree.rb', line 20

def sorted_children
  descendants.sort_by{ |d| d.klass.name }
end