Class: Defmastership::Export::HeaderFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/defmastership/export/header_formatter.rb

Overview

format CSV header (first line) for one document

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ HeaderFormatter

Returns a new instance of HeaderFormatter.

Parameters:

  • doc (Document)

    the document to export



11
12
13
# File 'lib/defmastership/export/header_formatter.rb', line 11

def initialize(doc)
  @doc = doc
end

Instance Method Details

#attributesArray<String>

Returns Optional attributes columns captions.

Returns:

  • (Array<String>)

    Optional attributes columns captions



46
47
48
# File 'lib/defmastership/export/header_formatter.rb', line 46

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

#erefArray<String>

Returns Optional external refs columns captions.

Returns:

  • (Array<String>)

    Optional external refs columns captions



36
37
38
# File 'lib/defmastership/export/header_formatter.rb', line 36

def eref
  @doc.eref.map { |_, ref| ref.fetch(:prefix) }
end

#explicit_versionArray<String>

Returns Optional version column captions.

Returns:

  • (Array<String>)

    Optional version column captions



26
27
28
# File 'lib/defmastership/export/header_formatter.rb', line 26

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

#fixedArray<String>

Returns list of always available columns.

Returns:

  • (Array<String>)

    list of always available columns



16
17
18
# File 'lib/defmastership/export/header_formatter.rb', line 16

def fixed
  %w[Type Reference Value Checksum]
end

#irefArray<String>

Returns Optional internal refs column caption.

Returns:

  • (Array<String>)

    Optional internal refs column caption



41
42
43
# File 'lib/defmastership/export/header_formatter.rb', line 41

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

#labelsArray<String>

Returns Optional labels columns captions.

Returns:

  • (Array<String>)

    Optional labels columns captions



31
32
33
# File 'lib/defmastership/export/header_formatter.rb', line 31

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

#wrong_explicit_checksumArray<String>

Returns Optional wrong_explicit_checksum column caption.

Returns:

  • (Array<String>)

    Optional wrong_explicit_checksum column caption



21
22
23
# File 'lib/defmastership/export/header_formatter.rb', line 21

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