inlining yaml

Discussion in 'Ruby' started by Dan Kirkwood, Jan 11, 2007.

  1. Dan Kirkwood

    Dan Kirkwood Guest

    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
    Dan Kirkwood, Jan 11, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RubyQuestions
    Replies:
    0
    Views:
    214
    RubyQuestions
    Dec 3, 2003
  2. Paul Battley

    YAML.dump/YAML.load bug

    Paul Battley, Aug 3, 2005, in forum: Ruby
    Replies:
    0
    Views:
    169
    Paul Battley
    Aug 3, 2005
  3. Eric Promislow
    Replies:
    4
    Views:
    199
    Eric Promislow
    Oct 31, 2006
  4. Joshua Choi

    yaml.rb and YAML "%" directives

    Joshua Choi, Jan 14, 2007, in forum: Ruby
    Replies:
    1
    Views:
    156
  5. Fransiscus Xaverius

    YAML Problem YAML::Object

    Fransiscus Xaverius, Dec 14, 2007, in forum: Ruby
    Replies:
    2
    Views:
    145
    Fransiscus Xaverius
    Dec 14, 2007
Loading...

Share This Page