Class: Reading::Parsing::Attributes::Title

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

Overview

Transformer for the :title item attribute.

Instance Method Summary collapse

Instance Method Details

#transform_from_parsed(parsed_row, head_index) ⇒ 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
13
14
15
16
17
# File 'lib/reading/parsing/attributes/title.rb', line 9

def transform_from_parsed(parsed_row, head_index)
  title = parsed_row[:head][head_index][:title]

  if title.nil? || title.end_with?(" -")
    raise InvalidHeadError, "Missing title in the head #{parsed_row[:head][head_index]}"
  end

  title
end