Skip to content

Instantly share code, notes, and snippets.

@FredrikL
Created June 21, 2011 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FredrikL/1038709 to your computer and use it in GitHub Desktop.
Save FredrikL/1038709 to your computer and use it in GitHub Desktop.
IronRuby + C#
using System;
using Microsoft.Scripting.Hosting;
using IronRuby;
namespace IronRubyHostTest
{
public class Meh
{
public void baz()
{
Console.WriteLine("Baz");
}
}
class Program
{
static void Main(string[] args)
{
string script = @"
require 'IronRubyHostTest.exe'
class Foo < IronRubyHostTest::Meh
def bar
puts 'foo baz'
end
def baz
puts 'BAZ BAZ BAZ'
end
end
Foo.new";
ScriptEngine engine = Ruby.CreateEngine();
dynamic foo = engine.Execute(script);
foo.baz();
foo.bar();
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment