Module: Html2rss::AutoSource::Scraper::Schema::CategoryExtractor

Defined in:
lib/html2rss/auto_source/scraper/schema/category_extractor.rb

Overview

Extracts categories from Schema.org structured data.

Constant Summary collapse

CATEGORY_FIELDS =

Schema.org fields checked for category-like string values.

%i[articleSection keywords categories tags].freeze

Class Method Summary collapse

Class Method Details

.call(schema_object) ⇒ Array<String>

Returns Array of category strings.

Parameters:

  • schema_object (Hash)

    The schema object

Returns:

  • (Array<String>)

    Array of category strings



16
17
18
19
20
21
# File 'lib/html2rss/auto_source/scraper/schema/category_extractor.rb', line 16

def self.call(schema_object)
  Set.new.tap do |categories|
    CATEGORY_FIELDS.each { |field| add_field(categories, schema_object[field]) }
    add_about(categories, schema_object[:about])
  end.to_a
end