require_relative 'convertible/heading' require_relative 'convertible/parsing' require_relative 'convertible/inputable' module Eco::API::UseCases::GraphQL::Samples::Location::Service module TreeDiff # Offers a way to convert the values and keys/headers # of the input csv file/rows module Convertible class << self def included(base) super base.send :include, Inputable end end include Parsing include Heading private def input_csv @input_csv ||= Eco::CSV.read(input_file, encoding: input_encoding).then do |csv| next csv unless header_maps&.any? csv.transform_headers do |name| next name unless header_maps.key?(name) header_maps[name] end end.then do |csv| transform_input_csv(csv).tap do |res| next if res.is_a?(Eco::CSV::Table) msg = "Expecting and Eco::CSV::Table. Given: #{res.class}" raise ArgumentError, msg end end end end end end