Class: PatternMatch::PatternValue
- Inherits:
-
PatternElement
- Object
- Pattern
- PatternElement
- PatternMatch::PatternValue
- Defined in:
- lib/pattern-match/core.rb
Instance Attribute Summary
Attributes inherited from Pattern
Instance Method Summary collapse
-
#initialize(val, compare_by = :===) ⇒ PatternValue
constructor
A new instance of PatternValue.
- #inspect ⇒ Object
- #match(vals) ⇒ Object
Methods inherited from PatternElement
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
#inspect ⇒ Object
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 |