Sha256: a5ef58fc2075d177e1baa990a5cc449b42dc1b1a1106ece25009b105870b6280

Contents?: true

Size: 740 Bytes

Versions: 7

Compression:

Stored size: 740 Bytes

Contents

module UsdaNutrientDatabase
  module Import
    class Nutrients < Base

      private

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

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

      def columns
        @columns ||= [
          :nutrient_number, :units, :tagname, :nutrient_description,
          :number_decimal_places, :sort_record_order
        ]
      end

      def filename
        'NUTR_DEF.txt'
      end

      def log_import_started
        UsdaNutrientDatabase.log 'Importing nutrients'
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
usda-nutrient-database-1.0.1 lib/usda_nutrient_database/import/nutrients.rb
usda-nutrient-database-1.0.0 lib/usda_nutrient_database/import/nutrients.rb
usda-nutrient-database-0.8.1 lib/usda_nutrient_database/import/nutrients.rb
usda-nutrient-database-0.8.0 lib/usda_nutrient_database/import/nutrients.rb
usda-nutrient-database-0.7.0 lib/usda_nutrient_database/import/nutrients.rb
usda-nutrient-database-0.6.0 lib/usda_nutrient_database/import/nutrients.rb
usda-nutrient-database-0.5.0 lib/usda_nutrient_database/import/nutrients.rb