From: Jeremy Bopp Date: 2011-02-02T11:35:29+09:00 Subject: Re: remove array bracket On 02/01/2011 08:22 PM, Kamarulnizam Rahim wrote: > Hi guys, > > Actually i just want to remove the bracket (The very first and last > bracket) because if the bracket still there, it will affect the > indentation on my yaml output (as the posted output above will be > converted into yaml format). This is what will happen on my yaml output > if i do not remove the brackets: > > - - name: Efficiency (Energy) > type: Objective > subtype: NIZAMMMMzz > components: > - type: ContentBox > title: Audit > args: > :content: | > None > > - type: ChildListingComponent > title: "Current Targets for the Efficiency (Energy) > Objective:" > - children: > - name: Routinely monitor energy use > type: Target > subtype: ATEEN > components: > - type: ContentBox > title: Summary > args: > :content: | > None > > As you can see, there are double indented dash (- -) on the Efficiency > (energy) and i want to remove one of those.This is the code i use: > > tar = [ ] > objective = {"name"=>"#{blank}", > "type"=>"Objective", > "subtype"=>"NIZAMMMMzz", > "components"=> > [{"type"=>"ContentBox", > "title"=>"Audit", > "args"=>{:content=>"None\n"}}, > {"type"=>"ChildListingComponent", > "title"=>"Current Targets for the #{blank} Objective:"}]} > tar << objective > > mon = { "children"=> > [{"name"=>"#{question}", > "type"=>"Target", > "subtype"=>"ATEEN", > "components"=> > [{"type"=>"ContentBox", > "title"=>"Summary", > "args"=>{:content=>"None\n"}}, > {"type"=>"ContentBox", > "title"=>"Description", > "args"=> > {:content=> > ""}}, > {"type"=>"TargetComponent", > "title"=>"None", > "args"=> > {:start_date=>"# :end_date=>"#{due_date}", > :state=>"#{status}"}}]}]} > tar << mon > pp tar The variable tar is an array of hashes, and the first output you posted agrees with this. At this point there does not appear to be any cause for an added array wrapping tar. You need to show us how you output the value of tar into your YAML file. You are likely wrapping tar within another array before you do that. -Jeremy