Class: Safrano::Filter::BinopArithm

Inherits:
BinopTree show all
Defined in:
lib/odata/filter/sequel.rb,
lib/odata/filter/base.rb,
lib/odata/filter/tree.rb

Overview

Arithmetic Bin ops

Instance Attribute Summary

Attributes inherited from Tree

#parent

Attributes inherited from RootTree

#children, #state

Attributes inherited from Node

#value

Instance Method Summary collapse

Methods inherited from BinopTree

#initialize, #update_state

Methods inherited from Tree

#initialize

Methods inherited from RootTree

#==, #accept?, #apply_to_dataset, #attach, #check_types, #detach, #first_child_value, #initialize, #sequel_expr, #update_state

Methods inherited from Node

#==, #initialize, #success

Constructor Details

This class inherits a constructor from Safrano::Filter::BinopTree

Instance Method Details

#edm_typeObject

TODO: different num types?



285
286
287
# File 'lib/odata/filter/tree.rb', line 285

def edm_type
  :any
end

#leuqes(jh) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/odata/filter/sequel.rb', line 197

def leuqes(jh)
  leuqes_op = case @value
              when :add
                :+
              when :sub
                :-
              when :mul
                :*
              when :div
                :/
              when :mod
                :%
              else
                return Safrano::FilterParseError
              end
  Contract.collect_result!(@children[0].leuqes(jh),
                           @children[1].leuqes(jh)) do |c0, c1|
    Sequel::SQL::NumericExpression.new(leuqes_op, c0, c1)
  end
end

#precedenceObject

reference: OData v4 par 5.1.1.9 Operator Precedence



273
274
275
276
277
278
279
280
281
282
# File 'lib/odata/filter/tree.rb', line 273

def precedence
  case @value
  when :add, :sub
    5
  when :mul, :div, :mod
    6
  else
    999
  end
end