On Fri, Nov 22, 2002 at 12:37:47AM +0900, Paul Brannan wrote:
>    the only thing I don't like about this second method is that
>    initialize_with_filename and initialize_with_host_and_port are both
>    public methods; I don't know any way to make them private
>    (initialize() is always a private method).

I just thought of a solution:

  class Foo
  public
    def self.new_with_socket(host, port)
      return new(:initialize_with_host_and_port, host, port)
      return obj
    end

    def self.new_with_filename(filename)
      return new(:initialize_with_filename, filename)
    end

  private
    private_class_method :new

    def initialize(init_method, *args, &block)
      @host = @port = @filename = nil
      self.send(init_method, *args, &block)
    end

    def initialize_with_filename(filename)
      @filename = filename
    end

    def initialize_with_host_and_port(host, port)
      @host = host
      @port = port
    end
  end

Paul