Module: Centurian

Defined in:
lib/centurian.rb,
lib/centurian/version.rb

Constant Summary collapse

ROMAN =
{M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50, XL: 40, X:10, IX: 9, V:5, IV: 4, I: 1}
VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#to_romanObject



6
7
8
9
10
11
# File 'lib/centurian.rb', line 6

def to_roman
  ROMAN.reduce("") do |roman, (k, v)|
    count, number = (number || self).divmod(v)
    roman << (k.to_s * count)
  end
end