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, #directly_quantified?, #quantified?, #quantifier?, #quasibinding, #root, #root?, #to_a, #validate, #vars, #|

Methods included from PatternMatch::Pattern::Backtrackable

#choice_points

Constructor Details

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

Returns a new instance of PatternValue.



297
298
299
300
301
# File 'lib/pattern-match/core.rb', line 297

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

Instance Method Details

#inspectObject



309
310
311
# File 'lib/pattern-match/core.rb', line 309

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

#match(vals) ⇒ Object



303
304
305
306
307
# File 'lib/pattern-match/core.rb', line 303

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