# Copyright (c) 2020 Jerome Arbez-Gindre # frozen_string_literal: true require('csv') module DefMastership # format lines per definition class CSVFormatterBody def initialize(doc) @doc = doc end def fixed(definition) [definition.type, definition.reference, definition.value, definition.sha256] end def wrong_explicit_checksum(definition) wrong_explicit_checksum = definition.wrong_explicit_checksum wrong_explicit_checksum ? [wrong_explicit_checksum] : [''] end def explicit_version(definition) explicit_version = definition.explicit_version explicit_version ? [explicit_version] : [''] end def labels(definition) [definition.labels.to_a.join("\n")] end def eref(definition) @doc.eref.map { |key, _| definition.eref[key].join("\n") } end def iref(definition) [definition.iref.join("\n")] end def attributes(definition) @doc.attributes.map { |key, _| definition.attributes[key] } end end end