adamsanderson / ruby_diff

Higher level ruby code comparison

This URL has Read+Write access

ruby_diff / lib / ruby_diff / patterns.rb
100644 29 lines (24 sloc) 0.376 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class SexpWildCard < SexpMatchSpecial
  def === (o)
    return true
  end
  
  def == (o)
    return true
  end
  
end
 
def _?
  SexpWildCard.new
end
 
class Sexp
  def match(pattern, &block)
    if pattern == self
      block.call(self)
    end
 
    self.each do |subset|
      case subset
      when Sexp then
        subset.match(pattern, &block)
      end
    end
  end
end