Class: Html2rss::ItemExtractors::Html

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/item_extractors/html.rb

Overview

Returns the HTML content of the specified element.

Example HTML structure:

<p>Lorem <b>ipsum</b> dolor ...</p>

YAML usage example:

selectors:
  description:
    selector: p
    extractor: html

Would return:

'<p>Lorem <b>ipsum</b> dolor ...</p>'

Always ensure to sanitize the HTML during post-processing with AttributePostProcessors::SanitizeHtml.

Defined Under Namespace

Classes: Options

Instance Method Summary collapse

Constructor Details

#initialize(xml, options) ⇒ Html

Initializes the Html extractor.

Parameters:

  • xml (Nokogiri::XML::Element)
  • options (Options)


33
34
35
# File 'lib/html2rss/item_extractors/html.rb', line 33

def initialize(xml, options)
  @element = ItemExtractors.element(xml, options.selector)
end

Instance Method Details

#getString

Retrieves and returns the HTML content of the element.

Returns:

  • (String)

    The HTML content.



41
42
43
# File 'lib/html2rss/item_extractors/html.rb', line 41

def get
  @element.to_s
end