Sha256: ac9df7803b975ec71cf12c994094da6c558035f9cae55bd91e2d93a6a04aa7f0

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

require "pathname"

module Marmerdo
  class Node
    # @return [Symbol]
    attr_reader :path
    # @return [Symbol]
    attr_reader :name
    attr_accessor :relationships

    def initialize(path:, name:, relationships:)
      @path = path
      @name = name.to_sym
      @relationships = relationships
    end

    def to_mermaid_line
      "class #{name}"
    end

    def generate_mermaid_link(output_path, enable_link_extension:)
      path = enable_link_extension ? @path : Pathname.new(@path).sub_ext("").to_s

      output_dir = Pathname.new(output_path).dirname
      relative_path = Pathname.new(path).relative_path_from(output_dir).to_s
      relative_path = "./#{relative_path}" unless relative_path.start_with?("../")
      "link #{name} \"#{relative_path}\""
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marmerdo-0.2.3 lib/marmerdo/node.rb