Sha256: df58d12b64a66fe42b8c504545600d6266dc6de713ff0e9792dab622224287c1

Contents?: true

Size: 797 Bytes

Versions: 5

Compression:

Stored size: 797 Bytes

Contents

require_relative 'item_extractors/attribute'
require_relative 'item_extractors/current_time'
require_relative 'item_extractors/href'
require_relative 'item_extractors/html'
require_relative 'item_extractors/static'
require_relative 'item_extractors/text'

module Html2rss
  ##
  # Provides a namespace for item extractors.
  module ItemExtractors
    DEFAULT = 'text'.freeze

    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

    ##
    # @return [Nokogiri::XML::Element]
    def self.element(xml, options)
      selector = options['selector']
      selector ? xml.css(selector) : xml
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
html2rss-0.5.2 lib/html2rss/item_extractors.rb
html2rss-0.5.1 lib/html2rss/item_extractors.rb
html2rss-0.5.0 lib/html2rss/item_extractors.rb
html2rss-0.4.1 lib/html2rss/item_extractors.rb
html2rss-0.4.0 lib/html2rss/item_extractors.rb