Sha256: 41d19236f8c2fe9677ac3887ddf1089d0036b90f35150b4d3acabbe5be755d3c

Contents?: true

Size: 471 Bytes

Versions: 1

Compression:

Stored size: 471 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(&:level).
        join("\n")
    end

    def p mod
      puts of mod
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
constree-0.1.0 lib/constree.rb