444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
|
# File 'lib/oddb2xml/extractor.rb', line 444
def to_hash
data = {}
while line = @io.gets
if @@extended
next unless line =~ /(\d{13})(\d{1})\r\n$/
else
next unless line =~ /(7680\d{9})(\d{1})\r\n$/
end
pharma_code = line[3..9]
if $1.to_s == '0000000000000'
@@items_without_ean13s += 1
ean13 = '000000' + pharma_code else
ean13 = $1.to_s
end
if data[ean13]
@@error_file.puts "Duplicate ean13 #{ean13} in line \nact: #{line.chomp}\norg: #{data[ean13][:line]}"
@@items_without_ean13s -= 1
@@duplicated_ean13s += 1
next
end
data[ean13] = {
:line => line.chomp,
:ean => ean13,
:vat => $2.to_s,
:description => line[10..59], :additional_desc => '',
:pharmacode => pharma_code,
:price => sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, '.\1').to_f),
:pub_price => sprintf("%.2f", line[66,6].gsub(/(\d{2})$/, '.\1').to_f),
:type => :nonpharma,
}
@@zur_rose_items += 1
end if @io
data
end
|