Class: PatternMatch::PatternCondition
Instance Attribute Summary
Attributes inherited from Pattern
#next, #parent, #prev
Instance Method Summary
collapse
#quantifier?
Methods inherited from Pattern
#!@, #&, #ancestors, #append, #directly_quantified?, #quantified?, #quantifier?, #quasibinding, #root, #root?, #to_a, #vars, #|
#choice_points
Constructor Details
Returns a new instance of PatternCondition.
452
453
454
455
|
# File 'lib/pattern-match/core.rb', line 452
def initialize(&condition)
super()
@condition = condition
end
|
Instance Method Details
471
472
473
|
# File 'lib/pattern-match/core.rb', line 471
def inspect
"#<#{self.class.name}: condition=#{@condition.inspect}>"
end
|
#match(vals) ⇒ Object
457
458
459
460
461
462
463
464
|
# File 'lib/pattern-match/core.rb', line 457
def match(vals)
return false unless vals.empty?
if @condition.call
@next ? @next.match(vals) : true
else
false
end
end
|