Module: Oddb2xml::TxtExtractorMethods

Included in:
LppvExtractor
Defined in:
lib/oddb2xml/extractor.rb

Instance Method Summary collapse

Instance Method Details

#initialize(str) ⇒ Object



11
12
13
14
# File 'lib/oddb2xml/extractor.rb', line 11

def initialize(str)
  Oddb2xml.log("TxtExtractorMethods #{str} #{str.to_s.size} bytes")
  @io = StringIO.new(str)
end

#to_hashObject



16
17
18
19
20
21
22
23
24
# File 'lib/oddb2xml/extractor.rb', line 16

def to_hash
  data = {}
  while (line = @io.gets)
    next unless /\d{13}/.match?(line)
    ean13 = line.chomp.delete("\"")
    data[ean13] = true
  end
  data
end