Sha256: 27788be5c8389380e4ef7680bffa4a48962204582e877a7585231173cd903c92
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module JsDependency module Mermaid class NodesLink attr_reader :parent, :child # @param [String] parent # @param [String] child def initialize(parent, child) @parent = Pathname.new(parent) @child = Pathname.new(child) end # @param [Integer] level # @return [String] def parent_module_name(level = 0) mermaid_str(@parent, level) end # @param [Integer] level # @return [String] def child_module_name(level = 0) mermaid_str(@child, level) end private # @param [Pathname] pathname # @param [Integer] level def mermaid_str(pathname, level = 0) "#{parse(pathname).join("_")}[\"#{parse(pathname, level).join("/")}\"]" end # @param [Pathname] pathname # @param [Integer] level def parse(pathname, level = -1) pathname.each_filename.with_object([]) { |filename, array| array << filename }.reverse[0..level].reverse end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
js_dependency-0.3.2 | lib/js_dependency/mermaid/nodes_link.rb |
js_dependency-0.3.1 | lib/js_dependency/mermaid/nodes_link.rb |