use shift method to improve code

This commit is contained in:
Bilal Catic
2020-02-09 22:26:10 +01:00
parent 2078fabdbe
commit dc70c97ba1

View File

@@ -41,8 +41,8 @@ class TextToSqlQuery
raise "There should be more than 1 element for expression following NOT operator" raise "There should be more than 1 element for expression following NOT operator"
end end
not_expression = not_array.first not_expression = not_array.shift
not_params = not_array[1..] not_params = not_array
["NOT #{not_expression}"] + not_params ["NOT #{not_expression}"] + not_params
@@ -74,11 +74,11 @@ class TextToSqlQuery
raise 'There should be more than 1 element in second operand array' raise 'There should be more than 1 element in second operand array'
end end
first_operand_expression = first_operand.first first_operand_expression = first_operand.shift
first_operand_params = first_operand[1..] first_operand_params = first_operand
second_operand_expression = second_operand.first second_operand_expression = second_operand.shift
second_operand_params = second_operand[1..] second_operand_params = second_operand
["(#{first_operand_expression} #{operator.to_s} #{second_operand_expression})"] + first_operand_params + second_operand_params ["(#{first_operand_expression} #{operator.to_s} #{second_operand_expression})"] + first_operand_params + second_operand_params
end end