Class: Oddb2xml::ZurroseExtractor
- Defined in:
- lib/oddb2xml/extractor.rb
Instance Attribute Summary
Attributes inherited from Extractor
Instance Method Summary collapse
-
#initialize(dat) ⇒ ZurroseExtractor
constructor
A new instance of ZurroseExtractor.
- #to_hash ⇒ Object
Methods inherited from Extractor
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_hash ⇒ Object
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 |