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



9
10
11
# File 'lib/defmastership/export/header_formatter.rb', line 9

def initialize(doc)
  @doc = doc
end

Instance Method Details

#attributesArray<String>

Returns Optional attributes columns captions.

Returns:

  • (Array<String>)

    Optional attributes columns captions



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

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

#erefArray<String>

Returns Optional external refs columns captions.

Returns:

  • (Array<String>)

    Optional external refs columns captions



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

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



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

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

#irefArray<String>

Returns Optional internal refs column caption.

Returns:

  • (Array<String>)

    Optional internal refs column caption



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

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

#labelsArray<String>

Returns Optional labels columns captions.

Returns:

  • (Array<String>)

    Optional labels columns captions



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

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



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

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