# Inlining yaml

**URL:** <https://www.ruby-forum.com/t/inlining-yaml/82373>\
**Category:** Ruby\
**Created:** [January 19, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/inlining-yaml/82373 "2007-01-19T16:29:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [January 19, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/inlining-yaml/82373/1 "2007-01-19T16:29:55Z")

</div>

I want to be able to inline certain parts of yaml output that are  
embedded within a structure. Here’s the approach I’m taking – does  
it look reasonable? Can anyone recommend a better approach? -dan

require ‘yaml’  
class Object  
def inline!  
class \<\< self; def to\_yaml\_style; :inline; end; end  
self  
end  
end

ary = %w[a b c]  
ary.inline!  
other = %w[a b c]

## puts ({ ‘ary’ =\> ary, ‘other’ =\> other }).to\_yaml

ary: [a, b, c]  
other:

- a
- b
- c
