lib/cosing/annex/iii.rb in cosing-0.2.0 vs lib/cosing/annex/iii.rb in cosing-0.2.1

- old
+ new

@@ -8,8 +8,33 @@ attribute :inn, Types::String attribute :maximum_concentration, Types::String attribute :other_restrictions, Types::String attribute :product_type, Types::String end + + 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 end end end