Class: MandateClaw::Renderers::MarkdownRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/mandate_claw/renderers/markdown_renderer.rb

Overview

Renders a contract class as a human-readable Markdown document. This is the “bidirectional transpilation” — the same DSL that the Ruby runtime enforces can be read by lawyers and regulators.

Instance Method Summary collapse

Constructor Details

#initialize(contract_class) ⇒ MarkdownRenderer

Returns a new instance of MarkdownRenderer.



9
10
11
# File 'lib/mandate_claw/renderers/markdown_renderer.rb', line 9

def initialize(contract_class)
  @c = contract_class
end

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mandate_claw/renderers/markdown_renderer.rb', line 13

def render
  sections = []
  sections << header
  sections << parties_section
  sections << obligations_section   if @c._obligations.any?
  sections << permissions_section   if @c._permissions.any?
  sections << prohibitions_section  if @c._prohibitions.any?
  sections << agent_bounds_section  if @c._agent_bounds.any?
  sections << rules_section         if @c._rules.any?
  sections << attestation_section   if @c._attestation
  sections << footer
  sections.compact.join("\n\n")
end