Class: Oddb2xml::ZurroseExtractor

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

Instance Attribute Summary

Attributes inherited from Extractor

#xml

Instance Method Summary collapse

Methods inherited from Extractor

#correct_code

Constructor Details

#initialize(dat) ⇒ ZurroseExtractor



415
416
417
# File 'lib/oddb2xml/extractor.rb', line 415

def initialize(dat)
  @io = StringIO.new(dat) if dat
end

Instance Method Details

#to_hashObject



418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/oddb2xml/extractor.rb', line 418

def to_hash
  data = {}
  while line = @io.gets
    next unless line =~ /(7680\d{9})(\d{1})\r\n$/
    data[$1.to_s] = {
     :vat   => $2.to_s,
     :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),
    }
  end if @io
  data
end