Module: FamilyTree
- Defined in:
- lib/family_tree.rb,
lib/family_tree/version.rb
Defined Under Namespace
Classes: Node
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
Class Method Details
.graph(klasses) ⇒ Object
55 56 57 |
# File 'lib/family_tree.rb', line 55 def graph(klasses) of(klasses).tree_graph end |
.html(klasses) ⇒ Object
59 60 61 |
# File 'lib/family_tree.rb', line 59 def html(klasses) of(klasses).tree_html_full end |
.of(klasses) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/family_tree.rb', line 29 def of(klasses) root = Node.new(::BasicObject) Array(klasses).each do |k| parent = root k = ::Object.const_get(k) if String === k k.ancestors.reverse_each do |a| next unless Class === a next if ::BasicObject == a child = parent.descendants.detect{ |d| d.klass == a } unless child child = Node.new(a) parent.descendants << child end parent = child end end root end |