Class: FamilyTree::Node
- Inherits:
-
Object
- Object
- FamilyTree::Node
- Includes:
- TreeGraph, TreeHtml
- Defined in:
- lib/family_tree.rb
Instance Attribute Summary collapse
-
#descendants ⇒ Object
readonly
Returns the value of attribute descendants.
-
#klass ⇒ Object
(also: #label_for_tree_graph, #label_for_tree_html)
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
-
#initialize(klass) ⇒ Node
constructor
A new instance of Node.
- #sorted_children ⇒ Object (also: #children_for_tree_html, #children_for_tree_graph)
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
#descendants ⇒ Object (readonly)
Returns the value of attribute descendants.
10 11 12 |
# File 'lib/family_tree.rb', line 10 def descendants @descendants end |
#klass ⇒ Object (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_children ⇒ Object 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 |