Sha256: f3d7431ba0a3fd30b32baef5bb0b840368c2d0c97e13acc6c2edfd4b446521de

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 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)
      @extractors = Hash.new do |hash, key|
        camel_cased_name = key.split('_').map(&:capitalize).join
        class_name = ['Html2rss', 'ItemExtractors', camel_cased_name].join('::')

        hash[key] = Object.const_get(class_name)
      end[name || DEFAULT]
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
html2rss-0.6.0 lib/html2rss/item_extractors.rb