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.



361
362
363
# File 'lib/oddb2xml/extractor.rb', line 361

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

Instance Method Details

#to_arry ⇒ Object



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/oddb2xml/extractor.rb', line 364

def to_arry
  data = []
  ixno = 0
  inhalt = @io.read
  inhalt.split("\n").each do |line|
    next if line =~ /ATC1.*Name1.*ATC2.*Name2/
    line = '"'+line unless /^"/.match(line)
    row = CSV.parse_line(line)
    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