I have a hash object, whose structure looks similar to this:
{:category1 =>
{:subcategory1 =>
[
{:article => "some article", :date =&g开发者_如何学编程t; "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?
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
I believe you could use the ruby-graphviz gem for this sort of visualization.
精彩评论