From: Arlen Cuss Date: 2008-04-25T10:48:02+09:00 Subject: Re: pretty folder tree script ------=_Part_4407_19440645.1209088077458 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, On Fri, Apr 25, 2008 at 11:35 AM, John wrote: > I think you killed a fly with a shotgun this time. I mean it's really > appriciated, but I can't ride this horse. Understood, but I think this is probably the simplest data structure you can get for what you want. > I was looking for more of a [migratus[app[views, models, > controllers]]... etc] than a hash with empty symbols. > You can't use anything less than arrays *and* something else to do this, unfortunately - since arrays can only contain other objects [and have no `name' of their own], we need some other type of object used in conjunction to actually be the `nodes' of this tree structure. You could do it entirely with hashes, however, which renders what I think what you want: result[:migratus][:app][:views], for example. Is this more what you'd be looking for? My last question, though, is - what do you want at the `leaves' of this tree? [i.e. what do you get at the very end? - the items under `views', for example?] Something that produces such nested hashes would just leave empty hashes (i.e. result[...][:views][:abc] == {}), but that wouldn't impede your work. The only thing with using hashes is that you lose any order you might've had. But perhaps it's not a problem? http://pastie.caboo.se/186549 The result is like this: {"controllers"=>{}, "views"=>{"projects"=>{}, "tasks"=>{}, "layouts"=>{}}, "helpers"=>{}, "models"=>{}} Note that we're already "using" the data in some manipulated sense in that pastie bit by asking for `result["."]["Migratus"]["app"]' specifically. Hope this helps a bit. If I miss the point still, please let us know! Arlen ------=_Part_4407_19440645.1209088077458--