From: Hal Fulton Date: 2004-09-24T00:19:01+09:00 Subject: Re: Design Advice: Sub-Class 'Instances' Gavin Kistner wrote: > I'm starting to design/write an uber-ambitious home automation hub, in > Ruby. In addition to having convenient things like a web-based GUI > front-end, scheduler, and so on, the heart of this application is that > it will (eventually) work with any automation hardware whose > communication protocol is open (or reverse-engineered). This pleases me more than I can say. I have a similar project which I outlined and began to code, but I ran out of steam when I had problems debugging my X10 code. See http://rubyhacker.com/domo.html Let's see if we can develop some synergy or just plain merge these projects. I'm not picky about all the design details of "my" project; if I don't have help with it, it will never materialize at all; and if I do have help, the other person(s) will contribute to the design. > Questions > 1) Is there a way to inspect the runtime state and figure out which > subclasses exist for a given class? I think there's a hook by which you can have a callback keep a list. I forget the name: inherited I think. ri seems incorrect on that one. > 2) Is there a better way to force/detect if a subclass implements > certain methods? Well... you might just use the callback technique again and maintain a list of methods that are redefined. > 3) Is there a better way overall to achieve my goal? Dunno... for some thoughts on creating classes dynamically, you might want to look at this snippet: http://rubyforge.org/snippet/detail.php?type=snippet&id=25 For a fancy plugin architecture (which you can even reuse), look at FreeRIDE's thing called FreeBase. Definitely let's talk further. BTW: I like HomeSeer so much that if I could get Ruby scripting to work for it, I would almost abandon the idea of a Linux solution. It is "supposed" to work, but the last time I tried, I couldn't make it happen. If you're interested in looking at that problem, let me know. I would *love* to get that to work, because then I could start scripting my entire house in Ruby *today*. Thanks, Hal