Class: Oddb2xml::MigelExtractor
- Defined in:
- lib/oddb2xml/extractor.rb
Instance Attribute Summary
Attributes inherited from Extractor
Instance Method Summary collapse
-
#initialize(bin) ⇒ MigelExtractor
constructor
A new instance of MigelExtractor.
- #to_hash ⇒ Object
Methods inherited from Extractor
Constructor Details
#initialize(bin) ⇒ MigelExtractor
Returns a new instance of MigelExtractor.
316 317 318 319 320 |
# File 'lib/oddb2xml/extractor.rb', line 316 def initialize(bin) io = StringIO.new(bin) book = Spreadsheet.open(io, 'rb') @sheet = book.worksheet(0) end |
Instance Method Details
#to_hash ⇒ Object
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/oddb2xml/extractor.rb', line 321 def to_hash data = {} @sheet.each_with_index do |row, i| next if i.zero? phar = correct_code(row[1].to_s.gsub(/[^0-9]/, ''), 7) ean = row[0].to_i.to_s ean = '9999'+phar+'99' unless ean.length == 13 data[ean] = { :refdata => true, :ean => ean, :pharmacode => phar, :desc_de => row[3], :desc_fr => row[4], :quantity => row[5], # quantity :company_name => row[6], :company_ean => row[7].to_i.to_s, } end data end |