From: Kamarulnizam Rahim Date: 2011-01-28T13:56:36+09:00 Subject: Transfer hash (within a class) to another class I got a problem running the following codes: -------------------------------------------------------------------------- class Environmental def display convert_yaml = YAML::load_file('nizam.yaml') pp convert_yaml["System"]["Environmental"]["children"] end end class EnergyManagement < Environmental def display(nizam) convert_yaml = YAML::load_file('nizam.yaml') @nizam = nizam convert_yaml["System"]["Environmental"]["children"][2]["children"] << @nizam File.open("nizam_out.yaml", "w"){|f| YAML.dump(convert_yaml, f)} end end class Efficiency < Struct.new(:issue, :blank, :risk_opportunity, :compliance, :consequence, :current_status, :due_date, :priority, :responsibility, :probability) # a method to print out a csv record for the current Person. def print_csv_record #.....few lines of codes here. Not relevant to the problem i think #.....few lines of codes here def convert_ruby_struct afiq = {"name"=>"#{blank}", #assume #{blank} is just a normal string "type"=>"Objective", "subtype"=>"None", "components"=> [{"type"=>"ContentBox", "title"=>"Audit", "args"=>{:content=>"None\n"}}, {"type"=>"ChildListingComponent", "title"=>"Current Targets for the #{blank} Objective:"}]} pp afiq e = EnergyManagement.new(afiq) e.display end end -------------------------------------------------------------------------- Then i got this error: rb:18:in `display': wrong number of arguments (0 for 1) (ArgumentError) I know the problem is regarding on inserting 'afiq' into display method under EnergyManagement class but do not know how to solve it. Anyone knows how to transfer hash into another class? I know im posting two different threads at the same time because i am working with these two problems simultaneously. Sorry for this confusion Nizam -- Posted via http://www.ruby-forum.com/.