From: Robert Klemme Date: 2011-02-02T17:52:26+09:00 Subject: Re: remove array bracket On Wed, Feb 2, 2011 at 6:52 AM, Jeremy Bopp wrote: > OK.  It's really hard to be sure here, but I think the problem is that > you need to convert this section of your code: > > convert_yaml["System"]["Environmental"]["children"][2]["children"] > << @title > > To this: > > convert_yaml["System"]["Environmental"]["children"][2]["children"] += @title I'd rather convert_yaml["System"]["Environmental"]["children"][2]["children"].concat(@title) > The issue is that tar is an array of hashes, but it appears that you > actually want to append the contents of tar to the data structure you > have from the YAML file instead of appending tar itself.  This code > appends the contents of the array in tar to the existing array in that > mess of hashes. > > There are other ways to handle this, but this one is the simplest > change.  The downside is that you would prevent someone actually > appending tar as-is if they actually wanted to do so.  Maybe that's not > an issue for this code. Another remark: I don't understand why indentation in a YAML file is such an issue. After all it's a data format and readable either way. Typically too few indentation is more an issue than too much. If the formatting is that crucial it might be worthwhile to look into writing a new YAML formatter. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/