Forum: Ruby inlining yaml

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dan K. (Guest)
on 2007-01-19 17:29
(Received via mailing list)
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
This topic is locked and can not be replied to.