Class: Reading::Parsing::Attributes::Experiences::HistoryTransformer
- Defined in:
- lib/reading/parsing/attributes/experiences/history_transformer.rb
Overview
Experiences#transform_from_parsed delegates to this class when the History column is not blank (i.e. when experiences should be extracted from History and not the Start Dates, End Dates, and Head columns).
Instance Method Summary collapse
-
#initialize(parsed_row, head_index) ⇒ HistoryTransformer
constructor
A new instance of HistoryTransformer.
-
#transform ⇒ Array<Hash>
Extracts experiences from the parsed row.
Constructor Details
#initialize(parsed_row, head_index) ⇒ HistoryTransformer
Returns a new instance of HistoryTransformer.
34 35 36 37 38 |
# File 'lib/reading/parsing/attributes/experiences/history_transformer.rb', line 34 def initialize(parsed_row, head_index) @parsed_row = parsed_row @head_index = head_index @next_open_range_id = 0 end |
Instance Method Details
#transform ⇒ Array<Hash>
Extracts experiences from the parsed row.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/reading/parsing/attributes/experiences/history_transformer.rb', line 43 def transform experiences = parsed_row[:history].map { |entries| { spans: spans_from_history_entries(entries), group: entries.first[:group], variant_index: (entries.first[:variant] || 1).to_i - 1, } } Experiences::SpansValidator.validate(experiences, history_column: true) experiences end |