class PatternMatch::PatternCondition
Public Class Methods
new(&condition)
click to toggle source
Calls superclass method
PatternMatch::Pattern::new
# File lib/pattern-match/core.rb, line 452 def initialize(&condition) super() @condition = condition end
Public Instance Methods
inspect()
click to toggle source
# File lib/pattern-match/core.rb, line 471 def inspect "#<#{self.class.name}: condition=#{@condition.inspect}>" end
match(vals)
click to toggle source
# 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
validate()
click to toggle source
Calls superclass method
PatternMatch::Pattern#validate
# File lib/pattern-match/core.rb, line 466 def validate super raise MalformedPatternError if ancestors.find {|i| i.next and ! i.next.kind_of?(PatternCondition) } end