Sha256: 090c59113b70ed64090435eff9e46aae8c629342fc02fe551ed639826e1f6438

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

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(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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
defmastership-1.0.17 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.16 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.15 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.14 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.13 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.12 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.11 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.10 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.9 lib/defmastership/csv_formatter_body.rb
defmastership-1.0.8 lib/defmastership/csv_formatter_body.rb