Class: Marmerdo::OutputGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/marmerdo/output_generator.rb

Overview

This class generates a markdown or mermaid file from a mermaid diagram.

Defined Under Namespace

Classes: UnknownOutputExtensionError

Constant Summary collapse

WARNING_COMMENT =
"This file was generated by Marmerdo. Do not edit it manually.".freeze

Instance Method Summary collapse

Constructor Details

#initialize(output_path, domain_diagram) ⇒ OutputGenerator

Returns a new instance of OutputGenerator.



14
15
16
17
# File 'lib/marmerdo/output_generator.rb', line 14

def initialize(output_path, domain_diagram)
  @output_path = output_path
  @domain_diagram = domain_diagram
end

Instance Method Details

#generateString

Returns:

  • (String)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/marmerdo/output_generator.rb', line 20

def generate
  case output_filetype
  when :markdown
    [
      "<!-- #{WARNING_COMMENT} -->",
      "",
      "```mermaid",
      @domain_diagram,
      "```"
    ].join("\n")
  when :mermaid
    [
      "%% #{WARNING_COMMENT}",
      "",
      @domain_diagram
    ].join("\n")
  end
end