Class: PatternMatch::PatternSequence
- Inherits:
-
PatternElement
- Object
- Pattern
- PatternElement
- PatternMatch::PatternSequence
- Defined in:
- lib/pattern-match/core.rb
Defined Under Namespace
Classes: PatternRewind
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
341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/pattern-match/core.rb', line 341 def match(vals) if directly_quantified? repeating_match(vals, @next.greedy?) do |rewind| if rewind.ntimes < @next.min_k next false end rewind.match(vals) end else with_rewind(make_rewind(1)) do |rewind| rewind.match(vals) end end end |
#validate ⇒ Object
356 357 358 359 360 |
# File 'lib/pattern-match/core.rb', line 356 def validate super raise MalformedPatternError if subpatterns.empty? raise MalformedPatternError unless @parent.kind_of?(HasOrderedSubPatterns) end |