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

Returns a new instance of ZurroseExtractor.



411
412
413
# File 'lib/oddb2xml/extractor.rb', line 411

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

Instance Method Details

#to_hashObject



414
415
416
417
418
419
420
421
422
423
424
# File 'lib/oddb2xml/extractor.rb', line 414

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)
    }
  end if @io
  data
end