Skip to content

peagha/tree-plotter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tree Plotter

This is a simple Ruby algorithm that plots a tree based in a Hash.

Example:

tree = { label: 'Parent label', children: [ { label: 'Child label 1', children: [] }, { label: 'Child label 2', children: [] }, { label: 'Child label 3', children: [] } ] } Plotter.plot_tree(tree) # => # Parent label # ├─ Child label 1 # ├─ Child label 2 # └─ Child label 3

It supports more levels of nesting and adds a connectiong line between siblings:

Parent label ├─ Child label 1 │ ├─ Granchild label 1 │ │ ├─ Grangranchild label 1 │ │ └─ Grangranchild label 2 │ ├─ Granchild label 2 │ └─ Granchild label 3 └─ Child label 2 ├─ Granchild label 1 │ ├─ Grangranchild label 1 │ └─ Grangranchild label 2 ├─ Granchild label 2 └─ Granchild label 3 

Running the tests

ruby plotter_test.rb

TODO:

  • Add documentation
  • Improve class / module names (Plotter is too generic)

About

Simple ruby class to plot any generic tree in a directory-like structure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages