Method: Roby::Queries::TaskMatcher.match_indexed_predicate

Defined in:
lib/roby/queries/task_matcher.rb

.match_indexed_predicate(name, index: name.to_s, neg_index: nil, not_index: nil, not_neg_index: name.to_s) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/roby/queries/task_matcher.rb', line 172

def match_indexed_predicate(
    name,
    index: name.to_s, neg_index: nil,
    not_index: nil, not_neg_index: name.to_s
)
    method_name = name.to_s.gsub(/\?$/, "")
    class_eval <<~PREDICATE_METHOD, __FILE__, __LINE__ + 1
        def #{method_name}
            add_predicate(:#{name})
            #{"add_indexed_predicate(:#{index})" if index}
            #{"add_indexed_neg_predicate(:#{neg_index})" if neg_index}
            self
        end
        def not_#{method_name}
            add_neg_predicate(:#{name})
            #{"add_indexed_predicates(:#{not_index})" if not_index}
            #{"add_indexed_neg_predicate(:#{not_neg_index})" if not_neg_index}
            self
        end
    PREDICATE_METHOD
    declare_class_methods(method_name, "not_#{method_name}")
end