Class: Html2rss::ItemExtractors::Text
- Inherits:
-
Object
- Object
- Html2rss::ItemExtractors::Text
- Defined in:
- lib/html2rss/item_extractors/text.rb
Overview
Return the text of the attribute. This is the default extractor used, when no extractor is explicitly given.
Imagine this HTML structure:
<p>Lorem <b>ipsum</b> dolor ...</p>
YAML usage example:
selectors:
description:
selector: p
extractor: text
Would return:
'Lorem ipsum dolor ...'
Instance Method Summary collapse
- #get ⇒ String
-
#initialize(xml, options) ⇒ Text
constructor
A new instance of Text.
Constructor Details
#initialize(xml, options) ⇒ Text
Returns a new instance of Text
21 22 23 |
# File 'lib/html2rss/item_extractors/text.rb', line 21 def initialize(xml, ) @element = ItemExtractors.element(xml, ) end |
Instance Method Details
#get ⇒ String
27 28 29 |
# File 'lib/html2rss/item_extractors/text.rb', line 27 def get @element.text.to_s.strip.split.join(' ') end |