Sha256: a75ca9b86ea9b4de480be2fb8a6fdec584df6b5eb979e05753eaab76bbf56278

Contents?: true

Size: 974 Bytes

Versions: 6

Compression:

Stored size: 974 Bytes

Contents

# frozen_string_literal: true

module Html2rss
  module ItemExtractors
    ##
    # Returns a static value provided in the options.
    #
    # Example usage in YAML:
    #
    #    selectors:
    #      author:
    #        extractor: static
    #        static: Foobar
    #
    # Would return:
    #    'Foobar'
    class Static
      # The available option for the static extractor.
      Options = Struct.new('StaticOptions', :static, keyword_init: true)

      ##
      # Initializes the Static extractor.
      #
      # @param _xml [nil, Nokogiri::XML::Element] Unused parameter for compatibility with other extractors.
      # @param options [Options] Options containing the static value.
      def initialize(_xml, options)
        @options = options
      end

      ##
      # Retrieves and returns the static value.
      #
      # @return [String, Symbol] The static value provided in options.
      def get
        @options.static
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
html2rss-0.15.0 lib/html2rss/item_extractors/static.rb
html2rss-0.14.0 lib/html2rss/item_extractors/static.rb
html2rss-0.13.0 lib/html2rss/item_extractors/static.rb
html2rss-0.12.0 lib/html2rss/item_extractors/static.rb
html2rss-0.11.0 lib/html2rss/item_extractors/static.rb
html2rss-0.10.0 lib/html2rss/item_extractors/static.rb