Class: Html2rss::ItemExtractors::Text
- Inherits:
-
Object
- Object
- Html2rss::ItemExtractors::Text
- Defined in:
- lib/html2rss/item_extractors/text.rb
Overview
Return the text content of the attribute. This is the default extractor used, when no extractor is explicitly given.
Example HTML structure:
<p>Lorem <b>ipsum</b> dolor ...</p>
YAML usage example:
selectors:
description:
selector: p
extractor: text
Would return:
'Lorem ipsum dolor ...'
Defined Under Namespace
Classes: Options
Instance Method Summary collapse
-
#get ⇒ String
Retrieves and returns the text content of the element.
-
#initialize(xml, options) ⇒ Text
constructor
Initializes the Text extractor.
Constructor Details
#initialize(xml, options) ⇒ Text
Initializes the Text extractor.
31 32 33 |
# File 'lib/html2rss/item_extractors/text.rb', line 31 def initialize(xml, ) @element = ItemExtractors.element(xml, .selector) end |
Instance Method Details
#get ⇒ String
Retrieves and returns the text content of the element.
39 40 41 |
# File 'lib/html2rss/item_extractors/text.rb', line 39 def get @element.text.to_s.strip.gsub(/\s+/, ' ') end |