Class: ProxyFetcher::Document::AbstractAdapter
- Inherits:
-
Object
- Object
- ProxyFetcher::Document::AbstractAdapter
- Defined in:
- lib/proxy_fetcher/document/adapters/abstract_adapter.rb
Overview
Abstract HTML parser adapter class. Handles document manipulations.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#events ⇒ Hash
readonly
A hash with events registered within a bus.
Class Method Summary collapse
-
.setup!(*args) ⇒ Object
Installs adapter requirements.
Instance Method Summary collapse
-
#initialize(document) ⇒ AbstractAdapter
constructor
Initialize adapter.
-
#proxy_node ⇒ ProxyFetcher::Document::Node
Returns
Node
class that will handle HTML nodes for particular adapter. -
#xpath(selector) ⇒ Object
You can override this method in your own adapter class.
Constructor Details
#initialize(document) ⇒ AbstractAdapter
Initialize adapter
16 17 18 |
# File 'lib/proxy_fetcher/document/adapters/abstract_adapter.rb', line 16 def initialize(document) @document = document end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
10 11 12 |
# File 'lib/proxy_fetcher/document/adapters/abstract_adapter.rb', line 10 def document @document end |
#events ⇒ Hash (readonly)
Returns A hash with events registered within a bus.
10 |
# File 'lib/proxy_fetcher/document/adapters/abstract_adapter.rb', line 10 attr_reader :document |
Class Method Details
.setup!(*args) ⇒ Object
Installs adapter requirements.
44 45 46 47 48 49 |
# 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.) end |
Instance Method Details
#proxy_node ⇒ ProxyFetcher::Document::Node
Returns Node
class that will handle HTML nodes for particular adapter.
35 36 37 |
# File 'lib/proxy_fetcher/document/adapters/abstract_adapter.rb', line 35 def proxy_node self.class.const_get("Node") end |
#xpath(selector) ⇒ Object
You can override this method in your own adapter class
25 26 27 |
# File 'lib/proxy_fetcher/document/adapters/abstract_adapter.rb', line 25 def xpath(selector) document.xpath(selector) end |