Class: ProxyFetcher::Document::OgaAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/proxy_fetcher/document/adapters/oga_adapter.rb

Overview

HTML parser adapter that uses Oga as a backend.

Defined Under Namespace

Classes: Node

Instance Attribute Summary

Attributes inherited from AbstractAdapter

#document, #events

Class Method Summary collapse

Methods inherited from AbstractAdapter

#initialize, #proxy_node, setup!, #xpath

Constructor Details

This class inherits a constructor from ProxyFetcher::Document::AbstractAdapter

Class Method Details

.install_requirements!Object

Requires Oga gem to the application.



8
9
10
# File 'lib/proxy_fetcher/document/adapters/oga_adapter.rb', line 8

def self.install_requirements!
  require "oga"
end

.parse(data) ⇒ ProxyFetcher::Document::OgaAdapter

Parses raw HTML content with specific gem.

Parameters:

  • data (String)

    HTML content

Returns:



20
21
22
# File 'lib/proxy_fetcher/document/adapters/oga_adapter.rb', line 20

def self.parse(data)
  new(::Oga.parse_html(data))
end