Class: PatternMatch::PatternValue

Inherits:
PatternElement show all
Defined in:
lib/pattern-match/core.rb

Instance Attribute Summary

Attributes inherited from Pattern

#next, #parent, #prev

Instance Method Summary collapse

Methods inherited from PatternElement

#quantifier?

Methods inherited from Pattern

#!@, #&, #ancestors, #append, #quantified?, #quantifier?, #quasibinding, #root, #root?, #to_a, #validate, #vars, #|

Constructor Details

#initialize(val, compare_by = :===) ⇒ PatternValue

Returns a new instance of PatternValue.



342
343
344
345
346
# File 'lib/pattern-match/core.rb', line 342

def initialize(val, compare_by = :===)
  super()
  @val = val
  @compare_by = compare_by
end

Instance Method Details

#inspectObject



354
355
356
# File 'lib/pattern-match/core.rb', line 354

def inspect
  "#<#{self.class.name}: val=#{@val.inspect}>"
end

#match(vals) ⇒ Object



348
349
350
351
352
# File 'lib/pattern-match/core.rb', line 348

def match(vals)
  super do |val|
    @val.__send__(@compare_by, val)
  end
end