I’m a bit new to Ruby, so please excuse me if this is a simplistic
I am trying to create a genuine singleton class. My requirements are as
- The class is used by a terminal program that will be run on one
machine by multiple people with ssh connections to that machine.
- The class should never be instantiated more than once on the
machine, regardless of how many people are running the program that uses
I have tried to create a singleton class using the mixin outlined in the
documentation (i.e, include singleton…xyz.instance). But when I
invoke the application concurrently (in two separate terminal windows),
the singleton class gets instantiated by both programs. What I want is
for the first program to instantiate it, and the second (concurrently
running) program to use the version instantiated by the first (which is
to say that I really do want it to be a singleton!).
Since Ruby is interpreted, I am hoping that the runtime allows it to
handle things this way, although since it doesn’t use namespaces like
Java it’s not clear to me exactly how this would be accomplished.
I am using Ruby 1.67 on RedHat Linux for Intel 7.3. My copy of Ruby is
compiled from the source using the default configuration and no compiler
I’ve searched the archives and the web for info on this, and all I come
up with is the page from the design reference for the Singleton mixin.
David King Landrith (v) 617-227-4469x212
One useless man is a disgrace, two are called a law firm,
and three or more become a congress – John Adams
public key available upon request