Class: PatternMatch::PatternAnd

Inherits:
PatternElement show all
Defined in:
lib/pattern-match/core.rb

Instance Attribute Summary

Attributes inherited from Pattern

#next, #parent, #prev

Instance Method Summary collapse

Methods inherited from PatternElement

#quantifier?

Methods inherited from Pattern

#!@, #&, #ancestors, #append, #initialize, #inspect, #quantified?, #quantifier?, #quasibinding, #root, #root?, #to_a, #vars, #|

Constructor Details

This class inherits a constructor from PatternMatch::Pattern

Instance Method Details

#match(vals) ⇒ Object



446
447
448
449
450
# File 'lib/pattern-match/core.rb', line 446

def match(vals)
  super do |val|
    @subpatterns.all? {|i| i.match([val]) }
  end
end

#validateObject



452
453
454
455
# File 'lib/pattern-match/core.rb', line 452

def validate
  super
  raise MalformedPatternError if @subpatterns.empty?
end