Class: PatternMatch::PatternOr

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



459
460
461
462
463
464
465
466
467
468
469
# File 'lib/pattern-match/core.rb', line 459

def match(vals)
  super do |val|
    @subpatterns.find do |i|
      begin
        i.match([val])
      rescue PatternNotMatch
        false
      end
    end
  end
end

#validateObject



471
472
473
474
475
# File 'lib/pattern-match/core.rb', line 471

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