Class: Operator
- Inherits:
-
Expression
- Object
- Expression
- Operator
- Defined in:
- lib/eno/expressions.rb
Constant Summary collapse
- S_OP =
' %s '
- S_OP_EXPR =
'(%s)'
- INVERSE_OP =
{ '=' => '<>', '<>' => '=', '<' => '>=', '>' => '<=', '<=' => '>', '>=' => '<' }
Constants inherited from Expression
Expression::S_AND, Expression::S_DIV, Expression::S_EQ, Expression::S_GT, Expression::S_GTE, Expression::S_LT, Expression::S_LTE, Expression::S_MINUS, Expression::S_MOD, Expression::S_MUL, Expression::S_NEQ, Expression::S_OR, Expression::S_PLUS, Expression::S_TILDE
Instance Attribute Summary collapse
-
#op ⇒ Object
readonly
Returns the value of attribute op.
Attributes inherited from Expression
Instance Method Summary collapse
- #!@ ⇒ Object
-
#initialize(op, *members, **props) ⇒ Operator
constructor
A new instance of Operator.
- #to_sql(sql) ⇒ Object
Methods inherited from Expression
#!=, #%, #&, #*, #+, #-, #/, #<, #<=, #==, #=~, #>, #>=, #^, #as, #cast, #desc, #in, #inner_join, #join, #not_in, #not_null?, #null?, #over, #|
Constructor Details
#initialize(op, *members, **props) ⇒ Operator
Returns a new instance of Operator.
336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/eno/expressions.rb', line 336 def initialize(op, *members, **props) if Operator === members[0] && op == members[0].op members = members[0].members + members[1..-1] end if Operator === members.last && op == members.last.op members = members[0..-2] + members.last.members end super(*members, **props) @op = op end |
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
334 335 336 |
# File 'lib/eno/expressions.rb', line 334 def op @op end |
Instance Method Details
#!@ ⇒ Object
365 366 367 368 |
# File 'lib/eno/expressions.rb', line 365 def !@ inverse = INVERSE_OP[@op] inverse ? Operator.new(inverse, *@members) : super end |