Sha256: bf2c9b97f47f3d0e97bac03d25a20ebe8140007dcf06de31f276518fb59fed08

Contents?: true

Size: 482 Bytes

Versions: 2

Compression:

Stored size: 482 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
        list(sub_n, seen) if sub_n.not_yet? seen
      end

      seen
    end

    def of mod
      list(mod).
        map(&:tree_graph_level).
        join("\n")
    end

    def p mod
      puts of mod
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
constree-0.1.2 lib/constree.rb
constree-0.1.1 lib/constree.rb