Sha256: aff706f99eb343ae20155f9490441adb87c6d73b2cb05713acde6e035bea5e88

Contents?: true

Size: 761 Bytes

Versions: 10

Compression:

Stored size: 761 Bytes

Contents

# Copyright (c) 2020 Jerome Arbez-Gindre
# frozen_string_literal: true

require('csv')

module DefMastership
  # format header for one document
  class CSVFormatterHeader
    def initialize(doc)
      @doc = doc
    end

    def fixed
      %w[Type Reference Value Checksum]
    end

    def wrong_explicit_checksum
      @doc.wrong_explicit_checksum? ? ['Wrong explicit checksum'] : []
    end

    def explicit_version
      @doc.explicit_version? ? ['Version'] : []
    end

    def labels
      @doc.labels.empty? ? [] : %w[Labels]
    end

    def eref
      @doc.eref.map { |_, ref| ref[:prefix] }
    end

    def iref
      @doc.iref ? ['Internal links'] : []
    end

    def attributes
      @doc.attributes.map { |_, value| value }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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