Class: Marmerdo::DomainDiagramGenerator
- Inherits:
-
Object
- Object
- Marmerdo::DomainDiagramGenerator
- Defined in:
- lib/marmerdo/domain_diagram_generator.rb
Instance Method Summary collapse
-
#generate ⇒ String
Mermaid class diagram.
-
#initialize(output_path:, nodes:, enable_link_extension:) ⇒ DomainDiagramGenerator
constructor
A new instance of DomainDiagramGenerator.
Constructor Details
#initialize(output_path:, nodes:, enable_link_extension:) ⇒ DomainDiagramGenerator
Returns a new instance of DomainDiagramGenerator.
3 4 5 6 7 |
# File 'lib/marmerdo/domain_diagram_generator.rb', line 3 def initialize(output_path:, nodes:, enable_link_extension:) @output_path = output_path @nodes = nodes @enable_link_extension = enable_link_extension end |
Instance Method Details
#generate ⇒ String
Returns mermaid class diagram.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/marmerdo/domain_diagram_generator.rb', line 10 def generate classes = @nodes.map(&:to_mermaid_str) links = @nodes.map do |node| node.generate_mermaid_link(@output_path, enable_link_extension: @enable_link_extension) end relationships = @nodes.flat_map do |node| node.relationships.map do |relationship| relationship.to_mermaid_str(node.name) end end [ "classDiagram", classes, links, relationships ].flatten.join("\n") end |