Change a specific instance variable in 3 different, running Ruby scripts

Hi. Consider a simple class.

I call it class Test.

It has only one instance variable, called @foo.

This variable can be modified with method called
update, which accepts one argument, which is the
new value for this variable.

Code example could look like:

require ‘pp’

class Test

def initialize
  @foo = 'foo'
  run
end

def update(i)
  @foo = i
end

def run
  puts 'Running '+@foo+' from '+self.object_id.to_s
end

end

if FILE == $PROGRAM_NAME
_ = Test.new
end

This will return something like:

“Running from foo from -5950760”

Now I need to modify the @foo variable in ALL running scripts
(that run class Test, but it is ok to find only all those
that run test.rb).

I need to get a handle on these programs (I run Linux and am in full
control of the system otherwise, and I need to have this only for
myself.)

I have thought a bit about this but there are two problems:

  • I need to find out which scripts are running currently. This can be
    done via “ps ax” ok, then I can grep this result to get the ID.

  • But even when I have this, how can I call them directly?

In pseudo code:

matches = find_all_ruby_scripts.that_match ‘test’
matches.update ‘bar’
matches.run

This would then return something like:

“Running from bar from -5950760”

For all these processes.

Does anyone have ideas how to solve it?

Solve it in ANY way, mind you. Though of course, if there
would be a SIMPLE and ELEGANT way, I would be happy.