Sha256: 3b8086179dcad5d424445c48ec09c4db8d822ed9719ddec874247a62d8aa2fe0

Contents?: true

Size: 454 Bytes

Versions: 2

Compression:

Stored size: 454 Bytes

Contents

module GalaxyConverter
  module Roman
    module Rule
      extend self

      LONG_TO_SHORT = {
        "DCCCC" => "CM", # 900
        "CCCC"  => "CD", # 400
        "LXXXX" => "XC", # 90
        "XXXX"  => "XL", # 40
        "VIIII" => "IX", # 9
        "IIII"  => "IV"  # 4
      }

      def call(value)
        LONG_TO_SHORT.reduce(value) do |to_convert, (long, short)|
          to_convert.gsub(short, long)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
galaxy_converter-2.1.2 lib/galaxy_converter/roman_rule.rb
galaxy_converter-2.1.1 lib/galaxy_converter/roman_rule.rb