require_relative "label" class Ecu class Festwert < Label attr_reader :value, :unit def initialize(name:, value:, unit: nil, function: nil, description: nil) @name = name @value = value.is_a?(Array) ? value.first : value @unit = unit @function = function @description = description end def round_to(n) return self unless value.is_a?(Numeric) self.with \ value: value.round(n) end def bytesize BYTESIZE[:number] end def to_s(detail: false) if detail == :justvalue value.to_s elsif detail == :value "#{name}: #{value}" elsif detail == :onelinefull "#{name}: #{to_s(detail: :oneline)}" elsif detail == :oneline "#{value}" elsif detail <<~EOS #{name}: #{type} Value: #{value} Unit: "#{unit}" EOS else "#{name}: #{type}" end end def properties [:name, :value, :unit, :function, :description] end def equality_properties [:name, :value] end end end