Module: Wood::TreePattern::Matcher
- Defined in:
- lib/wood/tree_pattern/matcher.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
16 17 18 |
# File 'lib/wood/tree_pattern/matcher.rb', line 16 def self.included(klass) klass.extend ClassMethods end |
Instance Method Details
#===(node) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/wood/tree_pattern/matcher.rb', line 31 def === node self.class.pattern_builders.each do |p| if match = (p === node) return match end end return false end |
#replacement_for(node) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/wood/tree_pattern/matcher.rb', line 20 def replacement_for(node) self.class.pattern_builders.each do |pb| if pb === node if replacement = pb.replacement_for(node) return replacement end end end return node end |