class Ecu::Label

def self.from_lab(line)

def self.from_lab(line)
  name, description = line.strip.split(";")
  if description.nil?
    Festwert.new(name: name, value: nil)
  else
    Festwert.new(name: name, value: nil, description: description)
  end
end

def <=>(other)

def <=>(other)
  name <=> other.name if other.respond_to?(:name)
end

def ==(other)

def ==(other)
  return false unless other.instance_of?(self.class)
  equality_properties.all? do |p|
    if %i(value xvalue yvalue).include?(p)
      ValueComparison.new(self.public_send(p), other.public_send(p)).eql?
    else
      self.public_send(p) == other.public_send(p)
    end
  end
end

def ===(other)

def ===(other)
  name == other.name
end

def equality_properties

def equality_properties
  fail NotImplementedError, "Must be implemented in child classes"
end

def hash

def hash
  equality_properties.map { |p| self.public_send(p) }.hash
end

def init_error(message)

def init_error(message)
  fail ArgumentError, "Error creating #{name}: " +
    message + "\n" +
    inspect_instance_vars + "\n\n"
end

def inspect_instance_vars

def inspect_instance_vars
  instance_variables
    .map { "#{_1} = #{instance_variable_get(_1)}" }
    .join("\n")
end

def match(selector)

def match(selector)
  %i(name function description).any? do |property|
    self.public_send(property) && self.public_send(property).match(selector)
  end
end

def properties

def properties
  fail NotImplementedError, "Must be implemented in child classes"
end

def to_dcm

def to_dcm
  fail "To be defined by child classes"
end

def to_h

def to_h
  properties.zip(properties.map { |p| instance_variable_get("@#{p}".to_sym) }).to_h
end

def to_lab

def to_lab
  "#{name};#{description}"
end

def type

def type
  self.class.name.split('::').last
end

def valuestats(value, show_avg: false)

def valuestats(value, show_avg: false)
  value = [value].flatten
  min, avg, max = value.min, value.avg.round(1), value.max
  if show_avg
    "[#{min};~#{avg};#{max}]"
  else
    "[#{min};#{max}]"
  end
end

def with(hash={})

def with(hash={})
  return self if hash.empty?
  self.class.new(**to_h.merge(hash))
end