class Sexp::Pattern

Matches any atom who's string representation matches the patterns passed in.


s(:a) / s{ m('a') }                                      #=> [s(:a)]
s(:a) / s{ m(/\w/,/\d/) }                                #=> [s(:a)]
s(:tests, s(s(:test_a), s(:test_b))) / s{ m(/test_\w/) } #=> [s(:test_a),

TODO: maybe don't require non-sexps? This does respond to =~ now.



The regexp to match for the pattern.

Public Class Methods

new(pattern) click to toggle source

Create a Patten matcher which will match any atom that either matches the input pattern.

# File lib/sexp.rb, line 1177
def initialize pattern
  @pattern = pattern

Public Instance Methods

satisfy?(o) click to toggle source

Satisfied if o is an atom, and o matches pattern

# File lib/sexp.rb, line 1184
def satisfy? o
  !o.kind_of?(Sexp) && o.to_s =~ pattern # TODO: question to_s