Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Created April 12, 2009 01:36
Show Gist options
  • Save jashkenas/93814 to your computer and use it in GitHub Desktop.
Save jashkenas/93814 to your computer and use it in GitHub Desktop.
// Spin up a new Ruby VM, start Ruby-Processing in it.
private void spinUp(String command, String path) {
final RubyInstanceConfig config = new RubyInstanceConfig() {{
setLoader(this.getClass().getClassLoader());
}};
if (_ruby != null) _ruby.tearDown();
_ruby = Ruby.newInstance(config);
_ruby.evalScriptlet("RP5_EMBEDDED = true; ARGV[0] = '" + path + "'; require 'ruby-processing/lib/ruby-processing/runners/" + command + ".rb'");
}
// Spin down the current running Ruby VM.
private void spinDown() {
_ruby.evalScriptlet("$app.close");
// TODO: Seems to leak memory ... System.gc() doesn't help...
_ruby.tearDown();
_ruby = null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment