Class: Flounder::Expression::BinaryOp
- Defined in:
- lib/flounder/expression.rb
Instance Attribute Summary collapse
-
#op_string ⇒ Object
Returns the value of attribute op_string.
Instance Method Summary collapse
- #concat(term) ⇒ Object
-
#initialize(domain, op_string, *terms) ⇒ BinaryOp
constructor
A new instance of BinaryOp.
- #to_sql ⇒ Object
Methods inherited from Expr
#&, #as, #cast, #db_quote, #eval, #to_immediate, #|
Constructor Details
#initialize(domain, op_string, *terms) ⇒ BinaryOp
Returns a new instance of BinaryOp.
107 108 109 110 111 112 |
# File 'lib/flounder/expression.rb', line 107 def initialize domain, op_string, *terms super(domain) @op_string = op_string @terms = terms end |
Instance Attribute Details
#op_string ⇒ Object
Returns the value of attribute op_string.
114 115 116 |
# File 'lib/flounder/expression.rb', line 114 def op_string @op_string end |
Instance Method Details
#concat(term) ⇒ Object
116 117 118 |
# File 'lib/flounder/expression.rb', line 116 def concat term @terms << term end |
#to_sql ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/flounder/expression.rb', line 120 def to_sql "(" + @terms. map { |t| eval(t) }. join(" #{op_string} ") + ")" end |