Jason said:
I have worked with PHP in the past and have been playing with Ruby for a
few weeks. =A0I made a program that I would love to get feedback on. =A0= Any
comments would be great. =A0I have my program on Git hub.
http://github.com/jasonhamilton/NZBMatrix-Downloader
Well, the conversion isn't accurate yet, but using your approach, here's
another way to do it that allows you to easily grow the list of numerals
to be converted:
def convert(b10number)
=A0numerals =A0 =A0 =3D ['M','D','C','L','X','V','I']
=A0values =A0 =A0 =A0 =3D [1000,500,100,50,10,5,1]
=A0implemented =A0 =3D []
=A0conversion =A0 =A0 =3D ""
=A0remainder =A0 =A0 =3D b10number
=A0values.each do |this_value|
=A0 =A0if this_value > 1
=A0 =A0 =A0implemented << remainder/this_value
=A0 =A0 =A0remainder =3D remainder % this_value
=A0 =A0else
=A0 =A0 =A0implemented << remainder
=A0 =A0end
=A0end
=A0implemented.each_with_index do |this_many, indx|
=A0 =A0conversion +=3D (numerals[indx] * this_many)
=A0end
=A0puts conversion
end
puts 'Howdy there, enter a number and I\'ll convert it to the older
Roman Numeral fashion!'
argument =3D gets.chomp.to_i
convert argument