Module: RomanNumerals
- Defined in:
- lib/legal_markdown/roman_numerals.rb
Class Method Summary collapse
Class Method Details
.to_decimal_string(value) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/legal_markdown/roman_numerals.rb', line 58 def self.to_decimal_string(value) value.upcase! result = 0 @base_digits.values.reverse.each do |roman| while value.start_with? roman value = value.slice(roman.length, value.length) result += @base_digits.key roman end end result.to_s end |
.to_roman_lower(value) ⇒ Object
54 55 56 |
# File 'lib/legal_markdown/roman_numerals.rb', line 54 def self.to_roman_lower(value) self.to_roman_upper(value).downcase end |
.to_roman_upper(value) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/legal_markdown/roman_numerals.rb', line 42 def self.to_roman_upper(value) value = value.to_i result = '' @base_digits.keys.reverse.each do |decimal| while value >= decimal value -= decimal result += @base_digits[decimal] end end result end |