Sha256: 9a974eb50480c0acae2ed1771348dab4d59a951a87c6772d6ab075ad58f3b359

Contents?: true

Size: 636 Bytes

Versions: 4

Compression:

Stored size: 636 Bytes

Contents

module UsdaNutrientDatabase
  module Import
    class SourceCodes < Base

      private

      def extract_row(row)
        build_source_code(row).save
      end

      def build_source_code(row)
        UsdaNutrientDatabase::SourceCode.new.tap do |source_code|
          columns.each_with_index do |column, index|
            source_code.send("#{column}=", row[index])
          end
        end
      end

      def columns
        [:code, :description]
      end

      def log_import_started
        UsdaNutrientDatabase.log 'Source code import started'
      end

      def filename
        'SRC_CD.txt'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
usda-nutrient-database-1.0.1 lib/usda_nutrient_database/import/source_codes.rb
usda-nutrient-database-1.0.0 lib/usda_nutrient_database/import/source_codes.rb
usda-nutrient-database-0.8.1 lib/usda_nutrient_database/import/source_codes.rb
usda-nutrient-database-0.8.0 lib/usda_nutrient_database/import/source_codes.rb