[Ironruby-core] Still plugging away at some simple IronRuby stuff

Greg Akins angrygreg at gmail.com
Sun Jan 27 20:30:06 EST 2008


OK, I'm making progress.. Though my wife just got home, so this might
not last much longer ;-)

I am following the example at
http://ironruby.rubyforge.org/wiki/wiki.pl?ExecutingIronRubyFromCSharp

   NOTE:  I tried to be helpful and update that page with the examples
that were just posted to the list, but now the page includes this the
IScriptModule().SetVariable code - which doesn't appear to be valid
anymore)

This is what I'm using instead and I get a MissingMethod error on
widget.  I'd try using this method (
scriptenvironment.ExecuteSourceUnit(rubyengine.CreateScriptSourceFromString(script)
);  ) but CreateScriptSourceFromString doesn't appear to have a
signature for IScriptModule, or IScriptScope.

Thoughts?

           IScriptEnvironment scriptenvironment =
ScriptEnvironment.GetEnvironment();
           IScriptEngine rubyengine = scriptenvironment.GetEngine("ruby");

           string script = "puts 'Ruby and  ' + widget.to_s + '
together at last'";
           IScriptScope scope = scriptenvironment.CreateScope();
           scope.SetVariable("widget", ".Net");
           rubyengine.Execute(scope,
rubyengine.CreateScriptSourceFromString(script));
           Console.ReadKey();



-- 
Greg Akins
Software Development Manager
SSI Services

http://kc.vanadium.com
http://www.pghcodingdojo.org
http://www.insomnia-consulting.org/monologue


More information about the Ironruby-core mailing list