Sha256: ce7b61b0f3b00567150645309f869ce82fa4de77abf474441253553031b6dafd

Contents?: true

Size: 632 Bytes

Versions: 34

Compression:

Stored size: 632 Bytes

Contents

# frozen_string_literal: true

module DeepCover
  # A module to create a subset from a criteria called `in_subset?`
  # Including classes can refine it, or specify SUBSET_CLASSES
  module Analyser::Subset
    def node_children(node)
      find_children(node)
    end

    private

    def find_children(from, parent = from)
      @source.node_children(from).flat_map do |node|
        if in_subset?(node, parent)
          [node]
        else
          find_children(node, parent)
        end
      end
    end

    def in_subset?(node, _parent)
      self.class::SUBSET_CLASSES.any? { |klass| node.is_a?(klass) }
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
deep-cover-core-1.1.0 lib/deep_cover/analyser/subset.rb
deep-cover-core-1.0.0 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.8.1 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.8.0 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.10 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.9 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.8 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.7 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.6 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.5 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.4 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.3 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.2 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.1 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.7.0 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.6.4 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.6.3 lib/deep_cover/analyser/subset.rb
deep-cover-core-0.6.3.pre lib/deep_cover/analyser/subset.rb
deep-cover-0.6.2 lib/deep_cover/analyser/subset.rb
deep-cover-0.6.1 lib/deep_cover/analyser/subset.rb