Class: TransactionQL::NumericExpression
- Inherits:
-
Expression
- Object
- Expression
- TransactionQL::NumericExpression
- Defined in:
- lib/transaction_ql/expressions.rb
Instance Method Summary collapse
-
#initialize(column, other, operator) ⇒ NumericExpression
constructor
A new instance of NumericExpression.
- #matches?(hash) ⇒ Boolean
Constructor Details
#initialize(column, other, operator) ⇒ NumericExpression
Returns a new instance of NumericExpression.
9 10 11 12 13 |
# File 'lib/transaction_ql/expressions.rb', line 9 def initialize(column, other, operator) @column = column @other = other @operator = operator end |
Instance Method Details
#matches?(hash) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/transaction_ql/expressions.rb', line 15 def matches?(hash) case @other when Numeric hash.fetch(@column).send @operator, @other when String if !hash[@other].is_a? Numeric raise "Column `#{@other}` is not numeric!" end hash.fetch(@column).send @operator, hash.fetch(@other) else raise 'Unsupported right hand type.' end end |