Project

raze

0.0
No commit activity in last 3 years
No release in over 3 years
Provides methods to flatten nested collections into one dimensional structure that is easy to iterate over.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

Raze

Ruby Gem to flatten nested collections into one dimensional representations.

https://rubygems.org/gems/raze

##Examples

test = {test1: ['test_string', :test_symbol], test2: {test_hash: ['test_string']}}

Raze.flatten(test)
=> [:test1, "test_string", :test_symbol, :test2, :test_hash, "test_string"]

You might be wondering how the flatten method above differs from flatten methods in array or hash ruby core libraries. Unfortunately on their own the core methods won't flatten values/recurse through hashes.

irb(main):010:0> a = {test1: ['test_string', :test_symbol], test2: {test_hash: ['test_string']}}
=> {:test1=>["test_string", :test_symbol], :test2=>{:test_hash=>["test_string"]}}
irb(main):011:0> a.flatten(30)
=> [:test1, "test_string", :test_symbol, :test2, {:test_hash=>["test_string"]}]