class DDQL::TokenType::Operator
Constants
- NULL_TYPES
Public Instance Methods
as_hash(data)
click to toggle source
# File lib/ddql/token_type.rb, line 271 def as_hash(data) return NullOperators.instance.as_hash(data) if data =~ NULL_TYPES {op: {op_symbol(data) => data}} end
comparison?(data)
click to toggle source
# File lib/ddql/token_type.rb, line 276 def comparison?(data) Operators.instance.cache[data]&.comparison? end
complex_comparison?(data)
click to toggle source
# File lib/ddql/token_type.rb, line 280 def complex_comparison?(data) Operators.instance.cache[data]&.complex_comparison? end
math?(data)
click to toggle source
# File lib/ddql/token_type.rb, line 284 def math?(data) Operators.instance.cache[data]&.math? end
parse(parser, token, expression: nil)
click to toggle source
# File lib/ddql/token_type.rb, line 288 def parse(parser, token, expression: nil) operator = Operators.instance.cache[token.op_data] if expression.nil? && !operator&.prefix? raise "expected op[#{operator&.name}] to be part of an expression" end operator.parse(parser, token, expression: expression) end
simple_comparison?(data)
click to toggle source
# File lib/ddql/token_type.rb, line 296 def simple_comparison?(data) Operators.instance.cache[data]&.simple_comparison? end
Protected Instance Methods
op_symbol(data)
click to toggle source
# File lib/ddql/token_type.rb, line 302 def op_symbol(data) float_map_ops = Operators.float_map_ops case data when '==', '='; :op_eq when '!='; :op_ne when '>'; :op_gt when '>='; :op_ge when '<'; :op_lt when '<='; :op_le when '+'; :op_add when '-'; :op_subtract when '*'; :op_multiply when '/'; :op_divide when '%'; :op_mod when '^'; :op_power when 'ON'; :op_date_on when 'EPST'; :op_date_after_or_on when 'EPRE'; :op_date_before_or_on when 'PST'; :op_date_after when 'PRE'; :op_date_before when 'EXISTS'; :op_exist when 'LCTN'; :op_ctn when *float_map_ops.keys; float_map_ops[data].op_symbol else :"op_#{data.downcase.gsub(' ', '_')}" end end