Sha256: 2de7e850625b405bf45bd83083351e6724228dc1ad2c55f1146ff199607e1591

Contents?: true

Size: 658 Bytes

Versions: 3

Compression:

Stored size: 658 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.sort_by(&:parent).uniq { |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

3 entries across 3 versions & 1 rubygems

Version Path
js_dependency-0.2.0 lib/js_dependency/mermaid/root.rb
js_dependency-0.1.1 lib/js_dependency/mermaid/root.rb
js_dependency-0.1.0 lib/js_dependency/mermaid/root.rb