Sha256: 5b248ac88a061db92c184a485dd635c2764367f930f5e8445535ab9c4c7ee4f1

Contents?: true

Size: 634 Bytes

Versions: 11

Compression:

Stored size: 634 Bytes

Contents

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
automotive-ecu-0.1.10 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.9 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.8 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.7 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.6 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.5 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.4 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.3 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.2 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.1 lib/ecu/interfaces/dcm/label.rb
automotive-ecu-0.1.0 lib/ecu/interfaces/dcm/label.rb