irb でお試しRubyCLR

irbから.NET Frameworkのクラスを叩ける日が来るとは!

こんなんでRubyからWindows FormsのMessageBox.Showを叩いてメッセージボックスが出せる!

irb(main):001:0> require 'irb/completion'
irb(main):002:0> require 'rubyclr'
irb(main):003:0> reference 'System.Windows.Forms'
irb(main):004:0> include System::Windows::Forms
irb(main):005:0> MessageBox.Show 'Hello, RubyCLR!'

基本は、RubyCLR読み込んで、referenceでアセンブリ読み込んだら、それで.NETのクラス呼べる。名前空間長ければincludeがC#のusingと同じ意味で使える。
物によっては require 'rubygems' もいるかも。

いやー、RubyCLRおもろいね。.irbrc に RubyCLR 入れとこうかしら