to_yaml and options hash

A

Ara.T.Howard

iccording to the docs, this should emit the version:

~/eg/ruby > ruby -r yaml -e 'print([0,1,2].to_yaml:)UseVersion => true))'

but it simply outputs

---
- 0
- 1
- 2

other options seem to be ignored too :)Separator, etc). my questions are

a) what's up with the options hash? it does not seem to work the way the
docs imply:

...
puts [[ 'Crispin', 'Glover' ]].to_yaml( :Indent => 4, :UseHeader => true, :UseVersion => true )
# prints:
# --- %YAML:1.0
# -
# - Crispin
# - Glover
...

~/eg/ruby > ruby -r yaml -e "puts [['Crispin','Glover']].to_yaml:)Indent=>4,:UseHeader=>true,:UseVersion=>true)"
---
-
- Crispin
- Glover



b) is there an option that will cause

[ 0, 1, 2 ].to_yaml

to be emitted as

[ 0, 1, 2 ]

rather than

---
- 0
- 1
- 2


thanks for any assistance.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top