Class: UnaryMinus

Inherits:
Arity1Operators show all
Defined in:
lib/lamep/Expressions/unary_minus.rb

Constant Summary

Constants inherited from Arity1Operators

Arity1Operators::ARITY

Constants inherited from Operator

Operator::OPERATORS

Instance Attribute Summary

Attributes inherited from Arity1Operators

#operand

Instance Method Summary collapse

Methods inherited from Arity1Operators

#==, #initialize

Methods inherited from Operator

exists?, factory!, operator, precedence!, register

Constructor Details

This class inherits a constructor from Arity1Operators

Instance Method Details

#to_sqlObject



4
5
6
7
8
# File 'lib/lamep/Expressions/unary_minus.rb', line 4

def to_sql
  operand = @operand.to_sql
  fail(ArgumentError, ("#{operand} is not a number")) if operand !~ /^\d+$/
  -operand.to_i
end