Sha256: 1c08d95408f3b5e3eba579edea136d0696ccf21de57fadd3378c8bf5cf4e156b

Contents?: true

Size: 906 Bytes

Versions: 10

Compression:

Stored size: 906 Bytes

Contents

module LibBEL
  module NodeTest

    def any?(predicates)
      predicates.each do |predicate|
        if predicate.call(self)
          return true
        end
      end
      return false
    end

    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

    def all?(predicates)
      predicates.each do |predicate|
        if !predicate.call(self)
          return false
        end
      end
      return true
    end

    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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bel-0.3.2-x64-mingw32 lib/bel/libbel/node_test.rb
bel-0.3.2-x86-mingw32 lib/bel/libbel/node_test.rb
bel-0.3.2 lib/bel/libbel/node_test.rb
bel-0.3.1-x64-mingw32 lib/bel/libbel/node_test.rb
bel-0.3.1-x86-mingw32 lib/bel/libbel/node_test.rb
bel-0.3.1 lib/bel/libbel/node_test.rb
bel-0.3.0-x86-mingw32 lib/bel/libbel/node_test.rb
bel-0.3.0-x64-mingw32 lib/bel/libbel/node_test.rb
bel-0.3.0 lib/bel/libbel/node_test.rb
bel-0.3.0.beta6 lib/bel/libbel/node_test.rb