class SexpPath::Matcher::Type

See SexpQueryBuilder.t

Attributes

sexp_type[R]

Public Class Methods

new(type) click to toggle source

Creates a Matcher which will match any Sexp who’s type is type, where a type is the first element in the Sexp.

# File lib/sexp_path/matcher/type.rb, line 7
def initialize(type)
  @sexp_type = type
end

Public Instance Methods

inspect() click to toggle source
# File lib/sexp_path/matcher/type.rb, line 18
def inspect
  "t(#{sexp_type.inspect})"
end
satisfy?(o, data={}) click to toggle source

Satisfied if the sexp_type of o is type.

# File lib/sexp_path/matcher/type.rb, line 12
def satisfy?(o, data={})
  return nil unless o.is_a?(Sexp) && o.sexp_type == sexp_type

  capture_match o, data
end