lib/html2rss/item_extractors/html.rb in html2rss-0.9.0 vs lib/html2rss/item_extractors/html.rb in html2rss-0.10.0
- old
+ new
@@ -1,11 +1,13 @@
+# frozen_string_literal: true
+
module Html2rss
module ItemExtractors
##
- # Return the HTML of the attribute.
+ # Returns the HTML content of the specified element.
#
- # Imagine this HTML structure:
+ # Example HTML structure:
#
# <p>Lorem <b>ipsum</b> dolor ...</p>
#
# YAML usage example:
#
@@ -15,18 +17,28 @@
# extractor: html
#
# Would return:
# '<p>Lorem <b>ipsum</b> dolor ...</p>'
#
- # Always make sure to sanitize the HTML during post processing with
- # {AttributePostProcessors::SanitizeHtml}[rdoc-ref:Html2rss::AttributePostProcessors::SanitizeHtml].
+ # Always ensure to sanitize the HTML during post-processing with
+ # {AttributePostProcessors::SanitizeHtml}.
class Html
+ # The available options for the html extractor.
+ Options = Struct.new('HtmlOptions', :selector, keyword_init: true)
+
+ ##
+ # Initializes the Html extractor.
+ #
+ # @param xml [Nokogiri::XML::Element]
+ # @param options [Options]
def initialize(xml, options)
- @element = ItemExtractors.element(xml, options)
+ @element = ItemExtractors.element(xml, options.selector)
end
##
- # @return [String]
+ # Retrieves and returns the HTML content of the element.
+ #
+ # @return [String] The HTML content.
def get
@element.to_s
end
end
end