IronRuby is one of the DLR extension on Microsoft .net platform that enable you programming against .net using the Dynamic Language. I will put a very short tutorial, here.
Download the assemblies or just the installer file from http://ironruby.codeplex.com/releases/view/49097#DownloadId=159561
for the installation, it basically puts several .net assemblies to the GAC folder.
Then you can run the IronRuby console, which is the C# version of Irb
when you run process explorer, you will see the loaded Assemblies,
Ir.exe is a standard .net application,
Now, let’s write a basic HelloWorld Ruby application,
First in Ruby Style,
then In C#, we just call System.Console.WriteLine(“Message”). namespace will be mapped to module in Ruby,
Now, you can call the standard .net library, like Datetime
In Ruby, if you want to query the methods of the Object, you can use .methods, we can do this too.
if we want to change the Console foreground color, which we cant do in ruby easily,just call system.foreground_color
here, we can use ruby style naming like foreground_color, or C# style ForegroundColor, the dynamic method dispatcher will delver the call to the right stub,
To using the Base64 encoding that I used pretty often,
in Ruby, it’s easy to subclass to add more methods, say thing error here, I will add one method called writeerror
No comments:
Post a Comment