From: fuglyducky Date: 2010-05-24T23:30:09+09:00 Subject: Ruby Newbie...Classes and Objects, oh my! 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 def initialize(array_file, string_file, output_file) @array_file = array_file @string_file = string_file @output_file = output_file end def lines_to_array # Dump each line from text file into array File.open(@array_file).each do |line| my_array << line end end def file_to_string # Create string from text file @my_string_file = File.open(@string_file) my_string = @my_string_file.read end def string_into_array # Insert string into array my_array.insert((my_array.length - 1), my_string) end def new_array_to_file # Dump the array to a text file newFile = File.new(@output_file, "w+") my_array.each { |element| newFile.puts element } print 'New file created: ' + (@output_file) end end stat_xml = XMLProcessing.new("Stat.Template.xml", "Seg.Template.xml", "stat.xml.txt") ###############################################################