Module: Dcc::Convert::Html

Defined in:
lib/dcc/convert/html.rb

Overview

Dcc::Convert::Html renders a parsed DCC into a human-readable HTML report with collapsible sections per administrative section and measurement result.

Class Method Summary collapse

Class Method Details

.call(dcc) ⇒ Dcc::Convert::Result

Parameters:

  • dcc (Lutaml::Model::Serializable)

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dcc/convert/html.rb', line 12

def call(dcc)
  payload = <<~HTML
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>DCC Report #{escape(unique_identifier_of(dcc))}</title>
      <style>
        body { font-family: -apple-system, system-ui, sans-serif; margin: 2rem; }
        h1, h2, h3 { color: #333; }
        section { margin-bottom: 1.5rem; padding: 1rem; border: 1px solid #eee; border-radius: 4px; }
        table { border-collapse: collapse; }
        th, td { border: 1px solid #ddd; padding: 0.5rem 1rem; text-align: left; }
        th { background: #f5f5f5; }
      </style>
    </head>
    <body>
      <h1>Digital Calibration Certificate</h1>
      #{summary_table(dcc)}
      #{administrative_section(dcc)}
      #{measurement_section(dcc)}
    </body>
    </html>
  HTML

  ::Dcc::Convert::Result.new(
    format: :html,
    payload: payload,
    source_class: dcc.class.name,
    schema_version: dcc.schema_version.to_s,
  )
end