lib/ecu/labels/value_comparison.rb in automotive-ecu-0.1.1 vs lib/ecu/labels/value_comparison.rb in automotive-ecu-0.1.2

- old
+ new

@@ -7,26 +7,25 @@ end def eql? return false unless @left.class == @right.class case @left - when String then - @left == @right - when Numeric then - @left == @right - when Array then - return false unless @left.size == @right.size - @left.zip(@right).all? do |a, b| - self.class.new(a, b).eql? - end - when NilClass then - @left == @right + when NilClass then @left == @right + when String then @left == @right + when Numeric then @left == @right + when Array then arrays_eql?(@left, @right) else fail "Unkown value class: #{@left.class}" end end private + + def arrays_eql?(left, right) + return false unless left.size == right.size + + left.zip(right).all? { self.class.new(*_1).eql? } + end def check_compatibility(left, right) if left.class != right.class fail ArgumentError, "Values must have the same class for comparison (#{left}: #{left.class}/#{right}: #{right.class})" end