Sha256: 01056c92d8365188853882eab93efbea8390bb4316f0a2c0f64ed7aaf670148d

Contents?: true

Size: 511 Bytes

Versions: 5

Compression:

Stored size: 511 Bytes

Contents

# See SexpQueryBuilder.t
class SexpPath::Matcher::Type < SexpPath::Matcher::Base
  attr_reader :sexp_type
  
  # Creates a Matcher which will match any Sexp who's type is +type+, where a type is
  # the first element in the Sexp.
  def initialize(type)
    @sexp_type = type
  end

  # Satisfied if the sexp_type of +o+ is +type+.
  def satisfy?(o, data={})
    return nil unless o.is_a?(Sexp) && o.sexp_type == sexp_type
  
    capture_match o, data
  end

  def inspect
    "t(#{sexp_type.inspect})"
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
adamsanderson-sexp_path-0.4.0 lib/sexp_path/matcher/type.rb
sexp_path-0.5.2 lib/sexp_path/matcher/type.rb
sexp_path-0.5.1 lib/sexp_path/matcher/type.rb
sexp_path-0.5.0 lib/sexp_path/matcher/type.rb
sexp_path-0.4.0 lib/sexp_path/matcher/type.rb