require_relative "property_parser" class Ecu class Label def self.from_dcm(input) lines = case input in Array then input in String then input.lines end hsh = dcm_header.extract_captures(lines.first) hsh[:xdim] = hsh[:xdim].to_i if hsh.key?(:xdim) hsh[:ydim] = hsh[:ydim].to_i if hsh.key?(:ydim) fail "Malformed DCM" if hsh.empty? fail "Malformed DCM" unless lines.last.match?(/^END$/) lines[1..-2] .map { DcmPropertyParser.call(_1) } .each { hsh.merge!(_1) { |_, old, new| old + new } } new(**hsh) end end end