From: Meino Christian Cramer Date: 2003-08-09T16:47:10+09:00 Subject: Ruby and OOP-design (question of an old "procedural person" ;) Hi ! I have a newbie question on OOP-design: What I have is a large ASCII-File, a list of about 11000 shortwave broadcasters. Each line contains the informations about one transmitter hold in a long string without any delimiters. It is specified, what offsets into a line are to be used to cut off the informations one would need about a broadcaster. What I want to do is to read the whole file into memory, put each information into a sperate "field" to get rid of those "information-one-liners" and then I want to sort the whole thing by frequency first and by on-air-time then. What I done so far is (pseudo-code): -------------------- class SWFILE( file) open the file @ist=List.new foreach line do format line by expressions like @time=line[..] transmitter=Broadcaster.new( @freq, @station, @time.....) List.append( transmitter ) end foreach end class Broadcaster def initialize( freq, station, time.....) @freq = freq @station = station @time = time ... end end class List def initialize @list=Array.new end def append( broadcaster) @list.push( broadcaster) end end a=SWFILE.new( "" ) -------------------- This works so far.... Then I read about the new sort_by feature. This is exactly what I need! But sort_by needs an array as input. And my "list"-object is an object (or a duck, which quaks ;) holding and array...or what...or .... I got confused here. Furthermore I am really not sure, whether I have generated as "class-ified" program, which is programmed in a procedural way only or ... ? Two questions: What I have to feed where into the structure to sort the broadcasters by frequency first and then by on-air-time ? Is this "design" ok (in the sense of OOP)? Kind regards from a confused duck, which quaks, Meino