The code
require \'yaml\'
puts YAML.load(\"
is_something:
values: [\'yes\', \'no\']
\").to_yaml
produces
---
is_somethin
About the hash options: see http://yaml4r.sourceforge.net/doc/page/examples.htm
Ex. 24: Using to_yaml with an options Hash
puts [[ 'Crispin', 'Glover' ]].to_yaml( :Indent => 4, :UseHeader => true, :UseVersion => true )
# prints:
# --- %YAML:1.0
# -
# - Crispin
# - Glover
Ex. 25: Available symbols for an options Hash
Indent: The default indentation to use when emitting (defaults to2)
Separator: The default separator to use between documents (defaults to'---')
SortKeys: Sort Hash keys when emitting? (defaults tofalse)
UseHeader: Display the YAML header when emitting? (defaults tofalse)
UseVersion: Display the YAML version when emitting? (defaults tofalse)
AnchorFormat: A formatting string for anchor IDs when emitting (defaults to 'id%03d')
ExplicitTypes: Use explicit types when emitting? (defaults tofalse)
BestWidth: The character width to use when folding text (defaults to80)
UseFold: Force folding of text when emitting? (defaults tofalse)
UseBlock: Force all text to be literal when emitting? (defaults tofalse)
Encoding: Unicode format to encode with (defaults to:Utf8; requires Iconv)