From: Alexis Date: 2001-11-25T13:25:46+09:00 Subject: [ruby-talk:26421] New member, project(s) and questions Hi, An announcement and a couple of questions. To learn Ruby I've started to write a MUD. I have a neat command engine and a threaded server working just fine. I decided I wanted to store the world data in a relational database. However, I wanted this to happen with as little manual admin as possible. Hence I'm defining an abstract class DBObj which supports get(id), put() (which updates the DB record) and rel() (which doesn't). Yes, this means caretaking on objects, but I have lots of threads so it needs to be done anyway. Within DBObj I need to be able to find out what types the fields are. Right now I'm trying to do this by asking descendants to have defaults for all fields except id in initialize(), and doing this: class DBObj # Creates the DB table # Needs type info to declare column types correctly def DBObj.mktable obj = new(0) # Doesn't work @@dbfields.each { |sym| case obj.__send__(sym) when Integer sql << sym.id2name << " int" ... end } end end Any suggestions for neater ways to obtain this type information? Particularly since calling new from DBObj creates a DBObj, not an instance of the class "#{name}" reports as I had hoped. My current thought is to call Desc.new(0).mktable. That's very yuk though. Last question, is there any way to use variable variables? Like: class Boo def initialize @ab = "Hi" puts @("ab") end end Boo.new If I could use this to generate a Class object (IE Class.new("Boo")) then it would solve my reflection problem. If anyone is interested in any of the code I mentioned, drop me a line. Alexis -- "Teachers open the door, but you must enter by yourself" - Chinese proverb Attention. The early bird gets the worm. The second mouse gets the cheese. - Jen Hopkins