Module: Enumpath

Defined in:
lib/enumpath.rb,
lib/enumpath/path.rb,
lib/enumpath/logger.rb,
lib/enumpath/results.rb,
lib/enumpath/version.rb,
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/resolver/simple.rb,
lib/enumpath/operator/wildcard.rb,
lib/enumpath/resolver/property.rb,
lib/enumpath/path/normalized_path.rb,
lib/enumpath/operator/filter_expression.rb,
lib/enumpath/operator/recursive_descent.rb,
lib/enumpath/operator/subscript_expression.rb

Overview

TODO: Investigate supporting anchored paths ($.foo.bar..., @.foo.bar...)

Defined Under Namespace

Modules: Operator, Resolver Classes: Path, Results

Constant Summary collapse

VERSION =
'0.1.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.verbosetrue, false

Whether verbose mode is enabled. When enabled, the Logger will print information to the logging stream to assist in debugging path expressions. Defaults to false

Returns:

  • (true, false)


22
23
24
# File 'lib/enumpath.rb', line 22

def verbose
  @verbose
end

Class Method Details

.apply(path, enum, options = {}) ⇒ Enumpath::Results

Resolve a path expression against an enumerable

Parameters:

  • options (optional, Hash) (defaults to: {})
  • path (String, Array<String>)

    the path expression to apply to the enumerable

  • enum (Enumerable)

    the enumerable to apply the path to

Options Hash (options):

  • :result_type (Symbol) — default: :value

    The type of results to return, :value or :path

  • :verbose (true, false) — default: false

    Whether to enable additional output for debugging

Returns:



32
33
34
35
36
# File 'lib/enumpath.rb', line 32

def apply(path, enum, options = {})
  logger.level = 0
  @verbose = options.delete(:verbose) || false
  Enumpath::Path.new(path, result_type: options.delete(:result_type)).apply(enum)
end