Class: Html2rss::AutoSource::Scraper::Schema::ItemList

Inherits:
Thing
  • Object
show all
Defined in:
lib/html2rss/auto_source/scraper/schema/item_list.rb

Overview

Walks schema.org ItemList objects and yields article-shaped elements only. The ItemList container itself is never emitted.

Constant Summary collapse

SUPPORTED_TYPES =

Schema.org type names handled by the ItemList extractor.

Set['ItemList']

Constants inherited from Thing

Thing::DEFAULT_ATTRIBUTES

Instance Attribute Summary

Attributes inherited from Thing

#base_url, #schema_object

Instance Method Summary collapse

Methods inherited from Thing

#author, #categories, #description, #id, #image, #image_urls, #initialize, #published_at, #title, #url

Constructor Details

This class inherits a constructor from Html2rss::AutoSource::Scraper::Schema::Thing

Instance Method Details

#callArray<Hash>

Returns article hashes from list elements (no parent container).

Returns:

  • (Array<Hash>)

    article hashes from list elements (no parent container)



17
18
19
20
21
22
23
# File 'lib/html2rss/auto_source/scraper/schema/item_list.rb', line 17

def call
  elements = @schema_object[:itemListElement]
  return [] unless elements

  elements = [elements] unless elements.is_a?(Array)
  elements.filter_map { |element| materialize_element(element) }
end