Sha256: 55e854834ae51b7ac4da003dda650e045195d6f20bb7c4853ac88f1a81f3de39

Contents?: true

Size: 597 Bytes

Versions: 14

Compression:

Stored size: 597 Bytes

Contents

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

14 entries across 14 versions & 1 rubygems

Version Path
deep-cover-0.1.14 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.13 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.12 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.11 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.10 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.9 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.8 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.7 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.6 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.5 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.4 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.3 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.2 lib/deep_cover/analyser/subset.rb
deep-cover-0.1.1 lib/deep_cover/analyser/subset.rb