require_relative 'parsing/helpers' require_relative 'parsing/classifications' module Eco::API::UseCases::GraphQL::Samples::Location::Service module TreeDiff module Convertible # Helpers for transform module Parsing include Helpers include Classifications private # Custom callback to some required convertions to the input file # provided that it fits to the required input format. def transform_input_csv(csv) row_transform = custom_input_row_transform_block csv_transform = custom_input_csv_transform_block csv = csv_transform.call(csv) if csv_transform msg = "Expecting Eco::CSV::Table (i.e. from 'custom_input_csv_transform')." msg << "Given: #{csv.class}" raise ArgumentError, msg unless csv.is_a?(Eco::CSV::Table) csv.each do |row| row_transform&.call(row) transform_classifications(row) end csv end # The user define block for row transformation def custom_input_row_transform_block return nil unless respond_to?(:custom_input_row_transform, true) method(:custom_input_row_transform) end # The user define block for row transformation def custom_input_csv_transform_block return nil unless respond_to?(:custom_input_csv_transform, true) method(:custom_input_csv_transform) end end end end end