Question

I have a hash object, whose structure looks similar to this:

{:category1 => 
 {:subcategory1 => 
  [ 
   {:article => "some article", :date => "2010-04-04"},
   ...
  ],
  :subc2 => [...] 
 },
 :category2 => {...},
 ...
}

How can I visualize it as graph in ruby?

Is there a simple method/gem/lib that converts this Hash to DOT?

Was it helpful?

Solution

I believe you could use the ruby-graphviz gem for this sort of visualization.

OTHER TIPS

Why do you want it to be a graph? The data in your example is a tree.

You can see the tree easily in text with Ruby's pretty print:

pp my_hash

If you want a little cleaner output:

puts my_hash.to_yaml
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top