On Feb 2, 2008 8:49 PM, Todd Benson <caduceass / gmail.com> wrote:
> Actually, better production code that keeps in line with OO concepts would be...
>
> class Integer
>   ROMAN = {
>     1 => "I",
>     5 => "V",
>     10 => "X",
>     50 => "L",
>     100 => "C",
>     500 => "D",
>     1000 => "M"
>   }
>
>   def roman
>     number, roman_string = self, ""
>     ROMAN.keys.sort.reverse.each do |key|
>       roman_string << (ROMAN[n] * (number/key)
>       n %= key
>     end
>     roman_string
>   end
> end
>
> #usage
> puts 2137.roman
> # => "MMCCCXVII"
>
> I'm pretty sure there were better and more thorough examples at
> http://www.rubyquiz.com/quiz22.html.

gsub('number', 'n') on that code...and there's a missing parenthesis
")" number/key line

Yeah, yeah

That's what I get for not using cut and paste :-)

Todd