Module: Html2rss::ItemExtractors

Defined in:
lib/html2rss/item_extractors.rb,
lib/html2rss/item_extractors/href.rb,
lib/html2rss/item_extractors/html.rb,
lib/html2rss/item_extractors/text.rb,
lib/html2rss/item_extractors/static.rb,
lib/html2rss/item_extractors/attribute.rb,
lib/html2rss/item_extractors/current_time.rb

Overview

Provides a namespace for item extractors.

Defined Under Namespace

Classes: Attribute, CurrentTime, Href, Html, Static, Text

Constant Summary collapse

DEFAULT =
'text'.freeze

Class Method Summary collapse

Class Method Details

.element(xml, options) ⇒ Nokogiri::XML::Element

Returns:

  • (Nokogiri::XML::Element)


24
25
26
27
# File 'lib/html2rss/item_extractors.rb', line 24

def self.element(xml, options)
  selector = options['selector']
  selector ? xml.css(selector) : xml
end

.get_extractor(name) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/html2rss/item_extractors.rb', line 14

def self.get_extractor(name)
  name ||= DEFAULT
  camel_cased_name = name.split('_').map(&:capitalize).join
  class_name = ['Html2rss', 'ItemExtractors', camel_cased_name].join('::')

  Object.const_get(class_name)
end