Class: Oddb2xml::MigelExtractor

Inherits:
Extractor show all
Defined in:
lib/oddb2xml/extractor.rb

Instance Attribute Summary

Attributes inherited from Extractor

#xml

Instance Method Summary collapse

Constructor Details

#initialize(bin) ⇒ MigelExtractor

Returns a new instance of MigelExtractor.



330
331
332
333
334
# File 'lib/oddb2xml/extractor.rb', line 330

def initialize(bin)
  Oddb2xml.log("MigelExtractor #{io} #{File.size(io)} bytes")
  book = Spreadsheet.open(io, 'rb')
  @sheet = book.worksheet(0)
end

Instance Method Details

#to_hashObject



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/oddb2xml/extractor.rb', line 335

def to_hash
  data = {}
  @sheet.each_with_index do |row, i|
    next if i.zero?
    phar = row[1]
    next if phar == 0
    ean13 = row[0]
    ean13 = phar unless ean13.to_s.length == 13
    data[ean] = {
      :refdata         => true,
      :ean13           => ean13,
      :pharmacode      => phar,
      :desc_de         => row[3],
      :desc_fr         => row[4],
      :quantity        => row[5], # quantity
      :company_name    => row[6],
      :company_ean     => row[7],
      :data_origin     => 'migel'
    }
  end
  data
end