Class: Defmastership::Export::HeaderFormatter
- Inherits:
-
Object
- Object
- Defmastership::Export::HeaderFormatter
- Defined in:
- lib/defmastership/export/header_formatter.rb
Overview
format CSV header (first line) for one document
Instance Method Summary collapse
-
#attributes ⇒ Array<String>
Optional attributes columns captions.
-
#eref ⇒ Array<String>
Optional external refs columns captions.
-
#explicit_version ⇒ Array<String>
Optional version column captions.
-
#fixed ⇒ Array<String>
List of always available columns.
-
#initialize(doc) ⇒ HeaderFormatter
constructor
A new instance of HeaderFormatter.
-
#iref ⇒ Array<String>
Optional internal refs column caption.
-
#labels ⇒ Array<String>
Optional labels columns captions.
-
#wrong_explicit_checksum ⇒ Array<String>
Optional wrong_explicit_checksum column caption.
Constructor Details
#initialize(doc) ⇒ HeaderFormatter
Returns a new instance of HeaderFormatter.
11 12 13 |
# File 'lib/defmastership/export/header_formatter.rb', line 11 def initialize(doc) @doc = doc end |
Instance Method Details
#attributes ⇒ Array<String>
Returns Optional attributes columns captions.
46 47 48 |
# File 'lib/defmastership/export/header_formatter.rb', line 46 def attributes @doc.attributes.map { |_, value| value } end |
#eref ⇒ Array<String>
Returns 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_version ⇒ Array<String>
Returns Optional version column captions.
26 27 28 |
# File 'lib/defmastership/export/header_formatter.rb', line 26 def explicit_version @doc.explicit_version? ? ['Version'] : [] end |
#fixed ⇒ Array<String>
Returns 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 |
#iref ⇒ Array<String>
Returns Optional internal refs column caption.
41 42 43 |
# File 'lib/defmastership/export/header_formatter.rb', line 41 def iref @doc.iref ? ['Internal links'] : [] end |
#labels ⇒ Array<String>
Returns 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_checksum ⇒ Array<String>
Returns 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 |