Class: Marmerdo::Node
- Inherits:
-
Object
- Object
- Marmerdo::Node
- Defined in:
- lib/marmerdo/node.rb
Instance Attribute Summary collapse
- #name ⇒ Symbol readonly
- #namespace ⇒ Symbol? readonly
- #path ⇒ Symbol readonly
-
#relationships ⇒ Object
Returns the value of attribute relationships.
Instance Method Summary collapse
- #generate_mermaid_link(output_path, enable_link_extension:) ⇒ Object
-
#initialize(path:, name:, namespace:, relationships:) ⇒ Node
constructor
A new instance of Node.
- #to_mermaid_str ⇒ Object
Constructor Details
#initialize(path:, name:, namespace:, relationships:) ⇒ Node
Returns a new instance of Node.
13 14 15 16 17 18 |
# File 'lib/marmerdo/node.rb', line 13 def initialize(path:, name:, namespace:, relationships:) @path = path @name = name.to_sym @namespace = namespace&.to_sym @relationships = relationships end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
8 9 10 |
# File 'lib/marmerdo/node.rb', line 8 def name @name end |
#namespace ⇒ Symbol? (readonly)
10 11 12 |
# File 'lib/marmerdo/node.rb', line 10 def namespace @namespace end |
#path ⇒ Symbol (readonly)
6 7 8 |
# File 'lib/marmerdo/node.rb', line 6 def path @path end |
#relationships ⇒ Object
Returns the value of attribute relationships.
11 12 13 |
# File 'lib/marmerdo/node.rb', line 11 def relationships @relationships end |
Instance Method Details
#generate_mermaid_link(output_path, enable_link_extension:) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/marmerdo/node.rb', line 32 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 |
#to_mermaid_str ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/marmerdo/node.rb', line 20 def to_mermaid_str str = "class #{name}" return str if namespace.nil? [ "namespace #{namespace} {", str, "}" ].join("\n") end |