class ProxyFetcher::Document::Adapters

ProxyFetcher HTML parser adapters.

ProxyFetcher default supported adapters are:

Any custom adapter can be used and must be inherited from ProxyFetcher::Document::AbstractAdapter.

Constants

ADAPTER

Adapters class name suffix

Public Class Methods

lookup(name_or_class) click to toggle source

Returns HTML parser adapter by it's name or class. If name is provided, then it looks for predefined classes in ProxyFetcher::Document namespace. Otherwise it just returns the passed class.

@param name_or_class [String, Class]

Adapter name or class
# File lib/proxy_fetcher/document/adapters.rb, line 28
def lookup(name_or_class)
  raise Exceptions::BlankAdapter if name_or_class.nil? || name_or_class.to_s.empty?

  case name_or_class
  when Symbol, String
    adapter_name = "#{name_or_class.to_s.capitalize}#{ADAPTER}"
    ProxyFetcher::Document.const_get(adapter_name)
  else
    name_or_class
  end
rescue NameError
  raise Exceptions::UnknownAdapter, name_or_class
end