From: Steve Klabnik Date: 2012-02-09T02:15:08+09:00 Subject: Re: A better way implement "it" the ruby way This code is pretty easy to translate to straight Ruby, I spent about 15 minutes refactoring this, and there's one non-obvious thing: I tend to make code like this an object, via something like "Replace Method with Method Object"[1]. It's a refactoring that's used primarily for extracting long methods out of a parent class, but I've found that every time I want to write some sort of function rather than a method, I end up having to write two or three, then I wrap them in a module, and it ends up basically becoming an object with a few methods anyway. Don't use 'compute' though, it's a terrible name. I'd end up using something like "Key.generate(number)" for a final interface. > in the process of learning Ruby I am trying to implement a few algorithms. You won't find a whole lot different in straight up algorithmic code. Ruby offers basically the same things other languages do, so it won't really be all that different. However, in more complicated situations, where you have lots of moving parts interacting, Ruby really starts to shine. 1: http://sourcemaking.com/refactoring/replace-method-with-method-object