On May 24, 8:57 ¨Âí¬ Òïâåòô Äïâå¼òïâåòô®äï®®®Àçíáéì®ãïí¾ ÷òïôåº > On Mon, May 24, 2010 at 4:30 PM, fuglyducky <fuglydu... / gmail.com> wrote: > > I'm very new to Ruby and I'm trying to create a program that will take > > one text file and dump each line into an array. Then I take a second > > file and dump that into a string. Then I insert the string into the > > array. The code for these pieces work. However, for flexibility I want/ > > need to be able to use OO methods and that is where I seem to hit a > > wall. Not sure what I am supposed to do or how to call it. Below is my > > code, any input you may have would be greatly appreciated!!! > > > ############################################################### > > > class XMLProcessing > > ¨Âåæ éîéôéáìéúå¨áòòáùßæéìå¬ óôòéîçßæéìå¬ ïõôðõôßæéìå© > > ¨Âáòòáùßæéìå áòòáùßæéìå > > ¨Âóôòéîçßæéìóôòéîçßæéì> > ¨Âïõôðõôßæéìïõôðõôßæéì> > ¨Âîä > > > ¨Âåæ ìéîåóßôïßáòòáù > > Dump each line from text file into array > > ¨Âéìå®ïðåî¨Àáòòáùßæéìå©®åáãè äï üìéîåü > > ¨Âùßáòòá¼¼ ìéîå > > This is a local variable, uninitialized for that matter > try > @my_array = [] > File.open... > @my_array << line > end > > However, you could also simply do a > ¨Âíùßáòòáù Æéìå®òåáäìéîåóÀáòòáùßæéì©®íá𨠦ºãèïí> or the more explicit (and in Rubies < 1.9 necessary ) > ¨Âíùßáòòáù Æéìå®òåáäìéîåóÀáòòáùßæéì©®íáðû üìéîåü ìéîå®ãèïíð ý¾ ¨Âîä > > ¨Âîä > > > ¨Âåæ æéìåßôïßóôòéîç > > Create string from text file > > ¨Âíùßóôòéîçßæéìå Æéìå®ïðåî¨Àóôòéîçßæéìå> > ¨Âùßóôòéîç Àíùßóôòéîçßæéìå®òåáä > > Same here > ¨Âíùßóôòéî®®> > > ¨Âîä > > > ¨Âåæ óôòéîçßéîôïßáòòá> > Insert string into array > > ¨Âùßáòòáù®éîóåòô¨¨íùßáòòáù®ìåîçô±©íùßóôòéîç© > > and here too > @my_array> ¨Âîä > > > ¨Âåæ îå÷ßáòòáùßôïßæéì> > Dump the array to a text file > > ¨Âå÷Æéìå Æéìå®îå÷¨Àïõôðõôßæéìå¬ ¢÷«¢> > ¨Âùßáòòáù®åáãè üåìåíåîôîå÷Æéìå®ðõôó åìåíåî> > change here too > ¨Âíùßáòòáù > > > ¨Âòéîô §Îå÷ æéìå ãòåáôåäº ¨Àïõôðõôßæéìå© > > ¨Âîä > > end > > > stat_xml = XMLProcessing.new("Stat.Template.xml", "Seg.Template.xml", > > "stat.xml.txt") > > Now just call the methods you want to execute on stat_xml as e.g. > stat_xml.file_to_string > .. > .. > > I do not think your design is ideal, calling all those external method > calls for intermediate computations(1), but for a beginner it is > pretty nicely structured code. > > HTH > R. > > (1) But there might be reasons invisible to YHS. > > > > > ############################################################### > > -- > The best way to predict the future is to invent it. > -- Alan Kay Wow...thanks for the response!!! I'm not a programmer for a developer by any means. I'm a tester that needed a quick (and hopefully not too dirty) way of creating the files I need. The reason I wanted to call all of the submethods was because I need to be able to create a random number of some of the individual files before I dump them into the array. I thought that in the main body of the code I would script it out to call that particular method. This is all pretty new to me...is that bad form?