I want to mix roman numerals with arabic numerals when doing some math.
I would define some classes for each symbol
class I end class V end class X end
Now I want to be able to say things like
5 + V # results in 10 X + 12 # results in 22
But am not sure where to start.
I would have to define a method that tells ruby how 5 + V works, give each class a value, and when I say
I
I should get the value 1.
What kind of methods should I look at that allows me to treat X as the number 10?
Seems really simple to me:
If you want to show the result as roman numerals, I would extend the
Fixnumclass with ato_romanmethod:With this you can do: