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

Similar Threads

How to doing a "grep -v" to hide "---" line added by Hash#to_yaml ? 7
narray on windows? 1
Class::name 0
threads and blocking 0
pthread masters (that's you guy) 1
hash 13
LD_RUN_PATH 6
Object#copy [rcr?] 4

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top