Class: Reading::Parsing::Attributes::Genres

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

Overview

Transformer for the :genres item attribute.

Instance Method Summary collapse

Instance Method Details

#transform_from_parsed(parsed_row, head_index) ⇒ Array<String>

Parameters:

  • parsed_row (Hash)

    a parsed row (the intermediate hash).

  • head_index (Integer)

    current item’s position in the Head column.

Returns:



9
10
11
12
# File 'lib/reading/parsing/attributes/genres.rb', line 9

def transform_from_parsed(parsed_row, head_index)
  (parsed_row[:genres] || parsed_row[:head][head_index][:genres])
    &.map { _1.is_a?(Hash) ? _1[:genre] : _1 }
end