Class: DDQL::Operators
- Inherits:
-
Object
- Object
- DDQL::Operators
- Includes:
- Singleton
- Defined in:
- lib/ddql/operators.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Operators
constructor
A new instance of Operators.
Constructor Details
#initialize ⇒ Operators
Returns a new instance of Operators.
33 34 35 |
# File 'lib/ddql/operators.rb', line 33 def initialize @cache = build_cache end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
15 16 17 |
# File 'lib/ddql/operators.rb', line 15 def cache @cache end |
Class Method Details
.float_map_ops ⇒ Object
17 18 19 |
# File 'lib/ddql/operators.rb', line 17 def self.float_map_ops instance.cache.select { |_, v| v.is_a? InfixFloatMapOperator } end |
.operator_regex(operator_type) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ddql/operators.rb', line 21 def self.operator_regex(operator_type) ops = instance.cache.select { |k, v| v.type?(operator_type) } if ops.empty? # if there are no registered operators of the given type use negative # lookahead to generate a regex pattern that can never be matched return /(?!x)x/ else ops.keys[1..-1].inject(ops.keys.first) { |a, e| Regexp.union(a, ops[e].pattern) } end end |