lib/ecu/interfaces/dcm/stuetzstellenverteilung.rb



class Ecu
  class Stuetzstellenverteilung < Label
    def self.dcm_header
      %r{STUETZSTELLENVERTEILUNG\s+(?<name>[A-Za-z0-9\._]+)\s+(?<xdim>\d+)}
    end

    def to_dcm
      "#{type.upcase} #{name} #{xdim}\n".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 << case xvalue.first
        when Numeric then "  ST/X #{xvalue.join(" ")}\n"
        when String then  "  ST_TX/X #{xvalue.map(&:enquote).join(" ")}\n"
        end
        str << "END\n"
      end
    end
  end
end