Sha256: 31d348a5ab0deb2b2664effb659b7833a2c3b9e194399cb417cfb0508ca0066d

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

# 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_body(definition)
      [definition.type, definition.reference, definition.value]
    end

    def labels_body(definition)
      @doc.labels.empty? ? [] : [definition.labels.to_a.join("\n")]
    end

    def eref_body(definition)
      @doc.eref.map { |key, _| definition.eref[key].join("\n") }
    end

    def iref_body(definition)
      @doc.iref ? [definition.iref.join("\n")] : []
    end

    def attributes_body(definition)
      @doc.attributes.map do |key, _|
        definition.attributes[key]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
defmastership-1.0.5 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.4 lib/defmastership/csv_formatter_body.rb