Class: Oddb2xml::FirstbaseExtractor
- Defined in:
- lib/oddb2xml/extractor.rb
Instance Attribute Summary
Attributes inherited from Extractor
Instance Method Summary collapse
-
#initialize(file) ⇒ FirstbaseExtractor
constructor
A new instance of FirstbaseExtractor.
- #to_hash ⇒ Object
Constructor Details
#initialize(file) ⇒ FirstbaseExtractor
Returns a new instance of FirstbaseExtractor.
597 598 599 |
# File 'lib/oddb2xml/extractor.rb', line 597 def initialize(file) @sheet = RubyXL::Parser.parse(file).worksheets[0] end |
Instance Method Details
#to_hash ⇒ Object
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
# File 'lib/oddb2xml/extractor.rb', line 601 def to_hash data = {} return data unless @sheet @sheet.each_with_index do |row, i| next if i <= 1 if row.nil? puts "Empty row (#{i}) in firstbase" next end gtin = row[0].value.to_s.gsub(/^0+/, '') data[gtin] = { gtin: gtin, gln: row[1].value.to_s, target_market: row[2] ? row[2].value.to_s: "", gpc: row[3] ? row[3].value.to_s: "", trade_item_description_de: row[4] ? row[4].value.to_s: "", trade_item_description_en: row[5] ? row[5].value.to_s: "", trade_item_description_fr: row[6] ? row[6].value.to_s: "", trade_item_description_it: row[7] ? row[7].value.to_s: "", manufacturer_name: row[8] ? row[8].value.to_s: "", start_availability_date: row[9] ? row[9].value.to_s: "", gross_weight: row[10] ? row[10].value.to_s: "", net_weight: row[11] ? row[11].value.to_s: "", } end data end |