module RomanNumerals

adapted without any substanial changes from github.com/AndrewVos/roman-numerals

Constants

BASE_DIGITS

Public Instance Methods

to_lower_roman(value) click to toggle source
# File lib/modules/roman_numerals.rb, line 30
def to_lower_roman(value)
  to_upper_roman(value).downcase
end
to_upper_roman(value) click to toggle source
# File lib/modules/roman_numerals.rb, line 19
def to_upper_roman(value)
  result = ''
  BASE_DIGITS.keys.reverse.each do |decimal|
    while value >= decimal
      value -= decimal
      result += BASE_DIGITS[decimal]
    end
  end
  result
end