Class: ODDB::Import::PharmNet::RenewableAgent

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

Instance Method Summary collapse

Constructor Details

#initialize(agent) ⇒ RenewableAgent

Returns a new instance of RenewableAgent.



41
42
43
44
# File 'lib/oddb/import/pharmnet.rb', line 41

def initialize agent
  super
  renew!
end

Instance Method Details

#renew!Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/oddb/import/pharmnet.rb', line 45

def renew!
  agent = __getobj__.class.new
  proxies = ODDB.config.http_proxies
  host, port = proxies.at rand(proxies.size)
  if host
    ODDB.logger.debug('PharmNet') {
      "Using proxy server #{host}:#{port}"
    }
    agent.set_proxy host, port
  end
  agent.pluggable_parser.html = EncodedParser
  __setobj__ agent
end