Class: Cosing::Annex::III

Inherits:
Base
  • Object
show all
Defined in:
lib/cosing/annex/iii.rb

Defined Under Namespace

Classes: Rule

Class Method Summary collapse

Methods inherited from Base

#add_rule, #initialize, #keys, #lookup

Constructor Details

This class inherits a constructor from Cosing::Annex::Base

Class Method Details

.loadObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cosing/annex/iii.rb', line 14

def self.load
  new.tap do |annex|
    Annex.parse("data/annex.III.csv") do |row|
      common_ingredients = Cosing::Parser.transform_array!(
        row,
        key: :common_ingredients,
        split: ";"
      )
      identified_ingredients = Cosing::Parser.transform_array!(
        row,
        key: :identified_ingredients,
        split: ";"
      )

      annex.add_rule(
        row.merge(
          common_ingredients: common_ingredients.compact,
          identified_ingredients: identified_ingredients.compact,
          other_restrictions: row[:other]
        )
      )
    end
  end
end