Sha256: c9a6835611c1322f98c562614d144878698cb994d767aa2102f2aee8b081ef8f

Contents?: true

Size: 764 Bytes

Versions: 7

Compression:

Stored size: 764 Bytes

Contents

module UsdaNutrientDatabase
  module Import
    class Weights < Base

      private

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

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

      def filename
        'WEIGHT.txt'
      end

      def columns
        @columns ||= [
          :nutrient_databank_number, :sequence_number, :amount,
          :measurement_description, :gram_weight, :num_data_points,
          :standard_deviation
        ]
      end

      def log_import_started
        UsdaNutrientDatabase.log 'Importing weights'
      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/weights.rb
usda-nutrient-database-1.0.0 lib/usda_nutrient_database/import/weights.rb
usda-nutrient-database-0.8.1 lib/usda_nutrient_database/import/weights.rb
usda-nutrient-database-0.8.0 lib/usda_nutrient_database/import/weights.rb
usda-nutrient-database-0.7.0 lib/usda_nutrient_database/import/weights.rb
usda-nutrient-database-0.6.0 lib/usda_nutrient_database/import/weights.rb
usda-nutrient-database-0.5.0 lib/usda_nutrient_database/import/weights.rb