Create a gist now

Instantly share code, notes, and snippets.

require 'psych'
list = ('a'..'z').to_a
# Create a YAML AST
viz = {}
viz << list
tree = viz.tree
# Change the Sequence node to be FLOW style = Psych::Nodes::Sequence::FLOW
# Output as YAML
puts tree.to_yaml
# Or just use JSON style (it defaults to flow)
puts Psych.to_json list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment