# Onion 0.0.2 Released

**URL:** <https://www.ruby-forum.com/t/onion-0-0-2-released/165740>\
**Category:** Ruby\
**Created:** [April 16, 2009, 9:55pm UTC](https://www.ruby-forum.com/t/onion-0-0-2-released/165740 "2009-04-16T21:55:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![backorder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@backorder](https://www.ruby-forum.com/u/backorder)\
**Post date:** [April 16, 2009, 9:55pm UTC](https://www.ruby-forum.com/t/onion-0-0-2-released/165740/1 "2009-04-16T21:55:25Z")

</div>

Onion 0.0.2 has been released.

gem install Onion

Homepage: [http://rubyforge.org/projects/onion/](http://rubyforge.org/projects/onion/)  
Blog{Ruby, Onion, etc…}: [http://mecenia.blogspot.com/](http://mecenia.blogspot.com/)

Onion, or Array Onion, allows peeling an array like an onion. It shreds  
one layer after another, from the outer inwards the inner nested array,  
according to the given depth. Infinite depth (or greater than current  
nested array depth) is equivalent to Array#flatten.

Vote if you would like Onion for Hashes as well.  
[http://rubyforge.org/survey/survey.php?group\_id=8071&survey\_id=93](http://rubyforge.org/survey/survey.php?group_id=8071&survey_id=93)

What’s new?

- Improved performances
- Fully code covered
- Additional tests
- You can now peel!
- A small bug fix

== Usage Examples

[1, 2, 3, 4, 5].depth =\> 1  
[1, [2, [3, 4], 5]].depth =\> 3  
[1, [2, [3, [4, 5]]]].depth =\> 4

[1, [2, [3, [4, 5]]]].peel\_until(1) =\> [1, 2, 3, 4, 5]  
[1, [2, [3, [4, 5]]]].peel\_until(2) =\> [1, 2, 3, [4, 5]]  
[1, [2, [3, [4, 5]]]].peel\_until(3) =\> [1, 2, [3, [4, 5]]]  
[1, [2, [3, [4, 5]]]].peel\_until(4) =\> [1, [2, [3, [4, 5]]]]

[1, [2, [3, 4], 5]].peel(1) =\> [1, 2, [3, 4], 5]  
[1, [2, [3, 4], 5]].peel(2) =\> [1, 2, 3, 4, 5]

[1, [2, [3, [4, 5]]]].peel(1) =\> [1, 2, [3, [4, 5]]]  
[1, [2, [3, [4, 5]]]].peel(2) =\> [1, 2, 3, [4, 5]]  
[1, [2, [3, [4, 5]]]].peel(3) =\> [1, 2, 3, 4, 5]
