Sha256: b766ed4babe50f27be58939042b3b0d882d4a7e6b6e4980c59cd57f0f19dfc6b

Contents?: true

Size: 892 Bytes

Versions: 4

Compression:

Stored size: 892 Bytes

Contents

require_relative "../../../core_ext"

class Ecu
  class Festwerteblock < Label
    def self.dcm_header
      %r{^FESTWERTEBLOCK\s+(?<name>[A-Za-z0-9\._]+)\s+(?<xdim>\d+)(?:\s+@\s+(?<ydim>\d+))?}
    end

    def to_dcm(indented=false)
      fmtstr = indented ? "%-25s%s %s" : "%s %s %d"

      sprintf(fmtstr, type.upcase, name, xdim).tap do |str|
        str << " @ #{ydim}" if ydim != 1
        str << "\n"
        str << "  LANGNAME #{description.enquote}\n" if description
        str << "  FUNKTION #{function}\n"            if function
        str << "  EINHEIT_W #{unit.enquote}\n"       if unit
        value.each do |row|
          str << case row.first
                 when Numeric then "  WERT #{row.join("   ")}\n"
                 when String  then "  TEXT #{row.map(&:enquote).join("   ")}\n"
                 end
        end
        str << "END\n"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
automotive-ecu-0.1.9 lib/ecu/interfaces/dcm/festwerteblock.rb
automotive-ecu-0.1.8 lib/ecu/interfaces/dcm/festwerteblock.rb
automotive-ecu-0.1.7 lib/ecu/interfaces/dcm/festwerteblock.rb
automotive-ecu-0.1.6 lib/ecu/interfaces/dcm/festwerteblock.rb