# To\_yaml\_style

**URL:** <https://rubytalk.org/t/to-yaml-style/54349>\
**Category:** ruby-talk\
**Created:** [10 July 2009 19:31 UTC](https://rubytalk.org/t/to-yaml-style/54349 "2009-07-10T19:31:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pito\_Salas](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@Pito\_Salas](https://rubytalk.org/u/Pito_Salas)\
**Post date:** [10 July 2009 19:31 UTC](https://rubytalk.org/t/to-yaml-style/54349/1 "2009-07-10T19:31:27Z")

</div>

I wanted an array:

&nbsp;&nbsp;big\_array = [[1,2], [1,2], [1,2], [1,2]]

To convert into more readable yaml. (Yeah I know, YAML is for computers  
to read and write but sometimes I want to eyeball it)

The default yaml I get is:

> **···**
>
> ---  
> - - 1  
> &nbsp;&nbsp;- 2  
> - - 1  
> &nbsp;&nbsp;- 2  
> - - 1  
> &nbsp;&nbsp;- 2  
> - - 1  
> &nbsp;&nbsp;- 2
> 
> How ugly. I know that this is valid Yaml too:
> 
> --- [[1, 2], [1, 2], [1, 2], [1, 2]]
> 
> Sweet. I did it like this:
> 
> &nbsp;&nbsp;big\_array = [[1,2], [1,2], [1,2], [1,2]]  
> &nbsp;&nbsp;def big\_array.to\_yaml\_style; :inline; end  
> &nbsp;&nbsp;puts big\_array.to\_yaml
> 
> What? to\_yaml\_style? I found that lying around some list but can't find  
> any doc on it and couldn't even find it in the code. I know it must be  
> hiding.
> 
> Anyone know what other options there are for to\_yaml\_style? Because I  
> have some other needs that might already be built in.
> 
> Thanks much!
> 
> Pito  
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
