add diff command variant

This commit is contained in:
2026-04-13 14:57:03 +03:00
parent d8a24a1349
commit 286e79f21a
2 changed files with 78 additions and 38 deletions

View File

@@ -19,19 +19,22 @@ module RubyAlgebra
def to_s
result = "Assignment command: "
result += @lhs.is_a?(Array) ? @lhs.join(', ') : @lhs.to_s
result += ' := '
result += @operand1.to_s
case @operation
when :add
result += ' + '
when :sub
result += ' - '
when :mult, :scale
result += ' * '
when :div
result += ' / '
if @operation == :diff
result += ' := Diff(' + @operand1.to_s + @operand2.map { |v| ", #{v}"}.join + ')'
else
result += ' := ' + @operand1.to_s
case @operation
when :add
result += ' + '
when :sub
result += ' - '
when :mult, :scale
result += ' * '
when :div
result += ' / '
end
result += @operand2.to_s if @operation != :assign
end
result += @operand2.to_s if @operation != :assign
result
end
end