add diff command variant
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user