Sha256: 0794f43781564465014ac454a96d5416ca544803dc5a3869c45a22e6d35cf0de

Contents?: true

Size: 467 Bytes

Versions: 2

Compression:

Stored size: 467 Bytes

Contents

module SexpPath
  
  # 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
  #
  class SexpResult < Hash
    attr_accessor :sexp # Matched Sexp
    
    def initialize(sexp, data={})
      @sexp = sexp
      merge! data
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

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