Verbose Logging

software development with some really amazing hair

T+SGFR

Simple Ruby Pipes

· · Posted in Programming · Tagged with

Here’s something I cooked up this evening. Nothing too epic, but it’s a neat illustration of metaprogramming with ruby.

Can't see this Gist? View it on Github!

Ruby allows you to reopen classes and add methods to them. You can also make a Module and include that in a class to add methods. I’ve added four methods to the Symbol class and overridden one method in the Array class (using alias to keep the old method around since super doesn’t quite work).

Now we can pipe arrays like bash using a simple syntax! Wee!


Sharing is Caring

If you liked this post, you might like these: