Class: Filigree::MultipleObjectPattern
- Inherits:
-
BasicPattern
- Object
- BasicPattern
- Filigree::MultipleObjectPattern
- Extended by:
- AbstractClass
- Defined in:
- lib/filigree/match.rb
Overview
An abstract class that matches multiple objects to multiple patterns.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(pattern) ⇒ MultipleObjectPattern
constructor
Create a new pattern with multiple elements.
-
#match?(objects, env) ⇒ Boolean
Test multiple objects against multiple pattern elements.
Methods included from AbstractClass
abstract_method, extended, install_icvars, new
Methods inherited from BasicPattern
Constructor Details
#initialize(pattern) ⇒ MultipleObjectPattern
Create a new pattern with multiple elements.
386 387 388 |
# File 'lib/filigree/match.rb', line 386 def initialize(pattern) @pattern = pattern end |
Instance Method Details
#match?(objects, env) ⇒ Boolean
Test multiple objects against multiple pattern elements.
395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/filigree/match.rb', line 395 def match?(objects, env) if objects.length == @pattern.length @pattern.zip(objects).each do |pattern_elem, object| return false unless match_pattern_element(pattern_elem, object, env) end true else (@pattern.length == 1 and @pattern.first == WildcardPattern.instance) end end |