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.



419
420
421
# File 'lib/oddb2xml/extractor.rb', line 419

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

Instance Method Details

#to_hashObject



422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/oddb2xml/extractor.rb', line 422

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