Project

walkash

0.0
No commit activity in last 3 years
No release in over 3 years
Walks nested hashes giving you the power to interact with its inner parts.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.8.3
>= 0
~> 3.12
 Project Readme

walkash¶ ↑

Walks nested hashes giving you the power to interact with its inner parts.

Usage¶ ↑

kazu@utopia:~/dev/git/walkash$ cat examples/walk_hash.rb

require 'rubygems'
require 'walkash'
require 'pp'

hash = {
  1 => { 2 => { 3 => { 4 => { 5 => { 6 => { 7 => {
    8 => { 9 => {10 => { 'fix' => 'wrong', 'ignore' => 'wrong' }}}}}}}}}}
}

fix_wrong = lambda do |working_hash, key, value|
  working_hash[key] = 'correct' if (key == 'fix') && (value == 'wrong')
end

pp hash
Walkash.walk(hash, [fix_wrong])
pp hash

kazu@utopia:~/dev/git/walkash$ ruby examples/walk_hash.rb

{1=>
  {2=>
    {3=>
      {4=>
        {5=>{6=>{7=>{8=>{9=>{10=>{"ignore"=>"wrong", "fix"=>"wrong"}}}}}}}}}}}
{1=>
  {2=>
    {3=>
      {4=>
        {5=>
          {6=>{7=>{8=>{9=>{10=>{"ignore"=>"wrong", "fix"=>"correct"}}}}}}}}}}}

Copyright © 2012 kazuyoshi tlacaelel. See LICENSE.txt for further details.