Hi why,

thanks for the code. Very nice idea.

There's one error though: you don't store the Transport's subclass 
in the hash, but the class of the subclass, which is Class. So 
here's the modified version:

  class Transport 
    @@transports = {}
    class << self
      def def_proto_id( pid )
        @@transports[ pid ] = self
      end
      def registered_transports
        @@transports.keys
      end
      def create( pid )
        @@transports[ pid ].new
      end
    end
  end
  
  class TCPTransport < Transport
    def_proto_id 'tcp'
  end
  
  class UDPTransport < Transport
    def_proto_id 'udp'
  end
  
  p( Transport.registered_transports.join(', ') )  # => "udp, tcp"
  p( Transport.create( 'tcp' ) )  # => #<TCPTransport:0x2b89128>
  p( Transport.create( 'udp' ) )  # => #<UDPTransport:0x2b89008>


Regards,
Pit