Class: PatternMatch::PatternOr
- Inherits:
-
PatternElement
- Object
- Pattern
- PatternElement
- PatternMatch::PatternOr
- Defined in:
- lib/pattern-match/core.rb
Instance Attribute Summary
Attributes inherited from Pattern
Instance Method Summary collapse
Methods inherited from PatternElement
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 |
#validate ⇒ Object
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 |