Class: Roby::Queries::AndMatcher

Inherits:
MatcherBase show all
Includes:
DRoby::V5::Queries::AndMatcherDumper
Defined in:
lib/roby/queries/and_matcher.rb,
lib/roby/droby/enable.rb

Overview

This matcher combines multiple task matching predicates through a AND boolean operator. I.e. it will match if none of the underlying predicates match.

Direct Known Subclasses

Tasks

Defined Under Namespace

Classes: Tasks

Instance Attribute Summary

Attributes inherited from MatcherBase

#neg_predicates, #predicates

Instance Method Summary collapse

Methods included from DRoby::V5::Queries::AndMatcherDumper

#droby_dump

Methods inherited from MatcherBase

#&, #add_neg_predicate, #add_predicate, declare_class_methods, #describe_failed_match, #each, #each_in_plan, #indexed_query?, #match, match_predicate, match_predicates, #negate, #reset, #to_a, #to_set, #|

Constructor Details

#initialize(*ops) ⇒ AndMatcher

Create a new AndMatcher object combining the given predicates.



9
10
11
12
13
# File 'lib/roby/queries/and_matcher.rb', line 9

def initialize(*ops)
    super()

    @ops = ops
end

Instance Method Details

#<<(op) ⇒ Object

Add a new predicate to the combination



16
17
18
19
# File 'lib/roby/queries/and_matcher.rb', line 16

def <<(op)
    @ops << op
    self
end

#===(task) ⇒ Object

True if the task matches at least one of the underlying predicates



22
23
24
# File 'lib/roby/queries/and_matcher.rb', line 22

def ===(task)
    @ops.all? { |op| op === task }
end