Sha256: dc652c3525f5ff86648132aa8c4b916e505974f95c3403ed3f774ceef8753008

Contents?: true

Size: 454 Bytes

Versions: 3

Compression:

Stored size: 454 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.search(pattern, match) }
    end
    alias_method :/, :search
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sexp_path-0.5.2 lib/sexp_path/sexp_collection.rb
sexp_path-0.5.1 lib/sexp_path/sexp_collection.rb
sexp_path-0.5.0 lib/sexp_path/sexp_collection.rb