Joel VanderWerf
4/7/2009 10:41:00 PM
Ryan Davis wrote:
>
> On Apr 7, 2009, at 14:14 , bwv549 wrote:
>
>> How to emit yaml without the leading hyphens?
>>
>> [1,2,3].to_yaml
>> # ==>"--- \n- 1\n- 2\n- 3\n"
>>
>> I realize that I can do the following to get the result I'm after, but
>> it seems sort of "after the fact"
>> [1,2,3].to_yaml[5..-1]
>> # ==>"- 1\n- 2\n- 3\n"
>>
>> I know 'to_yaml' takes options, but I can't find acceptable options
>> anywhere.
>> [1,2,3].to_yaml({:??? => true})
>
>
> As I understand it, if you remove the hyphens, it is no longer yaml, so
> don't do that.
Maybe so, but the yaml extension loads it anyway.
irb(main):001:0> [1,2,3].to_yaml[5..-1]
=> "- 1\n- 2\n- 3\n"
irb(main):002:0> YAML.load(_)
=> [1, 2, 3]
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407