[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rb_cdio: subclass or module?

Claudio Bustos

5/28/2005 9:44:00 PM

Hi:
I'm the developer of rb_cdio, a library to create bindings for libcdio.
I'm currently implementing the audio related functions of the library. CdIo::Cd is the base class and there are 5 methods related to CDDA: play, stop, pause, resume and subchannels(retrieve current information, like state of device, time and others).
I have to methods to create a Cd object: CdIo::open (a la File::open) and Cd.new
Now, the question: is not very correct implement the audio functions on the Cd object by default. So, I have two options:
- subclass: create a CdIo::Cdda class, subclass of CdIo::Cd. So, CdIo::open could instance the correct class according to the disc type. The positive consequence is that is easy to verify that the new object is a cdda type
- extending: create a CdIo::Cdda module. In CdIo::Cd, if the disc is cdda type, I extends the class with the audio methods. To me, is the best, because I easy to handle cd with mixed contents.

Can you give some advice? Thank you in advancec.

Excuse me for my poor english (spanish is my native language)

--
Claudio Bustos Navarrete
Psicólogo
clbustos@surnet.cl