Sha256: 0d318c34da7c96f35e65fa7c5785184896f99a586568a904f4edcc21b57d9733

Contents?: true

Size: 697 Bytes

Versions: 2

Compression:

Stored size: 697 Bytes

Contents

module Asciidoctor
  module ConfluencePublisher
    class Asciidoc
      attr_reader :path, :children

      def initialize(path)
        @path = path
        @children = []
      end

      def is_leaves?
        !is_directory?
      end

      def is_directory?
        File.directory?(path)
      end

      def add_child(child)
        return if child.nil?
        @children << child
      end

      def to_s
        inspect
      end

      def has_any_leaves?
        traverse_file_tree(self)
      end

      private
      def traverse_file_tree(root)
        return true if root.is_leaves?
        return root.children.any? { |node| traverse_file_tree(node) }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asciidoctor-confluence_publisher-0.1.1 lib/asciidoctor/confluence_publisher/asciidoc.rb
asciidoctor-confluence_publisher-0.1.0 lib/asciidoctor/confluence_publisher/asciidoc.rb