Module: Rookout::Processor::Paths::Canopy
- Defined in:
- lib/rookout/processor/paths/canopy/consts.rb,
lib/rookout/processor/paths/canopy/actions.rb,
lib/rookout/processor/paths/canopy/markers.rb
Defined Under Namespace
Classes: Actions, AttributeOperation, Bool, Char, FloatNumber, FunctionOperation, List, LookupOperation, Marker, NamespaceResult, Nil, Number, ObjectMarker, Operation, Opt, Text, TextResult, ToolExceptionMarker
Constant Summary collapse
- LEVEL1 =
["*", "/"].freeze
- LEVEL2 =
["+", "-"].freeze
- LEVEL3 =
["<=", ">=", "!=", "=", "==", ">", "<", "LT", "GT", "LE", "GE", "EQ", "NE", "lt", "gt", "le", "ge", "eq", "ne"].freeze
- LEVEL4 =
["in"].freeze
- LEVEL5 =
["or", "OR", "||", "and", "AND", "&&"].freeze
- ALL_LEVELS =
[LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5].freeze
- PRIMITIVES =
[Array, Hash, TrueClass, FalseClass, Symbol, Integer, Float, Complex, Rational, BigDecimal, String].freeze
- OPS_ALTERNATIVES =
{ "NE" => "!=", "=" => "==", "EQ" => "==", "LT" => "<", "GT" => ">", "GE" => ">=", "LE" => "<=", "AND" => "and", "OR" => "or", "&&" => "and", "IN" => "in", "||" => "or" }.freeze
- OPS_FUNCTIONS =
{ "+" => ->(a, b) { a + b }, "-" => ->(a, b) { a - b }, "/" => ->(a, b) { a / b }, "*" => ->(a, b) { a * b }, "<" => ->(a, b) { a < b }, "<=" => ->(a, b) { a <= b }, ">" => ->(a, b) { a > b }, ">=" => ->(a, b) { a >= b }, "!=" => ->(a, b) { a != b }, "=" => ->(a, b) { a == b }, "==" => ->(a, b) { a == b }, "in" => lambda do |a, b| # If both are strings, just call include return b.include? a if b.is_a?(String) && a.is_a?(String) # If it's a dict, scan the keys, compensating for additional abstraction if b.is_a? Hash b.each_key do |key| case key when ObjectMarker return true if key.obj == a when a return true end end return false end # If it's an array, scan the value, compensating for additional abstraction if b.is_a? Array b.each do |value| case value when ObjectMarker return true if value.obj == a when a return true end end return false end false end, "and" => ->(a, b) { a && b }, "or" => ->(a, b) { a || b } }.freeze