Module: BEL::LibBEL::NodeTest
- Defined in:
- lib/bel/libbel/node_test.rb
Instance Method Summary collapse
- #all?(predicates) ⇒ Boolean
- #all_in_tree?(predicates) ⇒ Boolean
- #any?(predicates) ⇒ Boolean
- #any_in_tree?(predicates) ⇒ Boolean
Instance Method Details
#all?(predicates) ⇒ Boolean
25 26 27 28 29 30 31 32 |
# File 'lib/bel/libbel/node_test.rb', line 25 def all?(predicates) predicates.each do |predicate| if !predicate.call(self) return false end end return true end |
#all_in_tree?(predicates) ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bel/libbel/node_test.rb', line 34 def all_in_tree?(predicates) predicates.each do |predicate| self.traversal_method(self, :depth_first).call do |ast_node| if !predicate.call(ast_node) return false end end end return true end |
#any?(predicates) ⇒ Boolean
5 6 7 8 9 10 11 12 |
# File 'lib/bel/libbel/node_test.rb', line 5 def any?(predicates) predicates.each do |predicate| if predicate.call(self) return true end end return false end |
#any_in_tree?(predicates) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bel/libbel/node_test.rb', line 14 def any_in_tree?(predicates) predicates.each do |predicate| self.traversal_method(self, :depth_first).call do |ast_node| if predicate.call(ast_node) return true end end end return false end |