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, #directly_quantified?, #initialize, #inspect, #quantified?, #quantifier?, #quasibinding, #root, #root?, #to_a, #vars, #|
Methods included from PatternMatch::Pattern::Backtrackable
Constructor Details
This class inherits a constructor from PatternMatch::Pattern
Instance Method Details
#match(vals) ⇒ Object
414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/pattern-match/core.rb', line 414 def match(vals) super do |val| subpatterns.find do |i| begin i.match([val]) rescue PatternNotMatch false end end end end |
#validate ⇒ Object
426 427 428 429 430 |
# File 'lib/pattern-match/core.rb', line 426 def validate super raise MalformedPatternError if subpatterns.empty? raise MalformedPatternError unless vars.empty? end |