Class: Html2rss::Selectors::Extractors::Static

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/selectors/extractors/static.rb

Overview

Returns a static value provided in the options.

Example usage in YAML:

selectors:
 byline:
   extractor: static
   static: Foobar

Would return:

'Foobar'

Defined Under Namespace

Classes: Options

Constant Summary collapse

OPTION_TYPES =

Config-facing option types (excluding shared selector fields supplied at runtime).

{ static: String }.freeze
DESCRIPTION =

JSON Schema description exported via schema_doc.

'Return a fixed value from sibling selector option `static` (no DOM read).'
EXAMPLES =

Example extractor name values for JSON Schema examples.

[
  'static'
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_xml, options) ⇒ Static

Initializes the Static extractor.

Parameters:

  • _xml (nil, Nokogiri::XML::Element)

    Unused parameter for compatibility with other extractors.

  • options (Options)

    Options containing the static value.

Options Hash (options):

  • :static (String, Symbol)

    static value returned by this extractor



42
43
44
# File 'lib/html2rss/selectors/extractors/static.rb', line 42

def initialize(_xml, options)
  @options = options
end

Class Method Details

.schema_docHash{Symbol => Object}

Returns JSON Schema fragment for this extractor name.

Returns:

  • (Hash{Symbol => Object})

    JSON Schema fragment for this extractor name



34
# File 'lib/html2rss/selectors/extractors/static.rb', line 34

def self.schema_doc = SchemaDoc.for_extractor(name: :static, klass: self)

Instance Method Details

#getString, Symbol

Retrieves and returns the static value.

Returns:

  • (String, Symbol)

    The static value provided in options.



50
51
52
# File 'lib/html2rss/selectors/extractors/static.rb', line 50

def get
  @options.static
end