I'm trying to write a ruby extension that needs to run a init() function 
ONLY the first time a certain class is instantiated, and a shutdown() ONLY 
the last object is destroyed.  How can I do this?  The init() half seems 
easier, with something like (in ruby code, would be C)

def myclass
  def initialize()
    init() if @@firstonly.nil?
    @@firstonly = true
    ...
  end
  ...
end

What about shutdown()?  Should the user be forced to run a close()-type 
method (similar to File)?  Then I could increment a counter in initialize() 
(or make open(), to be more consistent)  and decrement it in close().  Is 
there a destructor-type method I could use?

Ryan