Sha256: 6d2e4a5a6086f96937c4ea2615f0929bc9607704548142b7924c325044b6a3e3
Contents?: true
Size: 432 Bytes
Versions: 4
Compression:
Stored size: 432 Bytes
Contents
require "galaxy_converter/roman_numeral" module GalaxyConverter class Converter def initialize(mapping = {}, unit = RomanNumeral) @mapping = mapping @unit = unit end def call(units) converted = convert(units) @unit.new(converted).to_i end private def convert(units) units.split(" ").reduce("") do |acc, unit| acc << @mapping.fetch(unit, "") end end end end
Version data entries
4 entries across 4 versions & 1 rubygems