Class: Filigree::BasicPattern
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.
304 305 306 307 308 |
# File 'lib/filigree/match.rb', line 304 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.
314 315 316 |
# File 'lib/filigree/match.rb', line 314 def as(binding_pattern) binding_pattern.tap { |bp| bp.pattern_elem = self } end |