Class: Enumpath::Operator::Base Abstract
- Inherits:
-
Object
- Object
- Enumpath::Operator::Base
- Defined in:
- lib/enumpath/operator/base.rb
Overview
Subclass and override Base.detect? and #apply to implement a new path expression operator.
Abstract base class for Operator definitions. Provides some helper methods for each operator and defines the basic factory methods that must be implemented.
Direct Known Subclasses
Child, FilterExpression, RecursiveDescent, Slice, SubscriptExpression, Union, Wildcard
Instance Attribute Summary collapse
-
#operator ⇒ String
readonly
The full, normalized operator.
Class Method Summary collapse
-
.detect?(operator, enum = nil) ⇒ true, false
abstract
Provides an interface for determining if a given string represents the operator class.
Instance Method Summary collapse
-
#apply(remaining_path, enum, resolved_path) {|remaining_path, enum, resolved_path| ... } ⇒ Object
abstract
Provides an interface for applying the operator to a given enumerable and yielding that result back to the caller with updated arguments.
-
#initialize(operator) ⇒ Base
constructor
Initializes an operator class with an operator string.
Constructor Details
#initialize(operator) ⇒ Base
Initializes an operator class with an operator string
30 31 32 |
# File 'lib/enumpath/operator/base.rb', line 30 def initialize(operator) @operator = operator end |
Instance Attribute Details
#operator ⇒ String (readonly)
Returns the full, normalized operator.
25 26 27 |
# File 'lib/enumpath/operator/base.rb', line 25 def operator @operator end |
Class Method Details
.detect?(operator, enum = nil) ⇒ true, false
Override in each path expression operator subclass
Provides an interface for determining if a given string represents the operator class
19 20 21 |
# File 'lib/enumpath/operator/base.rb', line 19 def detect?(operator, enum = nil) raise NotImplementedError end |
Instance Method Details
#apply(remaining_path, enum, resolved_path) {|remaining_path, enum, resolved_path| ... } ⇒ Object
Override in each path expression operator subclass
Provides an interface for applying the operator to a given enumerable and yielding that result back to the caller with updated arguments
50 51 52 |
# File 'lib/enumpath/operator/base.rb', line 50 def apply(remaining_path, enum, resolved_path) raise NotImplementedError end |