Class: Oddb2xml::EphaExtractor

Inherits:
Extractor 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(str) ⇒ EphaExtractor

Returns a new instance of EphaExtractor.



347
348
349
# File 'lib/oddb2xml/extractor.rb', line 347

def initialize(str)
  @io = StringIO.new(str)
end

Instance Method Details

#to_arryObject



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/oddb2xml/extractor.rb', line 350

def to_arry
  data = []
  ixno = 0
  while line = @io.gets
    next if line =~ /^ATC1;Name1;ATC2;Name2;/
    row = line.chomp.gsub("\"", '').split(';')
    ixno += 1
    action = {}
    action[:ixno]      = ixno
    action[:title]     = row[4]
    action[:atc1]      = row[0]
    action[:atc2]      = row[2]
    action[:mechanism] = row[5]
    action[:effect]    = row[6]
    action[:measures]  = row[7]
    action[:grad]      = row[8]
    data << action
  end
  data
end