Module: Enumpath::Operator
- Defined in:
- lib/enumpath/operator.rb,
lib/enumpath/operator/base.rb,
lib/enumpath/operator/child.rb,
lib/enumpath/operator/slice.rb,
lib/enumpath/operator/union.rb,
lib/enumpath/operator/wildcard.rb,
lib/enumpath/operator/filter_expression.rb,
lib/enumpath/operator/recursive_descent.rb,
lib/enumpath/operator/subscript_expression.rb
Overview
Namespace for classes that represent path expression operators
Defined Under Namespace
Classes: Base, Child, FilterExpression, RecursiveDescent, Slice, SubscriptExpression, Union, Wildcard
Constant Summary collapse
- ROOT =
'$'
Class Method Summary collapse
-
.detect(operator, enum) ⇒ Object
Infer the type of operator and return an instance of its Enumpath::Operator subclass.
Class Method Details
.detect(operator, enum) ⇒ Object
Infer the type of operator and return an instance of its Enumpath::Operator subclass
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/enumpath/operator.rb', line 24 def detect(operator, enum) if Enumpath::Operator::Child.detect?(operator, enum) Enumpath.log('Child operator detected') Enumpath::Operator::Child.new(operator) elsif Enumpath::Operator::Wildcard.detect?(operator) Enumpath.log('Wildcard operator detected') Enumpath::Operator::Wildcard.new(operator) elsif Enumpath::Operator::RecursiveDescent.detect?(operator) Enumpath.log('Recursive Descent operator detected') Enumpath::Operator::RecursiveDescent.new(operator) elsif Enumpath::Operator::Union.detect?(operator) Enumpath.log('Union operator detected') Enumpath::Operator::Union.new(operator) elsif Enumpath::Operator::SubscriptExpression.detect?(operator) Enumpath.log('Subscript Expression operator detected') Enumpath::Operator::SubscriptExpression.new(operator) elsif Enumpath::Operator::FilterExpression.detect?(operator) Enumpath.log('Filter Expression operator detected') Enumpath::Operator::FilterExpression.new(operator) elsif Enumpath::Operator::Slice.detect?(operator) Enumpath.log('Slice operator detected') Enumpath::Operator::Slice.new(operator) else Enumpath.log('Not a valid operator for enum') nil end end |