Class: SexpPath::Matcher::Type
- Defined in:
- lib/sexp_path/matcher/type.rb
Overview
See SexpQueryBuilder.t
Instance Attribute Summary collapse
-
#sexp_type ⇒ Object
readonly
Returns the value of attribute sexp_type.
Instance Method Summary collapse
-
#initialize(type) ⇒ Type
constructor
Creates a Matcher which will match any Sexp who’s type is
type
, where a type is the first element in the Sexp. - #inspect ⇒ Object
-
#satisfy?(o, data = {}) ⇒ Boolean
Satisfied if the sexp_type of
o
istype
.
Methods inherited from Base
Methods included from Traverse
#capture_as, #replace_sexp, #search, #search_each
Constructor Details
#initialize(type) ⇒ Type
Creates a Matcher which will match any Sexp who’s type is type
, where a type is the first element in the Sexp.
7 8 9 |
# File 'lib/sexp_path/matcher/type.rb', line 7 def initialize(type) @sexp_type = type end |
Instance Attribute Details
#sexp_type ⇒ Object (readonly)
Returns the value of attribute sexp_type.
3 4 5 |
# File 'lib/sexp_path/matcher/type.rb', line 3 def sexp_type @sexp_type end |
Instance Method Details
#inspect ⇒ Object
18 19 20 |
# File 'lib/sexp_path/matcher/type.rb', line 18 def inspect "t(#{sexp_type.inspect})" end |
#satisfy?(o, data = {}) ⇒ Boolean
Satisfied if the sexp_type of o
is type
.
12 13 14 15 16 |
# 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 |