Sha256: e964fb78b993184418c1cf90bd6786a3caf9a340fe7f6d01d1ae88386e0edcc0

Contents?: true

Size: 459 Bytes

Versions: 2

Compression:

Stored size: 459 Bytes

Contents

module SexpPath
  # Wraps the results of a SexpPath query.
  # SexpCollection defines SexpCollection#search so that you can
  # chain queries.
  # 
  # For instance:
  #   res = s(:a, s(:b)) / Q?{ s(:a,_) } / Q?{ s(:b) }
  #
  class SexpCollection < Array
    # See Traverse#search
    def search(pattern)
      inject(SexpCollection.new){|collection, match| collection.concat match.sexp.search(pattern, match) }
    end
    alias_method :/, :search
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
adamsanderson-sexp_path-0.4.0 lib/sexp_path/sexp_collection.rb
sexp_path-0.4.0 lib/sexp_path/sexp_collection.rb