Class: PGB::OperatorCall
- Inherits:
-
Expression
- Object
- Expression
- PGB::OperatorCall
- Defined in:
- lib/pgb/operator_call.rb
Instance Method Summary collapse
-
#initialize(operator, expression1, expression2 = nil) ⇒ OperatorCall
constructor
TODO Validate and parse operators www.postgresql.org/docs/current/functions.html.
- #to_sql ⇒ Object
Methods included from SQLDisplayable
Constructor Details
#initialize(operator, expression1, expression2 = nil) ⇒ OperatorCall
TODO Validate and parse operators www.postgresql.org/docs/current/functions.html
7 8 9 10 11 |
# File 'lib/pgb/operator_call.rb', line 7 def initialize(operator, expression1, expression2 = nil) @operator = operator.to_s @expression1 = to_expression(expression1) @expression2 = to_expression(expression2) if expression2 end |
Instance Method Details
#to_sql ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/pgb/operator_call.rb', line 13 def to_sql if unary? "#{operator}#{expression1}" else "#{expression1} #{operator} #{expression2}" end end |