Class: Html2rss::ItemExtractors::Text

Inherits:
Object
  • Object
show all
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

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, options)
  @element = ItemExtractors.element(xml, options)
end

Instance Method Details

#getString

Returns:

  • (String)


27
28
29
# File 'lib/html2rss/item_extractors/text.rb', line 27

def get
  @element.text.to_s.strip.split.join(' ')
end