Sha256: 3cd234b96390bb4deff6e9abd43a354d83d9df7ebc56e6e45e3029ae16b6d067

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

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

    def self.get_extractor(name)
      @get_extractor ||= Hash.new do |extractors, key|
        camel_cased_name = (key || DEFAULT).split('_').map(&:capitalize).join
        class_name = ['Html2rss', 'ItemExtractors', camel_cased_name].join('::')
        extractors[key] = Object.const_get(class_name)
      end

      @get_extractor[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

1 entries across 1 versions & 1 rubygems

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