class ProxyFetcher::Document::AbstractAdapter

Abstract HTML parser adapter class. Handles document manipulations.

Attributes

document[R]

@!attribute [r] events

@return [Hash] A hash with events registered within a bus

Public Class Methods

new(document) click to toggle source

Initialize adapter

@return [AbstractAdapter]

# File lib/proxy_fetcher/document/adapters/abstract_adapter.rb, line 16
def initialize(document)
  @document = document
end
setup!(*args) click to toggle source

Installs adapter requirements.

@raise [Exceptions::AdapterSetupError]

adapter can't be install due to some error
# File lib/proxy_fetcher/document/adapters/abstract_adapter.rb, line 44
def self.setup!(*args)
  install_requirements!(*args)
  self
rescue LoadError, StandardError => e
  raise Exceptions::AdapterSetupError.new(name, e.message)
end

Public Instance Methods

proxy_node() click to toggle source

Returns Node class that will handle HTML nodes for particular adapter.

@return [ProxyFetcher::Document::Node]

node
# File lib/proxy_fetcher/document/adapters/abstract_adapter.rb, line 35
def proxy_node
  self.class.const_get("Node")
end
xpath(selector) click to toggle source

You can override this method in your own adapter class

@param selector [String]

XPath selector
# File lib/proxy_fetcher/document/adapters/abstract_adapter.rb, line 25
def xpath(selector)
  document.xpath(selector)
end