class PatternMatch::PatternSequence::PatternRewind
Attributes
ntimes[R]
Public Class Methods
new(ntimes, head_pattern, next_pattern)
click to toggle source
Calls superclass method
PatternMatch::Pattern::new
# File lib/pattern-match/core.rb, line 320 def initialize(ntimes, head_pattern, next_pattern) super() @ntimes = ntimes @head = head_pattern @next = next_pattern end
Public Instance Methods
inspect()
click to toggle source
# File lib/pattern-match/core.rb, line 336 def inspect "#<#{self.class.name}: ntimes=#{@ntimes} head=#{@head.inspect} next=#{@next.inspect}>" end
match(vals)
click to toggle source
# File lib/pattern-match/core.rb, line 327 def match(vals) if @ntimes > 0 @ntimes -= 1 @head.match(vals) else @next ? @next.match(vals) : vals.empty? end end