inlining yaml

D

Dan Kirkwood

I want to be able to inline certain parts of yaml output that are
embedded within a structure. Here's the approach I'm taking -- does
it look reasonable? Can anyone recommend a better approach? -dan

require 'yaml'
class Object
def inline!
class << self; def to_yaml_style; :inline; end; end
self
end
end

ary = %w[a b c]
ary.inline!
other = %w[a b c]

puts ({ 'ary' => ary, 'other' => other }).to_yaml
---
ary: [a, b, c]
other:
- a
- b
- c
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top