class Ecu::Kennfeld

def to_dcm(indented=false)

def to_dcm(indented=false)
  fmtstr = indented ? "%-25s%s %s %s\n" : "%s %s %d %d\n"
  sprintf(fmtstr, type.upcase, name, xdim, ydim).tap do |str|
    str << "  LANGNAME #{description.enquote}\n" if description
    str << "  FUNKTION #{function}\n"            if function
    str << "  EINHEIT_X #{xunit.enquote}\n"      if xunit
    str << "  EINHEIT_Y #{yunit.enquote}\n"      if yunit
    str << "  EINHEIT_W #{unit.enquote}\n"       if unit
    str << case xvalue.first
          when Numeric then "  ST/X #{xvalue.join("   ")}\n"
          when String  then "  ST_TX/X #{xvalue.map(&:enquote).join("   ")}\n"
          end
    yvalue.each_with_index do |entry, idx|
      str << case entry
            when Numeric then "  ST/Y #{entry}\n"
            when String  then "  ST_TX/Y #{entry.enquote}\n"
            end
      str << case value[idx].first
            when Numeric then "  WERT #{value[idx].join("   ")}\n"
            when String  then "  TEXT #{value[idx].map(&:enquote).join("   ")}\n"
            end
    end
    str << "END\n"
  end
end