From: Damjan Rems Date: 2008-03-03T17:07:09+09:00 Subject: Understanding ruby classes This question is all about me not understanding how ruby classes work. I have three print classes. myPrint which is abstract class and implements common methods for other two classes which are myPrint2PDF and myPrint2HTML. They implement all the troubles of output to PDF or HTML format. Without too much code, implementation looks like this: class myPrint def printHDR end .... end class myPrint2PDF << myPrint .... end class myPrint2HTML << myPrint .... end Then I have fourth class which implements the job which has to be done. class myPrint001 << myPrint2PDF def printHDR image 'image.jpg' 20, 1 print 'some header text' 1,5 ... end def doJob print 'some text' 1,5 end end Here is my catch 22. I would REALLY like to call my implementation class like this: pr = myPrint001 :format => 'HTML' or pr = myPrint001 :format => 'PDF' pr.doJob I have made statement 'class myPrint001 << myPrint2PDF' intentionaly wrong and I know it does not provide the real solution, but this is how it works for now. What would be the best (ruby) solution to this problem. by TheR -- Posted via http://www.ruby-forum.com/.