# To\_yaml\_style

**URL:** <https://www.ruby-forum.com/t/to-yaml-style/171887>\
**Category:** Ruby\
**Created:** [July 10, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/to-yaml-style/171887 "2009-07-10T21:30:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [July 10, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/to-yaml-style/171887/1 "2009-07-10T21:30:58Z")

</div>

I wanted an array:

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
  - 2

- 
  - 1
  - 2

- 
  - 1
  - 2

- 
  - 1
  - 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:

big\_array = [[1,2], [1,2], [1,2], [1,2]]  
def big\_array.to\_yaml\_style; :inline; end  
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
