Sha256: ccc6bf81faeae920eba6d8696a8a6ddea5ddcbf7558a292aa3eef435870f7fc8

Contents?: true

Size: 492 Bytes

Versions: 5

Compression:

Stored size: 492 Bytes

Contents

require 'constree/version'
require 'constree/node'

module Constree

  class << self

    def list node, seen=[]
      node = Node.new node unless node.is_a? Node
      seen << node if seen.empty?

      node.sub_nodes.each do |sub_n|
        seen << sub_n
        node.children_for_tree_graph << sub_n
        list(sub_n, seen) if sub_n.not_yet? seen
      end

      seen
    end

    def of mod
      list(mod).first.tree_graph
    end

    def p mod
      puts of mod
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
constree-0.1.7 lib/constree.rb
constree-0.1.6 lib/constree.rb
constree-0.1.5 lib/constree.rb
constree-0.1.4 lib/constree.rb
constree-0.1.3 lib/constree.rb