Class: ODDB::Import::PharmNet::EncodedParser

Inherits:
Mechanize::Page
  • Object
show all
Defined in:
lib/oddb/import/pharmnet.rb

Constant Summary collapse

@@iconv =
Iconv.new('utf8', 'latin1')

Instance Method Summary collapse

Constructor Details

#initialize(uri = nil, response = nil, body = nil, code = nil) ⇒ EncodedParser

Returns a new instance of EncodedParser.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/oddb/import/pharmnet.rb', line 17

def initialize(uri=nil, response=nil, body=nil, code=nil)
  body = @@iconv.iconv(body.gsub(/iso-8859-1/i, 'utf-8'))
  ## HtmlEntities seems to kill the parser, do it manually for now
  #htmlentities = HTMLEntities.new
  #body = htmlentities.decode(body)
  body.gsub! 'á', 'á'
  body.gsub! 'à', 'à'
  body.gsub! 'ä', 'ä'
  body.gsub! 'é', 'é'
  body.gsub! 'è', 'è'
  body.gsub! 'ë', 'ë'
  body.gsub! 'í', 'í'
  body.gsub! 'ì', 'ì'
  body.gsub! 'ï', 'ï'
  body.gsub! 'ó', 'ó'
  body.gsub! 'ò', 'ò'
  body.gsub! 'ö', 'ö'
  body.gsub! 'ú', 'ú'
  body.gsub! 'ù', 'ù'
  body.gsub! 'ü', 'ü'
  super(uri, response, body, code)
end