Class: Html2rss::Selectors::Extractors::Html
- Inherits:
-
Object
- Object
- Html2rss::Selectors::Extractors::Html
- Defined in:
- lib/html2rss/selectors/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 PostProcessors::SanitizeHtml.
Defined Under Namespace
Classes: Options
Constant Summary collapse
- DESCRIPTION =
JSON Schema description exported via
schema_doc. 'Return the outer HTML of the selected element. ' \ 'Sanitize during post-processing (e.g. `sanitize_html`).'
- EXAMPLES =
Example extractor name values for JSON Schema
examples. [ 'html' ].freeze
Class Method Summary collapse
-
.schema_doc ⇒ Hash{Symbol => Object}
JSON Schema fragment for this extractor name.
Instance Method Summary collapse
-
#get ⇒ String
Retrieves and returns the HTML content of the element.
-
#initialize(xml, options) ⇒ Html
constructor
Initializes the Html extractor.
Constructor Details
#initialize(xml, options) ⇒ Html
Initializes the Html extractor.
47 48 49 |
# File 'lib/html2rss/selectors/extractors/html.rb', line 47 def initialize(xml, ) @element = Extractors.element(xml, .selector) end |
Class Method Details
.schema_doc ⇒ Hash{Symbol => Object}
Returns JSON Schema fragment for this extractor name.
39 |
# File 'lib/html2rss/selectors/extractors/html.rb', line 39 def self.schema_doc = SchemaDoc.for_extractor(name: :html, klass: self) |
Instance Method Details
#get ⇒ String
Retrieves and returns the HTML content of the element.
55 56 57 |
# File 'lib/html2rss/selectors/extractors/html.rb', line 55 def get @element.to_s end |