Class: ProxyFetcher::Document
- Inherits:
-
Object
- Object
- ProxyFetcher::Document
- Defined in:
- lib/proxy_fetcher/document.rb,
lib/proxy_fetcher/document/node.rb,
lib/proxy_fetcher/document/adapters.rb,
lib/proxy_fetcher/document/adapters/oga_adapter.rb,
lib/proxy_fetcher/document/adapters/abstract_adapter.rb,
lib/proxy_fetcher/document/adapters/nokogiri_adapter.rb
Overview
HTML document abstraction class. Used to work with different HTML parser adapters such as Nokogiri, Oga or a custom one. Stores <i>backend</i< that will handle all the DOM manipulation logic.
Defined Under Namespace
Classes: AbstractAdapter, Adapters, Node, NokogiriAdapter, OgaAdapter
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
Class Method Summary collapse
-
.parse(data) ⇒ ProxyFetcher::Document
Parses raw HTML data to abstract ProxyFetcher document.
Instance Method Summary collapse
-
#initialize(backend) ⇒ Document
constructor
Initialize abstract ProxyFetcher HTML Document.
-
#xpath(*args) ⇒ Array<ProxyFetcher::Document::Node>
Searches elements by XPath selector.
Constructor Details
#initialize(backend) ⇒ Document
Initialize abstract ProxyFetcher HTML Document
27 28 29 |
# File 'lib/proxy_fetcher/document.rb', line 27 def initialize(backend) @backend = backend end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
10 11 12 |
# File 'lib/proxy_fetcher/document.rb', line 10 def backend @backend end |
Class Method Details
.parse(data) ⇒ ProxyFetcher::Document
Parses raw HTML data to abstract ProxyFetcher document.
19 20 21 |
# File 'lib/proxy_fetcher/document.rb', line 19 def self.parse(data) new(ProxyFetcher.config.adapter_class.parse(data)) end |
Instance Method Details
#xpath(*args) ⇒ Array<ProxyFetcher::Document::Node>
Searches elements by XPath selector.
36 37 38 |
# File 'lib/proxy_fetcher/document.rb', line 36 def xpath(*args) backend.xpath(*args).map { |node| backend.proxy_node.new(node) } end |