Class: Enumpath::Path
- Inherits:
-
Object
- Object
- Enumpath::Path
- Defined in:
- lib/enumpath/path.rb,
lib/enumpath/path/normalized_path.rb
Overview
A mechanism for applying path expressions to enumerables and tracking results
Defined Under Namespace
Classes: NormalizedPath
Instance Attribute Summary collapse
-
#path ⇒ Enumpath::Path::NormalizedPath
readonly
The normalized path.
-
#results ⇒ Enumpath::Results
readonly
The current results array.
Instance Method Summary collapse
-
#apply(enum) ⇒ Enumpath::Results
Apply the path expression against an enumerable.
-
#initialize(path, result_type: nil) ⇒ Path
constructor
A new instance of Path.
Constructor Details
Instance Attribute Details
#path ⇒ Enumpath::Path::NormalizedPath (readonly)
Returns the normalized path.
9 10 11 |
# File 'lib/enumpath/path.rb', line 9 def path @path end |
#results ⇒ Enumpath::Results (readonly)
Returns the current results array.
12 13 14 |
# File 'lib/enumpath/path.rb', line 12 def results @results end |
Instance Method Details
#apply(enum) ⇒ Enumpath::Results
Note:
Calling this method resets the previous results array
Apply the path expression against an enumerable
28 29 30 31 32 |
# File 'lib/enumpath/path.rb', line 28 def apply(enum) results.clear trace(@path.dup, enum) results end |