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.
286 287 288 289 290 |
# File 'lib/oddb2xml/extractor.rb', line 286 def initialize(bin) io = StringIO.new(bin) book = Spreadsheet.open(io, 'rb') @sheet = book.worksheet(0) end |
Instance Method Details
#to_hash ⇒ Object
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/oddb2xml/extractor.rb', line 291 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) data[phar] = { :ean => row[0].to_i.to_s, :pharmacode => phar, :desc_de => row[3], :desc_fr => row[4], :additional_desc => row[5], # quantity :company_name => row[6], :company_ean => row[7].to_i.to_s, } end data end |