Class: Wood::TreePattern::OrMatcher

Inherits:
Object
  • Object
show all
Includes:
CombinatorialMatching
Defined in:
lib/wood/tree_pattern/or_matcher.rb

Overview

Matches a [Node], if any of two given patterns match it.

Instance Method Summary collapse

Methods included from CombinatorialMatching

#|

Constructor Details

#initialize(a, b) ⇒ OrMatcher

Returns a new instance of OrMatcher.



12
13
14
15
# File 'lib/wood/tree_pattern/or_matcher.rb', line 12

def initialize(a, b)
  @a = a
  @b = b
end

Instance Method Details

#==(node) ⇒ Object



21
22
23
# File 'lib/wood/tree_pattern/or_matcher.rb', line 21

def == node
  @a == node || @b == node
end

#===(node) ⇒ Object



17
18
19
# File 'lib/wood/tree_pattern/or_matcher.rb', line 17

def === node
  @a === node || @b === node
end

#inspectObject



29
30
31
# File 'lib/wood/tree_pattern/or_matcher.rb', line 29

def inspect
  sexp.inspect
end

#sexpObject



25
26
27
# File 'lib/wood/tree_pattern/or_matcher.rb', line 25

def sexp
  [:or_matcher, @a.sexp, @b.sexp]
end