Skip to content

Instantly share code, notes, and snippets.

@jschementi
Created December 12, 2009 08:24
Show Gist options
  • Save jschementi/254800 to your computer and use it in GitHub Desktop.
Save jschementi/254800 to your computer and use it in GitHub Desktop.
// create a ScriptRuntime, the portal to the DLR Hosting API
// CreateFromConfiguration gets information, like languages
// are available, from an app.config configuration file
var runtime = ScriptRuntime.CreateFromConfiguration();
// create a ScriptEngine for IronRuby
var engine = runtime.GetEngine("IronRuby");
// a ScriptScope stores state between executions
var scope = engine.CreateScope();
// expose the current instance as "window" to the scripts
scope.SetVariable("window", this);
// execute a script against the scope, which modifies
// that "window" variable set previously.
engine.Execute("window.Message.Text = 'Hello from Ruby!'", scope);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment