I just finished giving my talk on IronRuby at the Richmond Code Camp 2008.2. It was titled “Microsoft and Ruby Sittin’ in a Tree”. I tried to cover a huge number of features in Ruby very quickly and then show off a few Ruby snippets that demonstrate many of its cool features. As usual you probably won’t get a huge amount out of the slides without seeing the accompanying presentation, but you can still go through it if you would like. I have included the source for my demos in the zip as well, and that is probably the more interesting part. It has some basic language primer, which I didn’t get to in the presentation, and it also has some more advanced “showy” demos.
I demonstrate 5 main things in the code samples:
1) A proxy class that allows you to pass an instance of a class to its constructor and then intercept method calls and do something. Just wanted to show how easy it is in Ruby with method_missing.
2) Second it shows off a recorder which lets you call a bunch of methods on a recorder object and then play those calls back against a target object. I wanted to implement this and search online and found an example of Jay Field’s blog. I studied his implementation for mine, so I have to give props.
3) Third I showed off a bit of Meta-Programming which uses class_eval and define_method to create new methods on a class.
4) Fourth I showed off a bit of .net Interop which just displays a form with a field and a button. It shows assigning a block to use as an event handler.
5) Fifth I showed how to consume a WSDL file in Ruby and then call the web service. Then I use REXML to parse the resulting XML and display it in the console. This the only of the five demonstrations that won’t run yet under IronRuby.
If you would like to see the presentation or accompanying source files, you can download it here.
Loved the article? Hated it? Didn’t even read it?
We’d love to hear from you.