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

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

Overview

Handles schema.org ItemList objects, which contain

  1. itemListElements, and/or

  2. interesting attributes, i.e. description, url, image, itself.

Constant Summary collapse

SUPPORTED_TYPES =
Set['ItemList']

Constants inherited from Thing

Thing::DEFAULT_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Thing

#description, #id, #image, #initialize, #published_at, #title, #url

Constructor Details

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

Instance Method Details

#callArray<Hash>

Returns the scraped article hashes with DEFAULT_ATTRIBUTES.

Returns:

  • (Array<Hash>)

    the scraped article hashes with DEFAULT_ATTRIBUTES

[View source]

17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/html2rss/auto_source/scraper/schema/item_list.rb', line 17

def call
  hashes = [super]

  return hashes if (elements = @schema_object[:itemListElement]).nil?

  elements = [elements] unless elements.is_a?(Array)

  elements.each do |schema_object|
    hashes << ListItem.new(schema_object, url: @url).call
  end

  hashes
end