Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > inlining yaml

Thread Tools

inlining yaml

Dan Kirkwood
Posts: n/a
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

ary = %w[a b c]
other = %w[a b c]

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

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
YAML Problem YAML::Object Fransiscus Xaverius Ruby 2 12-14-2007 09:17 PM
yaml.rb and YAML "%" directives Joshua Choi Ruby 1 01-14-2007 07:53 AM
Puzzling over why ri can open the std ruby/ri .yaml files, but raw yaml can't Eric Promislow Ruby 4 10-31-2006 10:15 PM
YAML.dump/YAML.load bug Paul Battley Ruby 0 08-03-2005 08:28 PM
YAML Question: Using YAML::YamlNode#transform Method to get float values? RubyQuestions Ruby 0 12-03-2003 02:15 AM