Class: SexpPath::Matcher::Pattern
- Defined in:
- lib/sexp_path/matcher/pattern.rb
Overview
See SexpQueryBuilder.m
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern) ⇒ Pattern
constructor
Create a Patten matcher which will match any atom that either matches the input
pattern
. - #inspect ⇒ Object
-
#satisfy?(o, data = {}) ⇒ Boolean
Satisfied if
o
is an atom, ando
matchespattern
.
Methods inherited from Base
Methods included from Traverse
#capture_as, #replace_sexp, #search, #search_each
Constructor Details
#initialize(pattern) ⇒ Pattern
Create a Patten matcher which will match any atom that either matches the input pattern
.
6 7 8 |
# File 'lib/sexp_path/matcher/pattern.rb', line 6 def initialize(pattern) @pattern = pattern end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
3 4 5 |
# File 'lib/sexp_path/matcher/pattern.rb', line 3 def pattern @pattern end |
Instance Method Details
#inspect ⇒ Object
17 18 19 |
# File 'lib/sexp_path/matcher/pattern.rb', line 17 def inspect "m(#{pattern.inspect})" end |
#satisfy?(o, data = {}) ⇒ Boolean
Satisfied if o
is an atom, and o
matches pattern
11 12 13 14 15 |
# File 'lib/sexp_path/matcher/pattern.rb', line 11 def satisfy?(o, data={}) return nil unless !o.is_a?(Sexp) && o.to_s =~ pattern capture_match o, data end |