Class: PatternMatch::PatternNot

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, #directly_quantified?, #initialize, #inspect, #quantified?, #quantifier?, #quasibinding, #root, #root?, #to_a, #vars, #|

Methods included from PatternMatch::Pattern::Backtrackable

#choice_points

Constructor Details

This class inherits a constructor from PatternMatch::Pattern

Instance Method Details

#match(vals) ⇒ Object



434
435
436
437
438
439
440
441
442
# File 'lib/pattern-match/core.rb', line 434

def match(vals)
  super do |val|
    begin
      ! subpatterns[0].match([val])
    rescue PatternNotMatch
      true
    end
  end
end

#validateObject



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

def validate
  super
  raise MalformedPatternError unless subpatterns.length == 1
  raise MalformedPatternError unless vars.empty?
end