title: Is it possible to specify formatting options for to_yaml in ruby?
body: <p>The code</p>
  
  <pre><code>require 'yaml'
  puts YAML.load("
  is_something:
    values: ['yes', 'no']
  ").to_yaml
  </code></pre>
  
  <p>produces</p>
  
  <pre><code>--- 
  is_something: 
    values: 
    - "yes"
    - "no"
  </code></pre>
  
  <p>While this is a correct yaml, it just looks ugly when you have a hash of arrays.  Is there a way for me to get <code>to_yaml</code> to produce the inline array version of the yaml? </p>
  
  <p><em>An options hash can be passed to  <a href="http://www.ruby-doc.org/stdlib/libdoc/yaml/rdoc/classes/Array.html#M010476" rel="noreferrer"><code>to_yaml</code></a> but how do you use it?</em></p>
  
  <p>Edit 0:  Thanks Pozsár Balázs.  But, as of ruby 1.8.7 (2009-04-08 patchlevel 160), the options hash does not work as advertised. :(</p>
  
  <pre><code>irb
  irb(main):001:0&gt; require 'yaml'
  =&gt; true
  irb(main):002:0&gt; puts [[ 'Crispin', 'Glover' ]].to_yaml( :Indent =&gt; 4, :UseHeader =&gt; true, :UseVersion =&gt; true )
  --- 
  - - Crispin
    - Glover
  =&gt; nil
  </code></pre>