Class: Reading::Parsing::Attributes::Notes

Inherits:
Attribute show all
Defined in:
lib/reading/parsing/attributes/notes.rb

Overview

Transformer for the :notes item attribute.

Instance Method Summary collapse

Instance Method Details

#transform_from_parsed(parsed_row, _head_index) ⇒ Array<Hash>

Returns an array of notes; see Config#default_config[:template].

Parameters:

  • parsed_row (Hash)

    a parsed row (the intermediate hash).

  • _head_index (Integer)

    current item’s position in the Head column.

Returns:



10
11
12
13
14
15
16
17
18
# File 'lib/reading/parsing/attributes/notes.rb', line 10

def transform_from_parsed(parsed_row, _head_index)
  parsed_row[:notes]&.map { |note|
    {
      blurb?: note.has_key?(:note_blurb),
      private?: note.has_key?(:note_private),
      content: note[:note_regular] || note[:note_blurb] || note[:note_private],
    }
  }
end