Sha256: 92700a400893d011007abd4b561bffaf08d8aade3aa58bebd203b0beaffc704e

Contents?: true

Size: 996 Bytes

Versions: 7

Compression:

Stored size: 996 Bytes

Contents

module UsdaNutrientDatabase
  module Import
    class FoodsNutrients < Base

      private

      def columns
        [
          :nutrient_databank_number, :nutrient_number, :nutrient_value,
          :num_data_points, :standard_error, :src_code, :derivation_code,
          :ref_nutrient_databank_number, :add_nutrient_mark, :num_studies, :min,
          :max, :degrees_of_freedom, :lower_error_bound, :upper_error_bound,
          :statistical_comments, :add_mod_date
        ]
      end

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

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

      def filename
        'NUT_DATA.txt'
      end

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