Ruby Tuesday #18 : Ruby meets .NET
A couple of weeks ago, I posted that John Lam had announced a binary release of IronRuby. So, I downloaded the zip file and extracted it to the root of my C drive. That created a folder called IronRuby on my C drive containing all the IronRuby goodness. In the IronRuby folder, there’s a bin folder in which is ir.exe, so I added C:\IronRuby\bin to my system PATH variable. I opened a command window and typed ir and saw this:
Now that I had IronRuby running, I did the obvious stuff – putting Hello World, adding some numbers and so on. Next, I tried calling .NET from IronRuby. I typed the following lines into the console;
require ‘mscorlib’ require 'System.Windows.Forms, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b77a5c561934e089' require 'System.Drawing, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Form = System::Windows::Forms::Form $f = Form.new $f.Text = “Hello World!” System::Windows::Forms::Application.run $f
I’m using $f (a global variable for those new to Ruby) because, as the console says, local variables aren’t supported yet in console mode. And, this is what I saw:
.NET written in Ruby. There’s a lot more here to explore.