[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Onion 0.0.2 Released

Ian Trudel

4/16/2009 7:56:00 PM

Onion 0.0.2 has been released.

gem install Onion

Homepage: http://rubyforge.org/proje...
Blog{Ruby, Onion, etc..}: http://mecenia.blo...

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&su...

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]
--
Posted via http://www.ruby-....