Class: SexpPath::SexpCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/sexp_path/sexp_collection.rb

Overview

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) }

Instance Method Summary collapse

Instance Method Details

#search(pattern) ⇒ Object Also known as: /

See Traverse#search



11
12
13
# File 'lib/sexp_path/sexp_collection.rb', line 11

def search(pattern)
  inject(SexpCollection.new){|collection, match| collection.concat match.sexp.search(pattern, match) }
end