Sha256: 82d956967ebcd4937fbf5c33325a9fc71a4de49184ae83f088f6d868a04ab79a

Contents?: true

Size: 691 Bytes

Versions: 4

Compression:

Stored size: 691 Bytes

Contents

# frozen_string_literal: true

require_relative "nodes_link"
module JsDependency
  module Mermaid
    class Root
      attr_accessor :orientation

      def initialize(orientation = "LR")
        @orientation = orientation
        @list = []
      end

      def add(parent, child)
        @list << NodesLink.new(parent, child)
      end

      def export(name_level: 1)
        str = "flowchart #{orientation}\n"
        str + @list.uniq { |link| "#{link.parent}__#{link.child}" }.sort_by { |link| "#{link.parent}__#{link.child}" }.map do |link|
          "#{link.parent_module_name(name_level)} --> #{link.child_module_name(name_level)}"
        end.join("\n")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
js_dependency-0.2.3.1 lib/js_dependency/mermaid/root.rb
js_dependency-0.2.3 lib/js_dependency/mermaid/root.rb
js_dependency-0.2.2 lib/js_dependency/mermaid/root.rb
js_dependency-0.2.1 lib/js_dependency/mermaid/root.rb