Class: SexpPath::SexpResult

Inherits:
Hash
  • Object
show all
Defined in:
lib/sexp_path/sexp_result.rb

Overview

Wraps the results of a SexpPath query. The matching Sexp is placed in SexpResult#sexp. Any named captures will be available with SexpResult#[].

For instance:

res = s(:a) / Q?{ s( _ % 'name') }

res.first.sexp == s(:a) 
res.first['name'] == :a

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sexp, data = {}) ⇒ SexpResult

Returns a new instance of SexpResult.



16
17
18
19
# File 'lib/sexp_path/sexp_result.rb', line 16

def initialize(sexp, data={})
  @sexp = sexp
  merge! data
end

Instance Attribute Details

#sexpObject

Matched Sexp



14
15
16
# File 'lib/sexp_path/sexp_result.rb', line 14

def sexp
  @sexp
end