Class: Filigree::BasicPattern
- Inherits:
-
Object
- Object
- Filigree::BasicPattern
- Extended by:
- AbstractClass
- Includes:
- Comparable
- Defined in:
- lib/filigree/match.rb
Overview
This class provides the basis for all match patterns.
Direct Known Subclasses
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Base implementation of bi-directional comparison for patterns.
-
#as(binding_pattern) ⇒ Object
Wraps this pattern in a BindingPattern, causing the object that this pattern matches to be bound to this name in the with block.
Methods included from AbstractClass
abstract_method, extended, install_icvars, new
Instance Method Details
#<=>(other) ⇒ Integer
Base implementation of bi-directional comparison for patterns.
302 303 304 305 306 |
# File 'lib/filigree/match.rb', line 302 def <=>(other) # This is performed in the non-intuitive order due to # higher-priority patterns having lower weights. other.weight - self.weight end |
#as(binding_pattern) ⇒ Object
Wraps this pattern in a Filigree::BindingPattern, causing the object that this pattern matches to be bound to this name in the with block.
312 313 314 |
# File 'lib/filigree/match.rb', line 312 def as(binding_pattern) binding_pattern.tap { |bp| bp.pattern_elem = self } end |