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



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

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

#erefArray<String>

Returns Optional external refs columns captions.

Returns:

  • (Array<String>)

    Optional external refs columns captions



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

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



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

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

#irefArray<String>

Returns Optional internal refs column caption.

Returns:

  • (Array<String>)

    Optional internal refs column caption



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

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

#labelsArray<String>

Returns Optional labels columns captions.

Returns:

  • (Array<String>)

    Optional labels columns captions



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

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



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

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