On Feb 4, 2008 12:20 PM, Moises Trovo <moises.trovo / gmail.com> wrote:
>  actually ROMAN[key] and not working with numbers having a 9.

Here's the copy and pasted code...

class Integer
 ROMAN = {
   1 => "I",
   5 => "V",
   10 => "X",
   50 => "L",
   100 => "C",
   500 => "D",
   1000 => "M"
 }

 def roman
   n, roman_string = self, ""
   ROMAN.keys.sort.reverse.each do |key|
     roman_string << (ROMAN[key] * (n/key))
     n %= key
   end
   roman_string
 end
end

#usage
puts 2319.roman
# => "MMCCCXVIIII"


cheers,
Todd