Last Modified
2021-02-12 13:34:18 +0000
Requires

Description

Base tree class which given an array of nodes produces different types of trees. The types of trees currently are:

Tree nodes can be given as an array of arrays or an array of hashes. To render the above basic tree with an array of hashes:

Hirb::Helpers::Tree.render([{:value=>0, :level=>0}, {:value=>1, :level=>1}, {:value=>2, :level=>2}, 
  {:value=>3, :level=>2}, {:value=>4, :level=>1}])

Note from the hash keys that :level refers to the depth of the tree while :value refers to the text displayed for a node.

To render the above basic tree with an array of arrays:

Hirb::Helpers::Tree.render([[0,0], [1,1], [2,2], [2,3], [1,4]])

Note that the each array pair consists of the level and the value for the node.